The relational data model is a way to organize data in a database using tables (also called relations). It was introduced by E. F. Codd in 1970 and is the foundation of relational databases like MySQL, PostgreSQL, and Oracle.
🧱 Key Concepts:
- Relation (Table)
- A set of rows and columns.
- Each table represents a type of entity (e.g.,
Users,Orders).
- Tuple (Row)
- A single record in a table.
- Represents one instance of the entity.
- Attribute (Column)
- A field or property of the entity (e.g.,
Name,Email). - Each column has a data type (e.g., INTEGER, VARCHAR).
- A field or property of the entity (e.g.,
- Primary Key
- A column (or group of columns) that uniquely identifies each row in a table.
- Foreign Key
- A column that links to the primary key of another table, establishing a relationship.
📊 Example: Two Related Tables
Customers
| CustomerID (PK) | Name | |
|---|---|---|
| 1 | Alice | alice@mail.com |
| 2 | Bob | bob@mail.com |
Orders
| OrderID (PK) | CustomerID (FK) | Product |
|---|---|---|
| 101 | 1 | Laptop |
| 102 | 2 | Smartphone |
In this example:
CustomerIDinCustomersis the primary key.CustomerIDinOrdersis a foreign key linking toCustomers.
✅ Benefits of the Relational Model:
- Data integrity via keys and constraints
- Easier querying using SQL
- Normalization helps reduce data redundancy
- Strong theoretical foundation