Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIS3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003,2004.

Similar presentations


Presentation on theme: "MIS3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003,2004."— Presentation transcript:

1 MIS3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003,2004. All Rights Reserved.

2 Review of Lecture 1 Learnt about integrity constraints - domain constraints - referential integrity - introduction to triggers Learnt about functional dependencies - Definition - Armstrong’s axioms - 3 additional rules - Closure of an attribute set (useful in computing super keys and candidate keys) -Practiced formulating FDs from a description

3 Goals for today Boyce-Codd Normal Form (BCNF) Algorithm for deriving a BCNF schema Design algorithm for designing a relational schema without ER diagrams In-class assignments

4 Before we get started A relational schema is a group of tables that make up the database, i.e., represent data about a real world enterprise. Our goal is to end up with a “good schema”in terms of a definition that we will see next. The methodology we learn today can be used AT the end of the ER Diagram ----> Relational schema methodology we learnt in module 1 of this course, to check and make sure our relational schema is in BCNF. The methodology we learn today can be used if we need to re-engineer a relational schema that already exists. Note that our aim is to simplify learning the theory so we can solve real-world problems.

5 Boyce-Codd Normal Form A table is in BCNF if, for all FDs on the table, the following holds: (Left Hand Side of FD) LHS is a superkey for the table In general, BCNF is considered a good design, in the real world. A schema is in BCNF if every table in the schema is in BCNF. We shall not do 3NF (Third Normal Form) because BCNF is more restrictive and guarantees no redundancy. So our aim is to learn how to create BCNF schemas. NB: 3NF is defined as: For every FD on a table, either LHS is a superkey or the RHS-LHS is a part of the candidate key. It is less restrictive than BCNF. We just need to focus on BCNF.

6 Algorithm for decomposing a big table into smaller tables that are in BCNF Inspect the list of FDs on the table and remove obvious duplications. For each FD make sure that LHS INTERSECT RHS = NULL. FOR each table T that is remaining that is not in BCNF DO Take an FD such that LHS is not a superkey (if we have a choice, select an FD whose RHS is not on LHS of some other FD first) Create a table with the attributes (LHS,RHS) and remove the RHS from table T.Primary key of new table is LHS. /*Note that the new table we have created is in BCNF*/ END

7 Algorithm for decomposing a table into BCNF Example: Course-Section-Classroom (c_id, c_name, num_credits, s_id, time_held, week_days_held, date_began, date_ended, cl_id, capacity, location) Decompose into BCNF tables.

8 Algorithm for decomposing a table into BCNF Example: Professors-Courses-Sections-Classrooms (f_id, f_name, f_address, f_specialty, highest_degree, c_id, c_name, num_credits, s_id, time_held, week_days_held, date_began, date_ended, cl_id, capacity, location) Decompose into BCNF tables.

9 Design algorithm for designing a relational schema without ER diagrams -List all the attributes into ONE BIG TABLE. -List all FDs and reduce them by inspection so that no information is represented twice. -Create a BCNF decomposition -Inspect our decomposed tables to make sure each is in BCNF -Inspect design to make sure it is dependency preserving. If not, use our judgement to combine tables so that the design is dependency preserving.

10 In class assignments 1. Big table (A, B, C, D, E, F, G, H, I, J, K) FDs = { A --> BCD, D--> EFG, I-->JK } Re-engineer this, so it is a “good design” (BCNF).

11 In class assignments 2. Al’s motor shop (AMS) is an automobile repair facility owned by the Capone family. AMS has 5 repair bays. Each repair bay (place where car is repaired) has a bay_id and bay_location. AMS employs 14 employees. Each employee has an employee_id, address, phone and salary. Of these 14, 2 are office staff. They are further described by typing_speed and degree_held. The 12 mechanics are further described by tech_level. Each mechanic is assigned to work on one bay. AMS customers have a cust_id, name, address, phone. In addition, Mr. Capone also wants to capture information for each customer that lists the mechanic who last did a job for the customer, the date on which the job was done, and the amount the customer paid to AMS. Please create a relational schema, in BCNF, without an ER diagram.


Download ppt "MIS3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 2 © Akhilesh Bajaj, 2000, 2002, 2003,2004."

Similar presentations


Ads by Google