Chapter 4 - Logical Database Design and the Relational Model Flashcards
Data structure ?
Table (relation), rows, columns
Data integrity ?
Mechanisms for implementing business rules that maintain integrity of manipulated data
What is a relation ?
A relation is a named, two dimensional table of data
Requirements for a table to qualify as a relation (6)
- Unique name
- Every attribute must be atomic (not multivalued, not composite)
- Every row must be unique (can’t have two rows with exactly the same values for all their fields)
- Attributes (columns) in tables must have unique names
- The order of the columns must be irrelevant.
- The order of the rows must be irrelevant.
Correspondence with E-R Model :
- Relations (tables) correspond with __ and with __.
- Rows correspond with __ and __.
- Columns correspond with __.
- Note: The word relation (in __) is not
the same as the word relationship (in __).
- Relations (tables) correspond with entity types and with many-to-many relationship types
- Rows correspond with entity instances and with many-to-many relationship instances.
- Columns correspond with attributes.
- Note: The word relation (in relational database) is not the same as the word relationship (in E-R model).
__ are unique identifiers of the relation.
Examples include employee numbers, social security
numbers, etc. This guarantees that __
Primary keys are unique identifiers of the relation.
Examples include employee numbers, social security
numbers, etc. This guarantees that all rows are unique.
__ are identifiers that enable a dependent
relation (on the __ of a relationship) to refer to its parent relation (on the __ of the relationship).
Foreign keys are identifiers that enable a dependent relation (on the many side of a relationship) to refer to its parent relation (on the one side of the relationship).
Keys can be _ (__) or __ (__).
Keys can be simple (a single field) or composite (more than one field).
Keys are usually used as __ to __ the response to user queries.
Keys are usually used as indexes to speed up the response to user queries.
Domain Constraints ?
Allowable values for an attribute (includes data types and restrictions on values)
Entity Integrity ?
No primary key attribute may be null. All primary key fields MUST contain data values.
Referential Integrity ?
Rules that maintain consistency between the rows of two related tables. rule states that any foreign key value (on the relation of the many side) MUST match a primary key value in the relation of the one side.(Or the foreign key can be null.)
Example of Referential Integrity ?
Delete Rules :
Restrict – don’t allow delete of “parent” side if related rows exist in “dependent” side
Cascade – automatically delete “dependent” side rows that correspond with the “parent” side row to be deleted
Set-to-Null – set the foreign key in the dependent side to null if deleting from the parent side → not allowed for weak entities
Mapping Regular Entities to Relations
– Simple attributes ?
– Composite attributes ?
– Multivalued attributes ?
Mapping Regular Entities to Relations
– Simple attributes: E-R attributes map directly onto the relation
– Composite attributes: Use only their simple,
component attributes
– Multivalued attributes: Become a separate relation
with a foreign key taken from the superior entity
Mapping Weak Entities
– Becomes a __ with a __ taken from the superior entity
– Primary key composed of ?
Mapping Weak Entities
– Becomes a separate relation with a foreign key taken from the superior entity
– Primary key composed of:
▪ Partial identifier of weak entity
▪ Primary key of identifying relation (strong entity)