SQL • SQL FOUNDATIONS

Tables, Rows & Schemas — Explain tables, rows, columns, and schemas (conceptual)

Understanding the fundamental building blocks that organize all data in relational database systems.

Historical Context & Motivation

Before relational databases existed, organizations stored data in flat files, hierarchical databases, and network databases — each approach entangling the physical storage layout with the logical meaning of the data. A programmer who wanted to answer a simple question like "Which customers placed orders last month?" had to write code that navigated pointers, understood file offsets, and was tightly coupled to the specific storage format on disk. Changing the structure of the data meant rewriting every program that touched it. The need for a data-independent model — one that separated what the data means from how the data is stored — drove the development of the relational model and, ultimately, the concepts of tables, rows, columns, and schemas that we study today.

1970
Codd's Relational Model
Edgar F. Codd publishes A Relational Model of Data for Large Shared Data Banks at IBM, proposing that data be organized into relations (tables) with named attributes (columns) and tuples (rows), independent of physical storage.
1974
System R & SEQUEL
IBM researchers develop System R, one of the first relational database prototypes, along with SEQUEL (later renamed SQL), a language designed to manipulate tables declaratively.
1979
Oracle V2 Ships
Relational Software Inc. (later Oracle Corporation) releases the first commercially available SQL-based relational database, proving the table-based model viable for industry.
1986
SQL Becomes a Standard
ANSI publishes the first SQL standard (SQL-86), codifying the concepts of tables, columns, rows, and schemas as the universal vocabulary for relational data management.
2003–Present
SQL Evolves
Subsequent standards (SQL:2003, SQL:2016, SQL:2023) add window functions, JSON support, and more — but the foundational abstractions of tables, rows, columns, and schemas remain unchanged.

The central question Codd's model answered was deceptively simple: How can we represent arbitrary data in a uniform structure that is mathematically precise, easy to reason about, and independent of physical storage? The answer — the humble table — has proven so powerful that over fifty years later it remains the dominant abstraction for structured data across virtually every industry.

Core Principles & Definitions

A relational database is built from a small set of precisely defined abstractions. Understanding each of these — and how they compose together — is the prerequisite for writing correct SQL, designing efficient databases, and reasoning about data integrity. The four foundational concepts are the table (relation), the column (attribute), the row (tuple), and the schema that governs their structure.

1

Table (Relation)

A named, two-dimensional structure consisting of columns and rows. Each table represents a single entity type or relationship in the domain being modeled. In formal relational theory, a table corresponds to a relation — a set of tuples that share the same attributes.
2

Column (Attribute)

A named field within a table that describes one property of the entity. Every column has a data type (e.g., INTEGER, VARCHAR, DATE) that constrains the values it may contain. Columns define the shape of the data; they are analogous to fields in a struct or class.
3

Row (Tuple)

A single record in a table — one concrete instance of the entity. Each row supplies a value (or NULL) for every column. In the relational model, a relation is a set of tuples, so duplicate rows are theoretically disallowed (enforced in practice via primary keys).
4

Schema

The structural blueprint of a database or table. A table schema specifies column names, data types, constraints (NOT NULL, UNIQUE, FOREIGN KEY), and defaults. A database schema is the collection of all table schemas plus their inter-table relationships.
KEY TAKEAWAY
Think of a table as a spreadsheet with strict rules. The column headers are locked (you cannot put a name where a date belongs), every row must conform to those headers, and the entire spreadsheet has a name so other spreadsheets can reference it. The schema is the rule book that enforces all of this — it is the contract between the data and every program that reads or writes it. If a spreadsheet lets you type anything anywhere, a schema-governed table says "this column is an integer and it must not be null."

Visual Explanation — Anatomy of a Table

The gradient header row shows the four columns (attributes). Each horizontal band beneath it is a row (tuple). Note that Dan Kim's major is NULL — the absence of a value. The dashed box at the bottom represents the schema, which prescribes column names, data types, and constraints before any data is inserted.

