Sobes.tech
Middle+

What is a relational database and how does it differ from a non-relational one?

sobes.tech AI

Answer from AI

A relational database (RDB) is a type of database where data is organized into tables (relations) with clearly defined columns and rows. Each table has a schema that defines data types and relationships with other tables through keys (primary and foreign).

Main characteristics of relational databases:

  • Strict data schema.
  • Use of SQL for queries.
  • Support for transactions and data integrity.
  • Relationships between tables via keys.

A non-relational database (NoSQL) is a broader class of databases that do not use a tabular model. They can store data as documents (JSON, BSON), key-value pairs, graphs, or columns.

Differences:

  • Flexible or absent schema (schema-less).
  • Different data models (documents, graphs, columns).
  • Often better horizontally scalable.
  • May sacrifice strict integrity for performance and scalability.

Examples:

  • Relational: PostgreSQL, MySQL
  • Non-relational: MongoDB (documents), Redis (key-value), Neo4j (graphs)

The choice depends on data requirements, need for complex relationships, scalability, and consistency.