A relation is like a table where the attributes are the columns. A relation is its attributes. Each row of the table is an occurrence.
| StudentId | CourseCode | TutorNo |
| s01 | c4 | 3158 |
| s05 | c2 | 5324 |
| s05 | c7 | 5324 |
| s07 | c4 | 3158 |
A row can be written as follows:
< s01, c4, 3158 >
This corresponds with to the occurrence in the first row of the table.
Properties of Relations
There are rules that control this type of table:
- Each value in the table is atomic. i.e. the value in a column is always just one value.
- Each attribute value in each column are always of the same type. They are drawn from the same domain.
- Each column has a different name.
- Each row is unique. At least one of the attributes (or a combination of) will form a key. A single attribute or the smallest combination of attributes will form a primary key. This is mandatory for a table to be a depiction of a relation. In our table above it will be necessary to form a primary key from StudentId and CourseCode.
- There is no significance to the ordering of rows and columns. It is not possible to refer to a column or row by its position. A column must be referred to by its name. A row must be referred to by its primary key.
A relation is an abstract structure. A table is simply a depiction of the structure. Any reference to rows and columns are references to the depiction and not the abstraction.
Relational Terminology
Specific terminology is used to depict relations to take away the references to tabular concerns of row and column:
- Degree is the number of attributes.
- Tuples are the rows. The tuples of a relationship are the extension (or body) of the relation. These can vary over time.
- Cardinality is the number of tuples
The heading of such a relation should be written as follows:
Enrolment (StudentId, CourseCode, TutorNo)
The primary key is placed first and underlined.
A natural language predicate is a device to define the meaning of a relation:
<a, b, c > is a tuple of Enrolment only if a student with StudentId of 'a' takes CourseCode 'b' tutored by TutorNo 'c'.
Null
Occassionally an attribute may not have a value determined. The value can be replaced by a marker. This marker is not a value. The natural language predicate where there may be no tutor allotted is shown below.
<a, b, c > is a tuple of Enrolment only if a student with StudentId of 'a' takes CourseCode 'b' is either tutored by TutorNo 'c' or 'c' is null.
Comments, suggestions, ideas to
Stuart Banner