The diagram above illustrates how the three levels of abstraction compose together. At the lowest level, individual cell values live at the intersection of a column and a row. Each column constrains which values are legal (an INTEGER column rejects the string "hello"), while each row groups related values into a coherent record. The schema wraps all of this with metadata — column ordering, naming conventions, and integrity constraints such as PRIMARY KEY and NOT NULL. This layered design means you can change how you query the data (SELECT, JOIN, WHERE) without changing the schema, and you can evolve the schema (ADD COLUMN, ALTER TYPE) without rewriting every query — a property known as logical data independence.

How It Works — From Theory to DDL

In Codd's relational algebra, a relation R is defined over a set of domains D₁, D₂, …, Dₙ. A relation is a subset of the Cartesian product of those domains. More precisely, R ⊆ D₁ × D₂ × … × Dₙ. Each element of R is an n-tuple, and the heading (schema) assigns a name and domain to each position in the tuple. This formal foundation is what gives SQL its mathematical rigor: every SQL query is ultimately an expression in relational algebra or relational calculus that produces a new relation (i.e., a new table).

RELATION DEFINITION
R ⊆ D₁ × D₂ × … × Dₙ
R is a relation (table). Dᵢ is the domain (data type) of the i-th attribute (column). Each element of R is an n-tuple (row). The heading assigns a name to each Dᵢ.
DEGREE AND CARDINALITY
degree(R) = n | cardinality(R) = |R|
The degree of a relation is the number of columns (n). The cardinality is the number of rows currently in the table. Degree is fixed by the schema; cardinality changes with every INSERT or DELETE.

In practice, the formal relation is realized through SQL's Data Definition Language (DDL). A CREATE TABLE statement translates the mathematical heading into a concrete schema stored in the database's catalog (also called the information schema or data dictionary). The catalog itself is composed of tables — a beautifully recursive design where the database's metadata is stored in the same format as user data. When you write CREATE TABLE students (student_id INT PRIMARY KEY, name VARCHAR(100) NOT NULL, major VARCHAR(50), gpa DECIMAL(3,2)), the RDBMS records the column names, data types, and constraints in catalog tables such as INFORMATION_SCHEMA.COLUMNS and INFORMATION_SCHEMA.TABLE_CONSTRAINTS.

⚠️ SQL vs. Relational Theory
SQL tables differ from mathematical relations in a few important ways. SQL allows duplicate rows (unless a UNIQUE or PRIMARY KEY constraint forbids them), permits NULL values (which have no counterpart in classical set theory), and defines a default column ordering. Purists sometimes call SQL's tables "multisets" or "bags" rather than true sets. Being aware of this gap helps you understand why some SQL behaviors — such as the three-valued logic introduced by NULL — can seem counterintuitive.

Schema Layers — From Column to Catalog

The word "schema" is used at multiple levels in database systems, and conflating them leads to confusion. At the narrowest level, a column definition specifies a name, data type, and optional constraints for a single attribute. A table schema is the ordered list of all such column definitions plus table-level constraints (composite keys, CHECK constraints). A database schema (sometimes called a "namespace" in PostgreSQL or a "schema" in SQL Server) is a named collection of tables, views, and other objects. Finally, the catalog is the metadata repository that stores all schema definitions for an entire database server. Understanding these layers is essential when you encounter SQL statements like CREATE SCHEMA university or fully qualified names like university.students.student_id.

This nested diagram shows how a catalog contains a database schema, which in turn contains multiple table schemas. The orange arrow between students and enrollments represents a foreign key relationship — a constraint declared in the schema that links rows across tables.
The four levels of schema in a typical RDBMS
Schema LevelScopeSQL Syntax / Access
Column DefinitionSingle attributename VARCHAR(100) NOT NULL
Table SchemaAll columns + table constraintsCREATE TABLE students (...)
Database SchemaNamed collection of tables, views, etc.CREATE SCHEMA university
CatalogAll schemas for the server/databaseSELECT * FROM INFORMATION_SCHEMA.TABLES

