Relational Database Vs NoSQL
Relational Database Vs NoSQL
As a developer, you will most likely have done a project, and had to use a relational database. It happens all the time on each project. I think I miss very few relational DBMS (Database Management System) that I haven’t used in my profile as DevOp. This has not been the case for non-relational BBDD or also called NoSQL (Not Only SQL) such as MongoDB. I will explain the differences above and in a future article, we will see their use.
Relational Databases
Main Features
- Tabular structure: The data is organized in tables with rows and columns, where each row represents a record and each column an attribute of the record.
- Fixed Schema: Require a predefined schema that determines the structure of data before it can be stored.
- SQL language: Use SQL (Structured Query Language) for data manipulation and query.
- ACID properties: Atomicity, Consistency, Isolation and Durability, which ensures reliable and consistent transactions.
Pros
- Consistency and Security: Ideal for applications that require secure and consistent transactions, such as financial systems.
- Data Integrity: Thanks to the ACID properties, the integrity and consistency of the data is ensured.
- Tools and Support: Wide availability of tools and support due to its long history in the market.
Cons
- Vertical Scalability: Generally they scale better vertically (increasing server capacity) than horizontally (adding more servers).
- Scheme Rigidity: Less flexible to changes in data structure, which may make it difficult to adapt to new needs.
Examples and where you could use it
Relational databases are often used in applications that require primarily transactional systems, where data consistency and integrity are critical and the data have a fixed, well-defined structure. Examples: MySQL/MariaDB, PostgreSQL, Oracle, SQL Server. You can use them in banking systems, inventory management, reservation system, CRM,...
Pro Tip
Do you have to do a lot of JOIN information?. Then opt for using SGBD relational.
NoSQL Databases
Main Features
- Dynamic Schema: Do not require a fixed schema, allowing for storing unstructured or semi-structured data.
- Various Data Models: They include several types such as key-value, documents, columns and graphs.
- Scale Out: Designed to scale easily by adding more nodes to the system.
- Eventual consistency: Often prioritise availability and partitioning tolerance over immediate consistency, following the CAP theorem.
Pros
- Flexibility: Can handle data of different types and structures without the need for a predefined schema.
- Scalability: Scale horizontally efficiently, ideal for applications with high data volumes and high availability needs.
- Performance: They offer high performance in read and write operations.
Cons
- Less Consistency: In many cases they offer instant rather than instant consistency, which may not be suitable for all applications.
- Less Support Tools: Although this is changing, they have historically had fewer tools and support compared to relational databases.
Examples and where you could use it
They are perfect for Big Data and real-time analytics as they support fast access to large volumes of data and the data does not necessarily have to be fixed in structure. Examples: MongoDB (documents), Cassandra (columns or tabular), Redis or Amazon DynamoDB (key-value). The most common use of this type of database is for location, geospatial/streaming/messaging/transaction/inventory data, customer profile, vector embeddings,...
When to choose one or the other?
Obviously, it will be defined by the project you must accomplish. There are no winners or victors, and each one is born with a purpose. I have given you some examples and use cases, but experience will show you which is the most suitable. If you have any questions, you can contact me and I will help you choose which database to use, but if we have to order food, then you choose. 😆
Interesting links
- (FREE) Introduction to NoSQL Databases: https://www.coursera.org/learn/introduction-to-nosql-databases