Presentation is loading. Please wait.

Presentation is loading. Please wait.

Third Normal Form.

Similar presentations


Presentation on theme: "Third Normal Form."— Presentation transcript:

1 Third Normal Form

2 BCNF and Dependency Preservation
theater play Wharton Center Nutcracker Children's Theater R = {play, theater, city} FDs = { theater → city (each theater is in one city) play city → theater (only one theater is allowed to hold the play in each city) } Keys: {play, city} {theater, play} BCNF Decomposition: {theater, play} and {theater, city} Does the following data obey the functional dependencies? No! But you can only know with a join. theater city Wharton Center East Lansing Children's Theater

3 Third Normal Form Third normal form is more permissive than BCNF, and allows dependency preservation. A relation R is in third normal form (3NF) if: Whenever there is a nontrivial FD A1, A2, ..., An → B1, B2, ... Bn for R, Either: It is the case that {A1, A2, ..., An} is a superkey for R. or, all of the B's that aren't in A are a member of some key. The bolded part is what 3NF allows that BCNF doesn't.

4 3NF Decomposition Input: A relation R with a set of functional dependencies F. Output: A decomposition of R0 into a collection of relations, each of which is in 3NF. The decomposition has the lossless-join and dependency-preservation properties. Method: Perform the following steps Find a minimal basis for F, say G (the minimal basis are the FD's that don't imply each other) For each functional dependency (X → A) in G, use XA as the schema of one of the relations in the decomposition. If none of the relation schema from Step 2 is a superkey for R, add another relation whose schema is the key for R.

5 R = {A, B, C, D, E} FDs = {AB → C; C → B; A → D; AB → D} Step 1: Find minimal basis AB → D is implied by (A → D) so it is ignored Minimal basis is {AB → C; C → B; A → D} Step 2: Make schema from each FD (AB → C) becomes {ABC} (C → B) becomes {BC} # is a subset of other relations so can be ignored (A → D) becomes {AD} Result = {ABC} and {AD} Step 3: Make sure there's a superkey relation Neither {ABC} or {AD} is a superkey So add {ABE} (which is a key) Final result = {ABC} and {AD} and {ABE}

6 AnimeTraits ( name, hair_color, tsundere, eye_size) FDs =
Is decomposition into Hair(name, hair_color, eye_size) and Emotion(hair_color, tsundere) a valid (lossless join and dependency preserving) 3NF decomposition? 1. Yes 2. No, it isn't dependency preserving 3. No, the intersection isn't a superkey for a subrelation 4. No, the union of attributes isn't the original relation


Download ppt "Third Normal Form."

Similar presentations


Ads by Google