Junior — Middle
How to distinguish relational databases from non-relational ones and what are their main differences?
sobes.tech AI
Answer from AI
Relational databases (RDBs) organize data into tables with clearly defined rows and columns, where each table has a schema (structure) and relationships with other tables through keys (such as primary and foreign keys). They use SQL language for queries and ensure transactional integrity, data consistency, and strict constraints.
Non-relational databases (NoSQL) do not use tables and schemas in the traditional sense. They can store data in key-value, document (JSON), graph, or column formats. NoSQL databases are more flexible, scale horizontally, and are suitable for working with large volumes of data and unstructured data.
Main differences:
- Data structure: RDB — tables with fixed schema; NoSQL — flexible structures (documents, key-value, etc.)
- Query language: RDB — SQL; NoSQL — various APIs and languages
- Scalability: RDB — usually vertical; NoSQL — horizontal
- Transactions: RDB support ACID; NoSQL often sacrifices strict consistency for speed and scalability
Example: MySQL — relational, MongoDB — document-oriented NoSQL database.