Definition of Database Relation

Not the same as a relationship

Architect looking at database on computer
  AzmanJaka/Getty Images

A database relation is not the same thing as a relational database. It does not imply a relationship between tables, despite its name. Rather, a database relation refers to an individual table in a relational database.

The Definition and Properties of a Relation

In a relational database, the table is a relation because it stores the relation between data in its column-row format. The columns are the table's attributes, and the rows represent the data records. A single row is known as a tuple.

A relation (table) in a relational database has certain properties:

  • Its name must be unique in the database: A database cannot contain multiple tables of the same name.
  • Each relation must have a set of columns (attributes): It must also have a set of rows to contain the data. As with the table names, no attributes can have the same name.
  • No tuple (row) can be a duplicate: In practice, a database might contain duplicate rows, but practices should be in place to avoid this, such as the use of unique primary keys.
  • A relation must contain at least one attribute (column) that identifies each tuple (row) uniquely: This is usually the primary key. This primary key cannot be duplicated. This means that no tuple can have the same unique, primary key. The key cannot have a NULL value, which means that the value must be known.
  • Each cell (field) must contain a single value: For example, you can't enter something like "Tom Smith" and expect the database to understand that you have a first and last name. Rather, the database will understand that the value of that cell is exactly what has been entered.
  • All attributes (columns) must be of the same domain: In other words, they must have the same data type. You can't mix a string and a number in a single cell.

All these properties, or constraints, serve to ensure data integrity, which is important to maintain the accuracy of data.