Presentation is loading. Please wait.

Presentation is loading. Please wait.

Databases : Design of Relational Database Schemas 2007, Fall Pusan National University Ki-Joune Li.

Similar presentations


Presentation on theme: "Databases : Design of Relational Database Schemas 2007, Fall Pusan National University Ki-Joune Li."— Presentation transcript:

1 Databases : Design of Relational Database Schemas 2007, Fall Pusan National University Ki-Joune Li

2 STEMPNU 2 Bad Design: Anomalies Bad Design: Example Redundancy Update Anomaly Deletion Anomaly TitleYearLengthFilm TypeStudioNameStarName Star Wars1977124ColorFoxCarrie Fisher Star Wars1977124ColorFoxMark Hamill Star Wars1977124ColorFoxHarrison Ford Mighty Ducks1991104ColorDisneyEmilio Estevez Wayne’s World199295ColorParamountDana Carvey Wayne’s World199295ColorParamountMike Meyers

3 STEMPNU 3 Decomposing Relations Decomposition of Bad Relation  A good way to remove the problem of bad relations Decomposition: Lossless Decomposition  { A 1 A 2 … A n }  { B 1 B 2 … B m }, {C 1 C 2 … C k } such that { B 1 B 2 … B m }  {C 1 C 2 … C k } = { A 1 A 2 … A n } and { B 1 B 2 … B m }  {C 1 C 2 … C k }  {}

4 STEMPNU 4 Decomposing Relations: Example R={title, year, length, filmType, studioName, starName}  {title, year, length, filmType, studioName} (=R1), {title, year, starName} (=R2) Redundancy Update Anomaly Deletion Anomaly TitleYearLengthFilm TypeStudioName Star Wars1977124ColorFox Mighty Ducks1991104ColorDisney Wayne’s World199295ColorParamount TitleYearStarName Star Wars1977Carrie Fisher Star Wars1977Mark Hamill Star Wars1977Harrison Ford Mighty Ducks1991Emilio Estevez Wayne’s World1992Dana Carvey Wayne’s World1992Mike Meyers

5 STEMPNU 5 Normal Form: Conditions for Good Relation 1 st Normal Form (1NF) 2 nd Normal Form (2NF) 3 rd Normal Form (3NF) Boyce-Codd Normal Form (BCNF)

6 STEMPNU 6 1 st Normal Form 1NF: Every component of relation should be ATOMIC  No Table in component  No Set  No List etc..

7 STEMPNU 7 2 nd Normal Form 2NF  1NF and  None of the non-prime attributes of the relation is FD on a part of a candidate key Partial Dependency on non-prime attribute Example  Player (Team, Number, TeamAddress, Name, Position)  1NF but not 2NF B CA

8 STEMPNU 8 Example EmployeeSkillCurrent Work Location JonesTyping114 Main Street JonesShorthand114 Main Street JonesWhittling114 Main Street RobertsLight Cleaning73 Industrial Way EllisAlchemy73 Industrial Way EllisJuggling73 Industrial Way HarrisonLight Cleaning73 Industrial Way Candidate Key: {Employee, Skill} Not 2ND  Partial FD: Employee  Current Work Location  Should be decomposed (Employee, Skill), (Employee, Current Work Location)

9 STEMPNU 9 3 rd Normal Form 2NF: Every non-prime attributes of the relation must be non-transitively dependent on every candidate key Example  Team (TeamName, Address, Manager SS ID, ManagerHireDate)  2NF but Not 3NF: TeamName  Manager SS ID  ManagerHireDate  To be decomposed (TeamName, Address, ManagerID), (Manager SS ID, ManagerHireDate) B CA

10 STEMPNU 10 Example: 2NF but NOT 3NF TournamentYearWinnerWinner Date of Birth Indiana Invitational1998Al Fredrickson21 July 1975 Cleveland Open1999Bob Albertson28 September 1968 Des Moines Masters1999Al Fredrickson21 July 1975 Indiana Invitational1999Chip Masterson14 March 1977 Candidate Key: {Tournament, Year} 2NF: No Partial Dependency Not 3ND  Transitive Functional Dependency  {Tournament, Year}  Winner  Winner Date of Birth  Should be decomposed (Tournament, Year, Winner), (Player, Birth date}

11 STEMPNU 11 Boyce-Codd Normal Form (BCNF) BCNF: For every one of its non-trivial functional dependencies X  Y, X is a super key  Remember: nontrivial means A is not a member of set X.  Remember, a superkey is any superset of a key (not necessarily a proper superset) BCNF is slightly stronger than 3NF

12 STEMPNU 12 1NF 2NF 3NF Relationship between 1NF, 2NF, 3NF and BCNF BCNF

13 STEMPNU 13 Example: 3NF but NOT BCNF Prof. IDProf. SS IDStudent ID 1078088-51-007431850 1078088-51-007437921 1293096-77-414646224 1480072-21-222331850 A table to show the assignment of students Candidate Keys  {Prof. ID, Student ID}  {Prof. SS ID, Student ID} 1NF 2NF: no partial FD on non-prime attributes on candidate key 3NF: No transitive FD NOT BCNF:  Prof. ID  Prof. SS ID : Functional Dependency but not candidate key  Should be decomposed (Prof. ID, Student ID), (Prof. ID, Prof. SS ID)


Download ppt "Databases : Design of Relational Database Schemas 2007, Fall Pusan National University Ki-Joune Li."

Similar presentations


Ads by Google