Chapter 4 Flashcards
What is data structure?
Tables (relations), rows, columns
What is data manipulation?
Powerful SQL operations for retrieving and modifying data.
What is data integrity?
Mechanisms for implementing business rules that maintain integrity of manipulated data
What is a name, two-dimensional table of data?
A relation
What consists of rows (records) and columns (attribute or field)?
A table
What are the requirements for a table to qualify as a relation?
- Must have a unique name
- Every attribute value 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 irrelevent.
- The order of the rows must be irrelevent.
What must all relations be in?
1st Normal form
How do relations correspond with the E-R model?
- 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.
Are relation (in relational database) and relationship (in E-R model) the same?
No, they are not the same.
What are special fields that serve two main purposes (Primary and Foreign)?
Keys
What two main purposes do keys serve?
- Primary Key
- Foreign Key
What is a primary key?
Unique identifiers of the relation.
Example: Employee numbers, SSN etc.
This guarentees that all row are unique
What are Foreign keys?
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)
How are the fields in keys defined?
Simple (a single field) or composite (more than one field)
How are keys usually used?
As indexes to speed up the response to user queries.
Keys (Visual example)
What are domain constraints?
Allowable values for an attribute
Example: setting restrictions for what can be input for an attribute.Visual below
What does entity integrity mean?
- That no primary key attribute may be null. All primary key fields MUST contain data values.
What is referential integrity mean?
It refers to rules that maintain consistency between the rows of two related tables.
What are rules that state 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)?
Referential Integrity
What is an 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 correspon 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
Referential Integrity Constraints visualized
When transforming an ER diagram into a relation, how are simple attributes handled?
E-R attributes map directly onto the relation.
When transforming an ER diagram into a relation, how are composite attributes handled?
Use only their simple, component attributes
When transforming an ER diagram into a relation, how are multivalued attributes handled?
Becomes a seperate relation with a foreign key taken from the superior entity
How are weak entities mapped from an ER diagram into relations?
- They become a seperate 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)

How is a One-to-Many Binary relationship mapped when transforming ER diagrams into relations?
Primary key on the one side becomes a foreign key on the many side
How is a Many-to-Many Binary relationship mapped when transforming ER diagrams into relations?
Create a new relation with the primary keys of the two entities as its primary key
How is a one-to-one Binary relationship mapped when transforming ER diagrams into relations?
Primary key on mandatory side becomes a foreign key on optional side
How are associative entities mapped when transforming ERDs into relations?
If the Identifier is not assigned
Default primary key for the association relation is composed of the primary keys of the two entities (and in M:N relationship)
If the Identifer is assigned
It is natural and familiar to end-users
Default identifier may not be unique
Mapping an associative entity with identifer example
How is a Unary relationship mapped when transforming ERD into relations?
One-to-Many = Recursive foreign key in the same relation
Many-to-Many = Two relations:
- One for the entity type
- One for an associative relation in which the primary key has two attributes, both taken from the primary key of the entity
How are ternary (and n-ary) relationships mapped when transforming ERDs into relations?
- One relation for each entity and one for the associative entity
- The associative entity has foreign keys to each entity in the relationship
How are supertype/subtype relationships mapped when transforming ERDs into relations?
- One relation for supertype and for each subtype
- Supertype attributes (including identifier and subtype discriminator) go into supertype relation
- Subtype attributes go into each subtype; primary key of supertype relation also become primary key of subtype relation
- 1:1 relationship established between supertype and each subtype, with supertype as primary table
What is primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of data?
Data normalization
What is the process of decomposing relations with anomalies to produce smaller, well-structured relations?
Data normalization
What defines a well-structured relation?
A relation that contains minimal data redundancy and allows users to insert, delete, and update rows without causing data inconsistencies.
What is the goal of a well-structured relation?
To avoid anomalies
What are the different types of anomalies to be avoided?
Insertion Anomaly
Deletion Anomaly
Modification Anomaly
What type of anomaly occurs when adding new rows forces users to create duplicate data?
Insertion Anomaly
What type of anomaly occurs when deleting rows may cause a loss of data that would be needed for other future rows?
Deletion Anomaly
What type of anomaly occurs when changing data in a row forces changes to other rows because of duplication?
Modification Anomaly
Example table with anomalies
Steps of normalization visualized
What is it called when the value of one attribute (the determinant) determines the value of another attribute?
Functional dependency
What is a candidate key?
A unique identifier. One of the candidate keys will become the primary key.
For example: perhaps there is both credit card number and SS# in a table, in this case both are candidate keys
What are non-key fields functionally dependent on?
Every candidate key
What is First Normal Form?
- No multivalued attributes
- Every attribute value is atomic
- All relations are in 1st Normal Form
Example of what is and isn’t in 1st Normal Form
Further Anomalies Example
What is second normal form?
- 1NF PLUS every non-key attribute is fully funtionally dependent on the ENTIRE primar key.
- Every non-key attribute must be defined by the entire key, not by only part of the key
- No partial functional dependencies
What is third normal form?
2NF PLUS no transitive dependencies (functional dependencies on non-primary-key attributes)
*It’s called transitive, because the primary key is a determinant for another attribute, which in turn is a determinant for a third.
What is the solution to transition transitive dependencies to make something third normal form?
Non-key determinant with transitive dependencies go into a new table; non-key determinant becomes primary key in the new table and stays as foreign key in the old table.
What is it called when you combine entities from multiple ER models into common relations?
View integration
What are the issues to watch out for when merging entities from different ER models?
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