> For the complete documentation index, see [llms.txt](https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vikram-bajaj.gitbook.io/cs-gy-6083-principles-of-database-systems/the-relational-model-details/relation.md).

# 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:

![](/files/-M5-0b2PLckCNEkhGATr)

## 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.

$$R = (A\_1, A\_2, ..., A\_n)$$ where $$A\_1, A\_2, ..., A\_n$$ are attributes of the relation.

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:

![](/files/-M5-0b2Tgtf246G-zkIr)

Best practices to design "good" relational schemas will be discussed under normalization theory.
