C4 DATABASE SYSTEM
Entity Integrity
Components of relational model
No primary key attribute may be null. All
Data structure
primary key fields MUST have data.
-Tables (relations), rows, columns
Referential Integrity
Data manipulation
rule states that any foreign key value must
-Powerful SQL operations for retrieving and match a primary key value
modifying data
Restrict
Data integrity
don’t allow delete of “parent” side if related
-Mechanisms for implementing business rules rows exist in “dependent” side
that maintain integrity of manipulated data
Cascade
relation
automatically delete “dependent” side rows
is a named, two-dimensional table of data. that correspond with the “parent” side row to
be deleted
rows (records)
Set-to-Null
columns (attribute or field).
set the foreign key in the dependent side to null
Key Fields if deleting from the parent side
Primary keys Transforming EER Diagrams into
Relations
are unique identifiers
Mapping Regular Entities to Relations
Foreign keys
Simple attributes
are identifiers that enable a dependent relation
E-R attributes map directly onto the relation
simple (a single field)
Composite attributes
composite (more than one field)
Use only their simple, component attributes
Multivalued Attribute
has more attributes
Mapping Weak Entities
Integrity Constraints Becomes a separate relation with a foreign key
Domain Constraints taken from the superior entity
Allowable values for an attribute
Primary key composed of: Supertype attributes
• Partial identifier of weak entity go into supertype relation
• Primary key of identifying relation
(strong entity) Subtype attributes
Mapping Binary Relationships primary key becomes primary key of subtype
relation
One-to-Many
Data Normalization
Primary key on the one side becomes a foreign
Primarily a tool to validate and improve a logical
key on the many side
design so that it satisfies certain constraints
Many-to-Many that avoid unnecessary duplication of data
Create a new relation with the primary keys of Well-Structured Relations
the two entities as its primary key
relation that contains minimal data redundancy
One-to-One
Goal is to avoid anomalies
Primary key on mandatory side becomes a
foreign key on optional side Insertion Anomaly–adding new rows
forces user to create duplicate data
Mapping Associative Entities
Deletion Anomaly–deleting rows may
Identifier Not Assigned cause a loss of data that would be
needed for other future rows
Default primary key for the association relation
is composed of the primary keys of the two Modification Anomaly–changing data
entities (as in M:N relationship) in a row forces changes to other rows
because of duplication
Identifier Assigned
Functional Dependency
It is natural and familiar to end-users
The value of one attribute
Mapping Unary Relationships
Candidate Key
One-to-Many
A unique identifier
Recursive foreign key in the same relation
First Normal Form
Many-to-Many–Two relations:
No multivalued attributes
One for an associative relation in which the
primary key has two attributes, both taken from Second Normal Form
the primary key of the entity
every non-key attribute is fully functionally
Mapping Supertype/Subtype Relationships dependent on the ENTIRE primary key
One relation for supertype and for each subtype Third Normal Form
no transitive dependencies
View Integration
Combining entities from multiple ER models
into common relations
Synonyms–two or more attributes with
different names but same meaning
Homonyms–attributes with same name
but different meanings
Transitive dependencies–even if
relations are in 3NF prior to merging,
they may not be after merging
Supertype/subtype relationships–may
be hidden prior to merging