Inside a relational database, the table is the primary unit of structured storage. A table is composed of rows, which are individual records, and columns, which are named attributes. Every column has a defined data type that determines what kind of values it can hold, and together the tables are linked to one another through keys.
The primary key is the unique identifier for each row in a table. It guarantees that no two records are identical and makes lookups efficient. A primary key may consist of a single column or several columns combined into a composite key. To model relationships between tables, a foreign key is used: it is a column, or set of columns, in one table that points to the primary key of another. For example, an orders.customer_id foreign key can be linked to customers.id, enforcing referential integrity so that orders cannot reference customers that do not exist.
SQL provides a rich set of data types that vary slightly between systems. Numeric types include INT and FLOAT, string types include VARCHAR and TEXT, date and time types include DATE and TIMESTAMP, and boolean values are represented with BOOLEAN. Beyond data types, constraints shape what values a column can accept. A CHECK constraint enforces domain integrity by restricting values, for example requiring age >= 18. A UNIQUE constraint guarantees that all values in a column are distinct, which is useful for fields like email addresses; unlike PRIMARY KEY, UNIQUE allows NULL values.