Worked Example — Designing a Table from Requirements

Suppose a university registrar asks you to store information about courses. Each course has a unique code (e.g., "CS301"), a title, a number of credits (always between 1 and 6), and an optional description. Let us walk through the process of translating these requirements into a well-defined table schema.

Creating the courses Table
1
Step 1 — Identify the Entity and AttributesThe entity is a course. Its attributes are: course_code (unique identifier), title, credits, and description. Each attribute maps to a column.
Columns: course_code, title, credits, description
2
Step 2 — Choose Data Typescourse_code is a short, fixed-length string → CHAR(8). title is a variable-length string → VARCHAR(150). credits is a small integer → SMALLINT. description is potentially long text → TEXT. Selecting the right type ensures the database can validate inputs and optimize storage.
CHAR(8), VARCHAR(150), SMALLINT, TEXT
3
Step 3 — Define Constraintscourse_code uniquely identifies each course, so it becomes the PRIMARY KEY. title must always be provided → NOT NULL. credits must be between 1 and 6 → CHECK (credits BETWEEN 1 AND 6). description is optional, so no NOT NULL constraint is needed (NULL is the default).
PK on course_code, NOT NULL on title, CHECK on credits
4
Step 4 — Write the DDL StatementCombining the above, the complete SQL statement is: CREATE TABLE courses ( course_code CHAR(8) PRIMARY KEY, title VARCHAR(150) NOT NULL, credits SMALLINT NOT NULL CHECK (credits BETWEEN 1 AND 6), description TEXT );
Table courses created with 4 columns, degree = 4, cardinality = 0 (no rows yet).
5
Step 5 — Insert a Row and VerifyWe insert a sample row: INSERT INTO courses VALUES ('CS301', 'Database Systems', 3, 'Relational model, SQL, normalization.'); After insertion, the table has cardinality = 1. A query like SELECT * FROM courses; will return one row with four cell values.
cardinality(courses) = 1

Strengths and Limitations of the Tabular Model

The table abstraction has endured for over fifty years because of its remarkable combination of simplicity and power, but it is not a perfect fit for every data problem. Appreciating both its strengths and its limitations helps you make informed architectural decisions about when to use a relational database and when an alternative model — document, graph, key-value — might serve you better.

Strengths vs. limitations of the relational table model
StrengthsLimitations
Rigorous mathematical foundation (set theory, relational algebra) enables formal reasoning and optimization.Fixed schema makes evolving the structure painful for rapidly changing domains (schema migrations can be complex).
Declarative querying — you specify what you want, not how to get it. The query optimizer handles execution.Deeply nested or hierarchical data (e.g., JSON trees, XML documents) maps awkwardly to flat tables without many JOINs.
Strong data integrity through constraints (PK, FK, UNIQUE, CHECK, NOT NULL) enforced at the database level.Horizontal scaling (distributing data across many servers) is harder than with document or key-value stores.
Mature ecosystem — decades of tooling, indexing strategies, and battle-tested implementations (PostgreSQL, MySQL, Oracle, SQL Server).NULL semantics introduce three-valued logic (TRUE, FALSE, UNKNOWN), which complicates predicates and aggregations.
KEY TAKEAWAY
The tabular model is like a strongly typed programming language: the compiler (schema) catches many errors before runtime (data entry), and the type system (column data types and constraints) guides correct usage. Just as strong typing adds friction when prototyping but pays off in large, long-lived systems, a rigid schema imposes upfront design cost but dramatically reduces data inconsistencies in production. Choosing between a relational model and a schema-less model is analogous to choosing between a statically typed language and a dynamically typed one — each has contexts where it shines.

Connection to Advanced Theory — Normalization and Beyond

