CH3 - The relational data model and relational database constraints Flashcards
relation
mathematical concept based on the ideas of sets. Informally, a relation looks like a table of values. It typically contains a set of rows. The data elements in each row represent certain facts that correspond to a real-world entity or relationship (in the formal model, rows are called tuples). Each column has a column header that gives an indication of the meaning of the data items in that column (in the formal model, the column header is called an attribute).
key
a value of a data item (or set of items) that uniquely identifies that row in the table. Sometimes row-ids or sequential numbers are assigned as keys to identify the rows in a table, these are called artificial key or surrogate key.
schema (or description)
relation is denoted by R(A1, A2,…, An) where R is the name of the relation and A1, A2,…, An are the attributes of the relation. Each attribute has a domain or set of valid values.
tuple
ordered set of values (). Each value is derived from an appropriate domain. A relation is a set of such tuple
domain
domain has a logical definition as well as a data-type or a format defined for it. The attribute name designates the role played by a domain in a relation.
relation state
a subset of the cartesian product of the domains of its attributes, where each domain contains the set of all possible values the attribute can take
Ordering of tuples in a relation r(R)
the tuples are not considered to be ordered, even though they appear to be in the tabular form.
Ordering of attributes in a relation schema R
the attributes and their values are considered to be ordered. However, this ordering is not required with self-describing representation which includes both the name and the value for each attribute.
Values in a tuple
all values are considered atomic (indivisible). Each value in a tuple must be from the domain of the attribute for that column. A special null value is used to represent values that are unknown or not available or inapplicable in certain tuples
Constraints
determine which values are permissible and which are not in the database. They are of three main types :
- Inherent or implici constraints, which are based on the data model itself
- Schema-based or explicit constraints, which are expressed in the schema by using the facilities provided by the model
- Application based or semantic constraints, which are beyond the expressive power of the model and must be specified and enforced by the application programs
Constraints are conditions that must hold on all valid relation states
three main types of explicit schema-based constraints that can be expressed in the relational model
- Key constraints
- Entity integrity constraints
- Referential integrity constraints
domain constraint
every value in a tuple must be from the domain of its attribute
Superkey
a set of attributes with the following condition : no two tuples in any valid relation state r(R) will have the same value and this condition must hold in any valid state
Key
a minimal superkey. That is, a key is a superkey such that removal of any attribute results in a set of attributes that is not a superkey (that does not possess the superkey uniqueness property). A key is a superkey but not vice versa.
relational database schema
is a set S of relation schemas that belong to the same database. S is the name of the whole database schema S = {R1, R2,…, Rn} and a set IC of integrity constraints. R1, R2,…, Rn are the names of the individual relation schemas within the database S.