Relational vs. Non-Relational Databases
Last updated
Last updated
A relational database, or relational database management system (RDMS), stores information in tables. Often, these tables have shared information between them, causing a relationship to form between tables. This is where a relational database gets its name from.
The details of the product are in a separate product table. This makes information organized and more structured.
ACID compliance
Data accuracy
Normalisation
Flexibility
Scalability
Performance
A non-relational database, sometimes called NoSQL (Not Only SQL), is any kind of database that doesn’t use the tables, fields, and columns structured data concept from relational databases. Non-relational databases have been designed with the cloud in mind, making them great at horizontal scaling.
There are a few different groups of database types that store the data in different ways:
Document databases
Key-value databases
Graph databases
Wide-column databases
Document databases store data in documents, which are usually JSON-like structures that support a variety of data types. These types include strings; numbers like int, float, and long; dates; objects; arrays; and even nested documents. The data is stored in pairs, similar to key/value pairs.
Consider the same customer example as above. In this case, however, we are able to view all the data of one customer in a single place as a single document:
Due to documents being JSON-like, they are much easier to read and understand for a user. The data is organized, and also easy to view. There is no need to reference multiple documents or collections to view data of a single customer. The documents map nicely to objects in code in object-oriented programming languages, making it much easier to work with.
Data is predictable in terms of structure size and frequency of access
Normalisation is a must to keep the size of data low
There is complex relationship between participating entities
You need to work with existing tool sets
Data keeps varying in terms of their structure and size
Your application is distributed across multiple nodes on a cloud
Where we need low latency and eventual consistency