Script Valley
Database Management Systems with SQL: Complete Course
Introduction to Database Management SystemsLesson 1.3

The Relational Model: Tables, Rows, and Columns

relational model, relations, tuples, attributes, domains, relational algebra, schema, instance

Introduction

The relational model, proposed by E.F. Codd in 1970, forms the foundation of modern relational Database Management Systems (RDBMS). It represents data in the form of relations (tables) and provides a structured and logical way to store and manipulate data.This model is based on mathematical concepts such as set theory and relational algebra, which also form the basis of SQL. Understanding the relational model is essential for designing efficient, consistent, and scalable databases.

Explanation

In the relational model, a relation is a two-dimensional table with rows and columns. Each relation has a name, a set of attributes (columns), and a set of tuples (rows). Every attribute has a domain โ€” the set of valid values it can hold (e.g., the domain of an age attribute is positive integers).

Key properties of a relation:

  • Each row (tuple) is unique (no duplicates)

  • Each column contains atomic values (single, indivisible values)

  • The order of rows does not matter

  • Each column has a unique name within the table

Real World Example

An e-commerce platform's orders table is a perfect relational model example. Each row represents one order (tuple). Columns represent order_id, user_id, product_id, quantity, price, and order_date (attributes). The order_id attribute's domain is positive integers only. No two rows have the same order_id. The fact that rows have no inherent ordering reflects the relational model's mathematical set theory foundation.

Technical Breakdown

Relational algebra defines six fundamental operations that SQL is built on:

  • Selection (ฯƒ): Filters rows based on a condition. Maps to SQL WHERE clause.

  • Projection (ฯ€): Selects specific columns. Maps to SQL SELECT column list.

  • Union (โˆช): Combines rows from two compatible relations. Maps to SQL UNION.

  • Difference (โˆ’): Returns rows in one relation but not another. Maps to SQL EXCEPT.

  • Cartesian Product (ร—): Combines every row from two relations. Maps to SQL cross join.

  • Join (โ‹ˆ): Combines related rows from two relations. Maps to SQL JOIN.

Schema: A schema defines the structure (table name, columns, data types, constraints).

Instance: An instance is the current set of data stored in that schema at a point in time.

Example

-- Schema definition (structure):
CREATE TABLE products (
    product_id   INT          PRIMARY KEY,
    name         VARCHAR(100) NOT NULL,
    category     VARCHAR(50),
    price        DECIMAL(10,2) NOT NULL,
    stock        INT          DEFAULT 0
);

-- Instance (data stored at this moment):
SELECT * FROM products;
-- product_id | name          | category    | price  | stock
-- 1          | Laptop Pro    | Electronics | 999.99 | 45
-- 2          | Wireless Mouse| Electronics | 29.99  | 120

Common Mistakes

  • Storing multiple values in a single column (e.g., comma-separated tags) โ€” this violates atomicity and breaks the relational model.

  • Confusing schema with instance โ€” the schema is the structure (definition), the instance is the current data.

  • Ignoring domains โ€” allowing any string in a phone_number column that should only hold digits causes data quality problems.

Interview Tips

Be ready to explain the difference between a schema and an instance, and why atomicity of column values matters. Interviewers may also ask about relational algebra โ€” understanding that SQL SELECT maps to projection and WHERE maps to selection demonstrates deep foundational knowledge that separates strong candidates from average ones.

The Relational Model: Tables, Rows, and Columns โ€” Introduction to Database Management Systems โ€” Database Management Systems with SQL: Complete Course โ€” Script Valley โ€” Script Valley