Quiz 1 Flashcards
What makes a well-structured relation?
A relation that contains minimal redundancy and allows users to insert,
modify, and delete the rows in a table without errors or inconsistencies
Insertion anomalies
An insertion anomaly is the inability to add data to the database due to the absence of other data. Are experienced when we attempt to store a value for one attribute
but cannot because the value of another attribute is unknown
Deletion anomalies
A deletion anomaly occurs when you delete a record that may contain attributes that shouldn’t be deleted.
Are experienced when a value for one attribute we wish to keep is unexpectedly removed when a value for another attribute is deleted
Modification anomalies
A modification anomaly is an unexpected side effect from trying to insert, update, or delete a row.
Are experienced when changes to multiple instances of an entity (rows of a table) are needed to effect an update to a single value of an attribute
Normalization
The process of successively reducing relations with anomalies to produce smaller, well-structured relations.
What are the objectives of normalization?
To eliminate certain kinds of data redundancy and to avoid certain anomalies
Normal Form
A state of a relation that can be determined by applying simple rules regarding functional dependencies (or relationships between attributes). Are used to eliminate or reduce redundancy in database tables
A violation of NF is when…
two (or more) different entities are combined into a single entity
What are the two constraints required for 1NF
- There are no repeating groups in the relation. In other words, each
row/column intersection can contain one and only one value, rather
than a set of values. - A primary key has been defined, which uniquely identifies each row in the relation.
A table with repeating groups is converted to a relation in 1NF by
Extending the data in each column to fill the cells that are empty because of the repeating groups structures
Functional Dependency
A particular relationship between two attributes or two sets of attributes: The value of one attribute (the determinant) determines the value of other attributes
Determinant
Any attribute that you can use to determine the values assigned to other attribute(s) in the same row.
The attribute on the left-hand side of the arrow in a functional dependency
A primary key is always a ________, while a __________ may or may not be a primary key
Determinant
Give an example of a functional dependency
SSN -> NAME, ADDRESS, BIRTHDATE. A person’s name, address and birthdate are functionally dependent on that person’s social security number
True/False: Data in a relation prove that a functional dependency exists
FALSE. Only knowledge of the problem domain is a reliable method for identifying
a functional dependency
Identify the functional dependencies:
EMPLOYEE3 (EMP_ID, NAME, DEPT, SALARY, COURSE_ID, COURSE_NAME, DATE_ COMPLETED)
EMP_ID -> NAME, DEPT, SALARY
COURSE_ID ->COURSE_NAME
EMPID, COURSE_ID -> DATE_COMPLETED
Partial functional dependency
A functional dependency in which one or more nonkey (non-prime) attributes are functionally dependent on part (but not all) of the primary key
We check partial dependency if …
we have a composite primary key.
Partial dependencies create issues because….
Partial dependencies cannot be tolerated because a table that contains such dependencies is still subject to data redundancies and, therefore, to various anomalies
The requirements for 2NF are:
- The table is in 1NF
- It includes no partial dependencies; that is, no attribute is dependent on only a portion of the primary key
2NF a relation that is in 1NF in which every nonkey attribute is fully functionally dependent on the primary key
Convert this table from 1 NF to 2 NF
EMPLOYEE3 (EMP_ID, NAME, DEPT, SALARY, COURSE_ID, COURSE_NAME,
DATE_COMPLETED)
Write each key component on a separate line, and then write the original key on the last line.
Each component will become the key in a new table:
EMP_ID
COURSE_ID
EMP_ID, COURSE_ID
Write the dependent attributes after each new key.
We get three new tables:
EMPLOYEE (EMP_ID, NAME, DEPT, SALARY)
COURSE (COURSE_ID, COURSE_NAME)
EMPCOURSE (EMP_ID, COURSE_ID, DATE_COMPLETED)
A relation that is in 1NF will be in 2NF if any one of the following conditions applies
The primary key consists of only one attribute
No nonkey attributes exist in the relation (thus all of the attributes in the
relation are components of the primary key)
Every nonkey attribute is functionally dependent on the full set of primary key attributes