Newbie guide to databases

Alexandra Klacanova

by Alexandra Klacanova
· 3 min read

There are a multitude of databases to choose from when deciding how to store your data. They differ in complexity, scalability, data modelling possibilities they offer, and application. Let’s walk through some of the most popular databases and their differences.

SQL vs NoSQL

First, let’s look into the difference between SQL and NoSQL databases. SQL stands for “structured query language”. Thus SQL databases use structured querying. NoSQL databases either use both, or only unstructured querying.

SQL databases are often also referred to as relational. While it is true that relational databases are SQL, not all SQL databases are relational. There are more kinds of databases that store data in a highly structured manner. SQL databases generally leverage tables and scale vertically. In other words, to scale those databases up, you need more powerful hardware. SQL databases are best suited for data that does not change often.

NoSQL databases are less structured. They have different, often flexible schemas that make them ideal for semi-structured data. These databases scale horizontally - they can scale by adding more machines. Horizontal scalability makes NoSQL databases ideal for large and fast-changing datasets.

The main differences between SQL and NoSQL can be summarised in the table below:

SQL NoSQL
Query language SQL NoSQL
Data structure Highly structured Flexible structures/schemas
Data Smaller, more stable data Large, fast-changing data
Speed Faster for single object queries or simple joins Faster for specific query types, path traversals or multiple objects
Scalability Vertically scalable Horizontally scalable
Property followed ACID BASE (only few ACID)

SQL databases

As mentioned above, most SQL databases are relational. Relational databases compose of primary and foreign keys. Primary keys are all unique and linked to specific values within tables in which data is stored. Foreign keys establish relationships, and thus connect, the different tables. Their ACID compliance (atomicity, consistency, isolation and durability) guarantees data validity. Relational databases are still most used today.

NoSQL databases

The most common NoSQL databases include key-value, wide-column, document, search, and graph databases. NoSQL databases are generally BASE compliant (basic availability, soft-state, and eventual consistency). Yet, some NoSQL databases are ACID compliant.

Key-value databases are quite simple, and they are composed of unique keys that each have a value. These databases can host only a limited amount of data. They provide limited data modelling capabilities, which in turn, makes them fast.

Wide-column databases are a bit more complex. They are composed of rows, columns, and tables, but the names of the columns can differ for each row within a single table. Thanks to this, wide-column databases can handle unstructured data.

Document databases work like key-value databases. Each document has a key value that identifies it. As documents do not all have the same structure, these databases do not use a strict schema. Thus, document databases can store unstructured data. The lack of a strict schema makes them general purpose. Most often, they are used for developing games and applications. Documents in these databases can be grouped into collections and indexed in hierarchies, which allows for some degree of relational data modelling.

You can use search databases to build search engines. These databases create an index of searchable terms from documents. When the database is queried, the indexes are searched through, and the related results are returned.

Last on my list are graph databases. Graph databases consist of nodes and edges/relationships among them. These databases are ideal for representing large amounts of densely connected data. They pay equal amounts of attention to the relationships among the data and the data itself. Graph databases’ top use cases include fraud detection, recommendation engines, and Knowledge Graphs. You can read about more graph use cases in our blog post.

There are other types of databases I didn’t mention here, some of them even combine paradigms. They can combine an SQL with a NoSQL, or various NoSQL paradigms. These databases are called multi-model databases. They leverage different database paradigms to optimise their performance. These databases are also ACID compliant.

That was a brief overview of the most well-known kinds of databases however, there are many more. While some of these databases are more used than others, each of these databases serves a specific purpose. Which is the best database for you depends on your use case.

Share this blog post: