Test 2 Study Guide Flashcards
(34 cards)
Define “relation”.
A relation is a named, two-dimensional table of data.
What are the requirements for a table to qualify as a relation?
It must have a unique name.
Every attribute value must be atomic (not multivalued).
Every row must be unique.
Attribute columns must have unique names.
The order of the rows and columns must be irrelevant.
What do relations correspond to in the E-R model?
Relations correspond with entity types and with M:N relationship types.
What do rows correspond to in the E-R model?
Rows correspond with entity instances and with M:N relationship instances.
What do columns correspond to in the E-R model?
Columns correspond with attributes.
How are primary keys notated in a relational schema?
Primary keys are underlined with a solid line.
How are foreign keys notated in a relational schema?
Foreign keys are underlines with a dotted line.
Define “domain constraint”.
A domain constraint is a way to limit what data values can be placed in an attribute (such as integers, max digits, etc).
Define “entity integrity”.
Entity integrity is when no primary key attributes are allowed to be null, and all primary key fields have data.
Define “referential integrity constraint”.
Referential integrity constraint is where any foreign key value (on the “many” side) must match a primary key value on in the relation of the “1” side.
When converting from an ERD to a relational schema, what happens to composite attributes?
Composite attributes are split into their individual component attributes.
When converting from an ERD to a relational schema, what happens to multivalued attributes?
Multivalued attributes are split off into their own relation with a foreign key relating back to the superior entity.
When converting from an ERD to a relational schema, what happens to weak entities?
Weak entities are broken off into a separate relation, with a foreign key taken from the strong entity. The primary key of this relation is a partial identifier of the weak entity, and the primary key of the strong entity.
When converting from an ERD to a relational schema, what happens to a 1:M relationship?
The primary key on the 1 side of the relationship becomes a foreign key on the many side.
When converting from an ERD to a relational schema, what happens to a M:N relationship?
A new relation is created with a primary key made of the primary keys of each side. These do not act as foreign keys.
When converting from an ERD to a relational schema, what happens to a 1:1 relationship?
The primary key on the mandatory side becomes a foreign key of the optional side.
When converting from an ERD to a relational schema, what happens to an associative entity?
If the identifier of the associative entity isn’t assigned, then it defaults to the a composite primary key made of the primary keys of the two entities. Otherwise, the primary keys of the two many entities become foreign keys.
When converting from an ERD to a relational schema, what happens to a unary relationship?
A 1:M unary relationship becomes a recursive foreign key in the same relation (so, two EMP_IDs, although with different names).
A M:N unary relationship becomes two relations, one for the entity type, and one for an associative relation, in which the primary key has two attributes, one taken from the primary key of the entity, the other created for the relation. So, if you have an item that can have multiple components (also items), it would be broken into two relations, ITEM and COMPONENT. Component would have its primary keys set as Item_No and Component_No.
When converting from an ERD to a relational schema, what happens to ternary and N-ary relationships?
Ternary and N-ary relationships have a relation created for each entity, and one for the associative entity. The associative entity has a foreign key to each entity in the relationship.
When converting from an ERD to a relational schema, what happens to supertype/subtype relationships?
The supertype is converted to a relation, and so is each subtype, each keeping their respective attributes. Each subtype inherits its parent’s primary key, with the determinator character prepended to it.
Define “data normalization”.
Data normalization is the process of decomposing relations with anomalies to produce smaller, well-structured relations. It’s a tool to validate and improve logical designs, so that they avoid unnecessary data duplications.
What are the three types of data anomalies?
There are three types of data anomalies:
Insertion anomalies: Adding new rows forces the user to create duplicate data.
Deletion anomalies: Deleting rows may cause a loss of data that would be needed for other future rows.
Modification anomalies: Changing data in a row forces changes in other rows due to duplication.
What is the “rule of thumb” for good normalization?
The general rule of thumb is that a table should never pertain to more than one entity type.
What is functional dependency?
Functional dependency is when the value of one attribute (also called the determinant) determines the value of another.