SQL ET POSTGRE 3.2 : tables in databases
In this video we look at what tables in a database look like and what they are made of. Tables consist of columns (sometimes called fields) and rows of data. Each column has a defined data type for the values it can hold. For example, if a column has a numeric type such as INTEGER, it can only contain numbers — never words or dates. Every row of data should be unique, so there should not be two identical rows, and each cell should contain only one piece of data — for instance, an email column should not store more than one email per row.
An example table
Let's take an example: a table holding information about a group of French people. It has five columns. Theid column identifies each person, then we have first name, last name, city of residence and the corresponding département. Each column is named and underneath you can see its data type. The id column has an INTEGER type, meaning a numeric value — the values are simply 1, 2, 3, 4. The other columns use VARCHAR, which means they can only accept strings like "Julien" or "Brown". Each field is unique and only stores one piece of information.
- Tables = columns (with a fixed data type) + rows of data.
- Rows should be unique; each cell holds a single value.
- The
idcolumn is a primary key that uniquely identifies each row. - Tables in a relational database can be linked via primary and foreign keys.
id column is special: it is a primary key. We will revisit primary keys in more detail in this section, but in short a primary key identifies each row of a table in a unique way. The numbers in this column run from 1 upwards, which lets us pinpoint any row — for example identifying "Julien Brown" from Nantes in Loire-Atlantique through his id. In a relational database we usually have many tables that can be linked together — an entire section is devoted to relations because that is exactly what makes relational databases so powerful. Tables are connected through primary and foreign keys; the next video focuses on data types before we dive into keys.
Summary
This lesson introduces the fundamental structure of database tables in relational databases. A table consists of columns (fields) with defined data types and rows of unique data, where each field contains only one value. The video demonstrates a practical example using a people table from France and introduces primary keys as unique identifiers for each row in the table.
Key points
- Tables are the core building blocks of relational databases, composed of columns (fields) with defined data types and rows of unique data
- Each column has a specific data type that restricts its contents—for example, INTEGER columns store only numbers, while VARCHAR columns store text strings
- A primary key is a special column that uniquely identifies each row, allowing you to distinguish between records (e.g., using ID numbers 1–5)
- Each field within a row must contain only a single value of its defined type; no field should hold multiple values
- In relational databases, multiple tables can be connected together through primary and foreign keys, creating powerful data relationships
FAQ
What are the main components of a database table?
A table consists of columns (also called fields) that have defined data types (like INTEGER or VARCHAR), and rows that contain unique sets of data where each field holds only one value.
What is a primary key and why does it matter?
A primary key is a special column that uniquely identifies each row in the table. For example, an ID column with values 1–5 lets you identify each person individually (like 'person with ID 1 = Julien Brown from Nantes').
How do tables in a relational database work together?
Multiple tables in a relational database are connected through primary keys and foreign keys, which allows data to be organized efficiently and relationships between different entities to be established—this is what makes relational databases powerful.