Relational Databases
Relational databases organize data into tables with predefined schemas, establishing relationships between these tables through keys, enabling efficient data...
Relational databases are a type of database that stores and provides access to data points that are related to one another. They are based on the relational model, an intuitive, straightforward way of representing data in tables. A relational database organizes data into one or more tables (or 'relations') of columns and rows, with a unique key identifying each row. Each table column holds a specific kind of data (e.g., 'name', 'age', 'address'), and each row represents a record with a value for each column. Relationships between tables are established using foreign keys, which are columns in one table that refer to the primary key (a unique identifier) in another table. This structure allows for efficient querying and manipulation of data using Structured Query Language (SQL). Key advantages include data integrity (enforced through constraints like primary keys, foreign keys, and data types), data consistency, ease of data retrieval through joins, and support for complex transactions (ACID properties: Atomicity, Consistency, Isolation, Durability). Examples include MySQL, PostgreSQL, Oracle Database, and SQL Server.
graph LR
Center["Relational Databases"]:::main
Pre_data_structures["data-structures"]:::pre --> Center
click Pre_data_structures "/terms/data-structures"
Pre_logic["logic"]:::pre --> Center
click Pre_logic "/terms/logic"
Center --> Child_sql["sql"]:::child
click Child_sql "/terms/sql"
Center --> Child_postgresql["postgresql"]:::child
click Child_postgresql "/terms/postgresql"
Rel_nosql["nosql"]:::related -.-> Center
click Rel_nosql "/terms/nosql"
Rel_data_warehouse["data-warehouse"]:::related -.-> Center
click Rel_data_warehouse "/terms/data-warehouse"
Rel_relational_database["relational-database"]:::related -.-> Center
click Rel_relational_database "/terms/relational-database"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧒 Explain Like I'm 5
Think of a library's card catalog. Each card (row) has information about a book (like title, author), and the cards are organized in a way that lets you easily find all books by a specific author or all books on a certain topic (relationships).
🤓 Expert Deep Dive
The relational model, introduced by E.F. Codd, provides a theoretical foundation based on set theory and first-order predicate logic. Data is represented in normalized tables to reduce redundancy and improve data integrity. Normalization forms (1NF, 2NF, 3NF, BCNF) guide the design process. Relational [database](/en/terms/relational-database) management systems (RDBMS) implement SQL as the standard language for data definition, manipulation, and control. Query optimization is a critical component, where the RDBMS's query optimizer determines the most efficient execution plan for SQL queries, often involving techniques like indexing (B-trees, hash indexes), join algorithms (nested loop, hash join, merge join), and query rewriting. Transaction management ensures ACID properties through mechanisms like locking, logging (write-ahead logging), and concurrency control protocols (e.g., two-phase locking). Distributed relational databases introduce complexities in maintaining consistency and availability across multiple nodes, often employing techniques like two-phase commit (2PC).