80 likes | 215 Vues
Relations. The Relational Data Model. John Sieg, UMass Lowell. A Relation (or Table). attributes (columns). tuples (rows). John Sieg, UMass Lowell. Relational Model: Definitions. domain - a set of scalar values
E N D
Relations The Relational Data Model John Sieg, UMass Lowell
A Relation (or Table) attributes (columns) tuples (rows) John Sieg, UMass Lowell
Relational Model: Definitions • domain - a set of scalar values • relation on D1,...,Dk (Codd’s definition): a mathematical relation on D1,...,Dk , i.e., a subset of D1 x...x Dk • doesn’t model attribute names John Sieg, UMass Lowell
Definitions, cont’d • scheme - a set S of objects called attribute names or attributes. • Each attribute has a domain, i.e., there is a function dom: S -> {domains} • tuple t on scheme S = {A1, ... , An} - mapping from S to values that are in the appropriate domains, i.e., t(Ai) is in dom(Ai) John Sieg, UMass Lowell
Definitions, cont’d • Relation on scheme S - a set of tuples on S • cardinality, degree • Properties of relations (Date): • There are no duplicate tuples. • Tuples are unordered. • Attributes are unordered. • Attribute values are atomic. • A database is a set of named relations. John Sieg, UMass Lowell
Candidate Keys • candidate key of a relation R - a subset K of R’s scheme having the properties that • (Uniqueness property) No two distinct tuples have the same value(s) for K • No proper subset of K has the uniqueness property. • True over all time! • Every relation has at least one candidate key. John Sieg, UMass Lowell
Primary & Foreign Keys • One of a relation’s candidate key’s is designated to be a primary key. • A foreign key in a relation refers to the primary key of some relation. John Sieg, UMass Lowell
Integrity and Keys (C. J. Date) • The entity integrity rule - No component of a primary key is allowed to accept nulls. • The referential integrity rule - The database must not contain any unmatched foreign key values. John Sieg, UMass Lowell