Relations
A relational database contains multiple tables/relations.
A relation is a set of tuples where each attribute is part of a domain.
Relations are represented as tables.
The columns of the table represent attributes of the relation and the rows/tuples represent the relationship between the entities i.e. the values for the relation.
The following is an example of a relation:
More about attributes
The set of allowed values for an attribute is called the domain of the attribute
Attribute values are atomic i.e. indivisible (they can't be divided into sub-domains)
The special value null is a member of every domain; it means that the value is not available or is unknown
This null value may cause complications in the definition of many operations
Aggregate functions ignore null values
Relational Schema and Instance
A relational schema consists of a set of attributes and their domains.
An relation instance refers to the tuples of a relation at a particular point in time. It is denoted as a table.
Note that relations are unordered i.e. the order in which the tuples are present in the table is irrelevant.
Database
A database consists of multiple relations.
For example, a university database can have relations including student, instructor, advisor, department etc.
It is good to have separate relations instead of combining all the attributes into a single table. If we use a single table to represent everything, there would be two main issues:
redundancy: ex. more than one student having the same instructor
null values: ex. a student who doesn't have an advisor
The following figure illustrates the university database:
Best practices to design "good" relational schemas will be discussed under normalization theory.
Last updated