LambdaLabTM
Databases & SQL · Class 12 · Database Concepts
databasesterminology⏱️ 8 min read

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.

MySQL command line client
mysql> select * from students;
+------+--------+-------+---------+------------+----------+
| id | name | grade | percent | dob | city |
+------+--------+-------+---------+------------+----------+
| 1099 | Veena | 10 | 90.5 | 2010-11-20 | Singtam |
| 1187 | Anjali | 12 | 91 | 2008-03-04 | Gangtok |
| 1250 | Sohan | 12 | 66 | 2008-12-01 | NULL |
| 1402 | Lhamu | 10 | 95.2 | 2010-09-30 | Namchi |
| 2035 | Ravi | 12 | 83.75 | 2008-08-13 | Gangtok |
| 2044 | Karma | 11 | 78.5 | 2009-07-19 | Singtam |
| 2199 | Diana | 11 | 88.25 | 2009-05-16 | Kolkata |
| 2500 | Bhim | 12 | NULL | 2008-06-22 | Singtam |
| 3033 | Tom | 8 | 64.25 | 2013-02-25 | Kolkata |
| 3120 | Pema | 10 | NULL | 2010-03-28 | Namchi |
| 3301 | Farhan | 9 | 72.8 | 2012-03-09 | Siliguri |
| 3612 | Nima | 9 | 59.4 | 2012-11-11 | NULL |
+------+--------+-------+---------+------------+----------+
12 rows in set (0.00 sec)

2Table, row and column

the whole grid
Table

A structure formed by the intersection of rows and columns.

also called: relation
goes across →
Row

A horizontal structure inside the table. One row holds everything about one student.

also called: tuple, record
goes down ↓
Column

A vertical structure inside the table. One column holds the same fact about every student.

also called: field, attribute

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.

Learn the second names
A question will not always say “row”. It may say tuple or record. It may say attribute or field where you were expecting “column”, and relation where you were expecting “table”. They are exact synonyms.

3Degree and cardinality

These two get asked for by name, constantly, and are easy marks.

Degree

the number of columns in a table

6

id, name, grade, percent, dob, city

Cardinality

the number of rows in a table

12

Veena, Anjali, Sohan … Nima

A way to keep them apart
Cardinality counts the cards you have — one card per row, and you get more of them every time somebody joins. Degree is the other one: the fixed set of columns, which changes only when you redesign the table.

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.

grade

Whole numbers, and realistically 1 to 12. 'Blue' is not in the domain of this column, and neither is 250.

percent

A number with a decimal part, from 0 to 100.

dob

A date. 2010-11-20 is in the domain; 2010-13-45 is not, because there is no month 13.

city

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 word → formal word
EverydayFormalAlso seen asIn the students table
TableRelationstudents
RowTupleRecordOne student, e.g. Ravi's line
ColumnAttributeFieldpercent
Number of columnsDegree6
Number of rowsCardinality12
Allowed valuesDomaingrade holds whole numbers

6Recap

Table = relation

Rows crossed with columns.

Row = tuple = record

Horizontal. One complete entry.

Column = attribute = field

Vertical. One fact about everybody.

Degree / cardinality

Columns / rows. Degree is fixed, cardinality grows.

Quick Check

A table has 8 columns and 40 rows. What is its degree?

Quick Check

Which of these is NOT another name for a row?

Quick Check

Two new students are admitted and their rows are added. What changes?

Quick Check

What is the domain of a column?