Table, Row & Column
This lesson is almost entirely vocabulary, and it is worth learning properly, because exam questions are written in the formal words and not the everyday ones. Every idea here is something you can already see — it just has a second name.
1The table we will use
Here is the whole students table. Every term in this lesson points at some part of it.
2Table, row and column
A structure formed by the intersection of rows and columns.
A horizontal structure inside the table. One row holds everything about one student.
A vertical structure inside the table. One column holds the same fact about every student.
In the table above, | 2035 | Ravi | 12 | 83.75 | 2008-08-13 | Gangtok | is one row — one tuple, one record, one student. The percent column is one attribute, and it holds a percentage for all twelve of them.
3Degree and cardinality
These two get asked for by name, constantly, and are easy marks.
the number of columns in a table
id, name, grade, percent, dob, city
the number of rows in a table
Veena, Anjali, Sohan … Nima
Notice which one moves. Admit a new student and the cardinality becomes 13; the degree is still 6. Adding a column is a change to the design of the table, and that is a much bigger deal.
4Domain
The last term in this group, and the one most often left out of a revision list — then asked for by name.
The domain of a column is the set of permitted values for that column.
Every column has one. It answers: what is this cell allowed to be?
A column is not a free space you can put anything in. Each one has a pool of values that make sense for it, and everything outside that pool is not merely unusual — it is not allowed. That pool is the domain.
Whole numbers, and realistically 1 to 12. 'Blue' is not in the domain of this column, and neither is 250.
A number with a decimal part, from 0 to 100.
A date. 2010-11-20 is in the domain; 2010-13-45 is not, because there is no month 13.
Text — a place name, up to the length the column allows.
Part of the domain is enforced for you by the column's data type, which is the next chapter: a column declared to hold dates will simply refuse a value that is not one.
5All the words in one place
| Everyday | Formal | Also seen as | In the students table |
|---|---|---|---|
| Table | Relation | — | students |
| Row | Tuple | Record | One student, e.g. Ravi's line |
| Column | Attribute | Field | percent |
| Number of columns | Degree | — | 6 |
| Number of rows | Cardinality | — | 12 |
| Allowed values | Domain | — | grade holds whole numbers |
6Recap
Rows crossed with columns.
Horizontal. One complete entry.
Vertical. One fact about everybody.
Columns / rows. Degree is fixed, cardinality grows.
A table has 8 columns and 40 rows. What is its degree?
Which of these is NOT another name for a row?
Two new students are admitted and their rows are added. What changes?
What is the domain of a column?