Once you understand tables, rows, columns, and schemas, the next conceptual frontier is normalization — the process of organizing tables to reduce redundancy and prevent update anomalies. Normalization is defined through a series of normal forms (1NF through 5NF and beyond), each imposing stricter rules on how columns depend on the primary key. Understanding that a table is a set of tuples with a well-defined heading is the prerequisite for reasoning about functional dependencies (the mathematical relationships between columns) and deciding how to decompose a badly designed table into several well-structured ones.

How foundational concepts extend into advanced database theory
Concept (This Lesson)Advanced Extension
Table as a set of rows with a fixed schemaNormal forms — 1NF requires atomic column values, no repeating groups
Primary key uniquely identifies each rowFunctional dependencies — non-key columns depend on the whole key (2NF, 3NF, BCNF)
Foreign key links rows across tablesReferential integrity, cascading updates/deletes, join algebra
Schema as a blueprint with constraintsSchema evolution, migrations, online DDL, schema versioning
Catalog stores metadataQuery optimizer uses catalog statistics (row counts, value distributions) for plan selection

Beyond normalization, the table abstraction underpins views (virtual tables defined by queries), materialized views (cached query results stored as physical tables), and the entire ACID transaction model. Every time you write a SELECT statement, the query optimizer consults the catalog (schema metadata) to choose indexes, join orders, and access paths. In this sense, the schema is not just documentation — it is an active participant in query execution. As you advance into topics like distributed databases, columnar storage, and data warehousing, you will find that the conceptual vocabulary of tables, rows, columns, and schemas remains the lingua franca, even when the physical implementation diverges dramatically from a simple row-by-row layout on disk.

Practice Problems

PROBLEM 1CONCEPTUAL
In relational theory, a relation is defined as a subset of a Cartesian product of domains. Explain, in your own words, why a relation is a set of tuples rather than a list, and what practical consequence this has for duplicate rows in SQL tables.
PROBLEM 2BASIC CALCULATION
A table employees has columns emp_id INT, first_name VARCHAR(50), last_name VARCHAR(50), department_id INT, salary DECIMAL(10,2), hire_date DATE. What is the degree of this relation? If the table currently holds 2,500 records, what is its cardinality? How many cells (individual values) does the table contain?
PROBLEM 3INTERMEDIATE
Given the following requirements, write a CREATE TABLE statement: A library tracks books. Each book has an ISBN (exactly 13 characters, unique), a title (required, up to 300 characters), a publication year (integer, must be between 1450 and the current year), and an optional page count (positive integer). Identify the primary key and all constraints you would apply.
PROBLEM 4APPLIED
A startup is building an e-commerce platform. They initially store all order data in a single table: orders(order_id, customer_name, customer_email, product_name, product_price, quantity, order_date). Identify at least two problems with this single-table design, and propose a multi-table schema that resolves them. Specify primary and foreign keys.
PROBLEM 5CRITICAL THINKING
SQL tables allow NULL values, but Codd's original relational model was based on set theory, where every element in a tuple must come from its domain. Argue for or against the inclusion of NULL in a relational database system. Consider the impact on query semantics (three-valued logic), constraint enforcement, and practical usability. Support your argument with at least one concrete example.

Summary

Relational databases organize data into tables (relations), where each table models a single entity type or relationship. A table's columns (attributes) define the properties of that entity — each with a name, data type, and optional constraints — while rows (tuples) are individual records that supply a value for every column. The schema is the structural blueprint that governs all of this: it specifies column definitions, primary keys, foreign keys, and CHECK constraints, and it exists at multiple levels — from a single column definition up through the database catalog. The number of columns is the table's degree (fixed by the schema), and the number of rows is its cardinality (variable with data manipulation).

These four abstractions — originating from Codd's 1970 paper and formalized in the SQL standard — remain the foundation upon which all SQL operations, normalization theory, query optimization, and transaction management are built. Mastering them is the essential first step toward designing correct, efficient, and maintainable database systems.

Varsity Tutors • SQL • Tables, Rows & Schemas