Skip to content

Database types

database-types.jpeg

SQL, NoSQL, or Something Else โ€” How Do You Decide Which Database?

The performance of your application can suffer if you choose the incorrect database type, and going back on a bad choice can be time-consuming and expensive.

Before we dive into the factors to take into account when choosing an appropriate database, letโ€™s examine the characteristics of the most widely used databases.

In a ๐—ฟ๐—ฒ๐—น๐—ฎ๐˜๐—ถ๐—ผ๐—ป๐—ฎ๐—น ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ, data is organized in rows and columns where a row represents a record and its data fields are stored in columns. They are ideal for when ACID compliance is required, and a predefined schema can be created.

With ๐—ฐ๐—ผ๐—น๐˜‚๐—บ๐—ป๐—ฎ๐—ฟ ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ๐˜€, records are stored as columns rather than rows. This makes them very performant for analytical purposes where complex queries are run across large datasets; especially those that contain aggregate functions.

In a ๐—ฑ๐—ผ๐—ฐ๐˜‚๐—บ๐—ฒ๐—ป๐˜ ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ, data is stored in a semi-structured format such as JSON. They offer a flexible and schema-less approach which makes them a great choice for data with complex or continually changing structures.

๐—š๐—ฟ๐—ฎ๐—ฝ๐—ต ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ๐˜€ are optimized for storing and querying highly connected data. Records are represented as nodes and relationships as edges. Under the hood, they use graph theory to traverse relationships between nodes to power performant queries.

๐—ž๐—ฒ๐˜†-๐˜ƒ๐—ฎ๐—น๐˜‚๐—ฒ ๐˜€๐˜๐—ผ๐—ฟ๐—ฒ๐˜€ are a simple form of storage where values are inserted, updated, and retrieved using a unique key. They are more commonly used for small datasets and often temporary purposes such as caching or session management.

๐—ง๐—ถ๐—บ๐—ฒ-๐˜€๐—ฒ๐—ฟ๐—ถ๐—ฒ๐˜€ ๐—ฑ๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ๐˜€ are ideal for time-stamped data that are queried and analyzed in relation to time. They provide built-in time-based functions that assist in analyzing large datasets over time.

Each database type has been optimized for specific use cases.

It's important to thoroughly consider the correct database for your use case as it can impact your applicationโ€™s performance.

Below are the considerations that should be made: ๐Ÿ”ธ How structured is your data? ๐Ÿ”ธ How often will the schema change? ๐Ÿ”ธ What type of queries do you need to run? ๐Ÿ”ธ How large is your dataset and do you expect it to grow? ๐Ÿ”ธ How large is each record? ๐Ÿ”ธ What is the nature of the operations you need to run? Is it read-heavy or write-heavy?

Use these questions as a starting point for your analysis. Take the time to investigate your use case and ask questions to your stakeholders and end-users when necessary.

It's important to invest as much time in this decision as needed. Choosing the wrong database type can be detrimental to your applicationโ€™s performance, and difficult to reverse.