You ran a query and got back rows. Here is what those rows come from.
A keeps its data in . This is part of customers:
customers
| id | name | country | city |
|---|---|---|---|
| 1 | Ava Chen | CA | Toronto |
| 2 | Liam Patel | CA | Peterborough |
| 3 | Sofia Rossi | IT | Milan |
- A row describes one thing: here, one customer.
- A column is one fact about each thing: the
countryof every customer. - A value is where a row and a column meet: Liam Patel's country is
CA.
The same table, with one column marked:
customers
| id | name | country | city |
|---|---|---|---|
| 1 | Ava Chen | CA | Toronto |
| 2 | Liam Patel | CA | Peterborough |
| 3 | Sofia Rossi | IT | Milan |
Every column has a type
A column holds one kind of value. Its says which kind. The table tabs in the lab show the type under each column name:
| Column | Type | Example value |
|---|---|---|
id | integer | 4 |
name | text | Noah Kim |
price | numeric(8,2) | 29.99 |
signup_date | date | 2024-03-11 |
is_member | boolean | true |
The database refuses a value of the wrong type. You cannot put hello in an integer column.
The relational model
A database built from tables is a relational database. The theory behind it uses its own words. Textbooks and exams use them, so learn both:
| Everyday word | Relational term |
|---|---|
| table | relation |
| row | tuple |
| column | attribute |
| the values a column allows | domain |
| the table's name and its columns | schema |
The schema of customers is written like this:
customers(id, name, email, country, city, signup_date, is_member)A relation has no fixed row order. Two queries can return the same rows in a different order. Chapter 3 shows how to choose the order.