Tables, Rows & Columns
The table is the fundamental building block of every relational database. Everything you store, query, and relate lives in tables. Understanding their anatomy precisely is the foundation for everything that follows.
The Relational Model
The relational database model was proposed by E.F. Codd of IBM in his landmark 1970 paper "A Relational Model of Data for Large Shared Data Banks." It remains the dominant model for structured data more than 50 years later.
The core idea is elegant: all data is stored in relations — which we call tables. A table is a two-dimensional structure of rows and columns. Every piece of data has a precise location: a specific column in a specific row of a specific table.
Codd used formal mathematical terms: relation (table), tuple (row), attribute (column). In practice, almost everyone says table, row, and column. Both mean the same thing.
Anatomy of a Table
Let's build a real table from scratch and name every part.
Table name: students
┌────────────┬──────────────┬─────┬──────────────┬─────────────┐
│ student_id │ full_name │ age │ email │ enrolled_on │ ← Column headers (attributes)
├────────────┼──────────────┼─────┼──────────────┼─────────────┤
│ 1 │ Kondwani Banda │ 21 │ p@email.com │ 2025-01-10 │ ← Row 1 (tuple)
│ 2 │ Chimwemwe Moyo│ 23 │ c@email.com │ 2025-01-11 │ ← Row 2
│ 3 │ Mphatso Phiri│ 20 │ m@email.com │ 2025-02-01 │ ← Row 3
└────────────┴──────────────┴─────┴──────────────┴─────────────┘
↑
Cell: intersection of one row and one column
Data Types
Every column has a data type that constrains what values can be stored in it. Choosing the right data type saves storage space, improves performance, and prevents invalid data entering your database.
INT / INTEGERDECIMAL(p, s)VARCHAR(n)CHAR(n)DATE / DATETIMEBOOLEANTEXT / BLOBColumn Constraints
Constraints enforce rules on column data. They are the database's way of rejecting invalid data before it enters the system — far better than trying to clean bad data after it's in.
CREATE TABLE students (
student_id INT PRIMARY KEY AUTO_INCREMENT,
full_name VARCHAR(100) NOT NULL,
email VARCHAR(150) NOT NULL UNIQUE,
age INT CHECK (age >= 16 AND age <= 100),
enrolled_on DATE DEFAULT CURRENT_DATE,
is_active BOOLEAN DEFAULT TRUE
);
NOT NULLUNIQUECHECKDEFAULT