Escolar Documentos
Profissional Documentos
Cultura Documentos
By Kristina Miguel
Review
Superkey a set of attributes which will uniquely identify each tuple in a relation Candidate key a minimal superkey Primary key a chosen candidate key Secondary key all the rest of candidate keys Prime attribute an attribute that is a part of a candidate key (key column) Non-prime attribute a non-key column
Review (cont.)
1NF
Make a separate table for each set of related attributes, and give each table a primary key.
2NF
Each attribute must be functionally dependent on the primary key. If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF
If attributes do not contribute to a description of the key, remove them to a separate table. Any transitive dependencies are moved into a smaller table.
BCNF
If there are non-trivial dependencies between candidate key attributes, separate them out into distinct tables.
All normal forms are additive, in that if a model is in 3NF, it is by definition also in 2NF and 1NF.
A MVD XY,
Holds
for some relation R, so that when you fix the values for one set of attributes, then the values in certain other attributes are independent of the values of all the other attributes in the relation. Is an assertion that two attributes or sets of attributes are independent of one another. For each value of X, the values of Y are independent of the values of R-X-Y.
MVD (cont.)
each pair of tuples t and u of relation R that agree on all the As, we can find in R some tuple v that agrees
both t and u on the As, With t on the Bs, and With u on all attributes of R that are not among the As or Bs.
With
MVD (cont.)
Representation of XY
X equal
others
exchange
MVD Example
Drinkers(name, addr, phones, beersLiked) A drinkers phones are independent of the beers they like.
namephones
and namebeersLiked.
Thus, each of a drinkers phones appears with each of the beers they like in all combinations.
we have tuples:
phones beersLiked p1 b1 p2 b2 p2 b1 p1 b2
4NF
Definition
A
relation R is in 4NF if and only if, for every one of its non-trivial multivalued dependencies XY, X is a superkeythat is, X is either a candidate key or a superset thereof.
1. 2.
Nontrivial MVD means that: Y is not a subset of X, and X and Y are not, together, all the attributes.
If XY is a 4NF violation for relation R, we can decompose R using the same technique as for BCNF.
1.
2.
Find a 4NF violation in R, say AB, where A is not a superkey. If there is such a 4NF violation, break the schema for the relation R that has the 4NF violation into two schemas.
1.
2.
R1, whose schema is As and Bs. R2, whose schema is the As and all attributes of R that are not among the As or Bs.
Find the FDs and MVDs that hold in R1 and R2. Recursively decompose R1 and R2 with respect to their projected dependencies.
1.
In 4NF; only dependency is nameaddr. Not in 4NF. MVDs namephones and namebeersLiked apply. No FDs, so all three attributes form the key.
2.
Decompose Drinkers2
Either
MVD name ->-> phones or name ->-> beersLiked tells us to decompose to:
Drinkers3(name,
Summary
A multivalued dependency is a statement that two sets of attributes in a relation have sets of values that appear in all possible combinations. If a relation is in 4NF, then every nontrivial MVD is really an FD with a superkey on the left.
References