relation
The term relation is used, among other things, in connection with relational databases. A relation describes a set of tuples - these are the data records. However, the relation does not define the order of the tuples.
The relation only defines whether a tuple belongs to it or not. A relation has the form of a table, and is therefore a combination of rows and columns. In terms of the entity-relationship model, both its entities and relationships themselves are modeled as relations. From a database perspective, a relation does not refer to the relationship between tables. Rather, a relational database model consists of a number of relations, which then store logically related data.
The columns of a relational database are called attributes or fields, and the rows of the table are called tuples or records. The structure of all tuples of a table is the same. The structure of a relation is also called the structure or schema of a table, so the entire set of relation schemas belonging to a database is also defined as the schema of a database. The various database systems do not have a uniform format for relations. The respective database management system defines the formalities for naming relations and attributes.
A relation must generally be characterized as follows:
- The name of a relation must be unique (see example PERSON).
- A relation consists of 0-n tuples - the table rows. The order of the tuples is not important, since a tuple is addressed on the basis of values - and not on the basis of its position.
- A relation consists of 1-m columns - the attributes. Here, too, the order does not matter, since an attribute is addressed on the basis of an attribute name, not on the basis of a position.
- A given attribute contains attribute values that are all taken from one and the same set. This means that all values of a column are of the same type - i.e. numeric, alphabetic or alphanumeric.
- Within a relation, each attribute must have a unique name. This name corresponds to the name of the set from which the values for the attribute are derived.
- Within a relation, the set name is supplemented by a so-called role name, which then describes the meaning assigned to the attribute values. Set names in the example below are LOCAL and DATE and the role names RESIDENCE and BIRTH.
- A relation has at least one key, which is indicated by underlining the key attribute(s).