Thursday, January 26, 2012
perkthim 5
Relational Model: Data Integrity
While the Relational Model: Data Structure section discusses the form for representing data, the data integrity portion of the relation model defines mechanisms for ensuring that stored data is valid. At a minimum this requires the following:
1. Attribute Integrity
This means that values for attributes (columns) should come only from their respective underlying domains. For example, an integer field cannot have double values and a Currency field cannot have varchar (string). Note that the relational model also permits an attribute to contain NULL which is a marker to indicate a missing or unknown value. NULL is not a value, it is only a placeholder.
2. Entity Integrity
This is a straightforward concept. Every row in a table represents an entity (i.e., an instance of a table type), and each entity must be uniquely identifiable. In other words, no two rows can have the same exact set of values. From this property of entity uniqueness comes the principle that in every table there exists a set of columns whose values are never duplicated and can therefore be used as the table's primary key. More than one possible set of columns may always contain unique values - each of these sets is referred to as a candidate primary key and one is usually picked randomly.
A primary key is a minimal set of columns whose values uniquely identify a row in a table. The primary key is the only way to identify a specific row in a specific table. A consequence of the primary key description is that a primary key can never ever contain NULL. A similar argument holds for composite primary keys (keys consisting of two or more columns) - columns that are part of a primary key can never every contain NULL.
3. Referential Integrity
Simply stated, referential integrity requires that rows that exist in separate tables but are inter-related, be unambiguously interrelated by corresponding column values.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment