Download presentation

Presentation is loading. Please wait.

Published byFrank Portugal Modified over 3 years ago

1
Chapter Three Objectives Identification of Keys Application of primary and foreign keys Converting a database design to Relational DB. What is a good DBMS

2
2 Keys: (Constraints) A set of attributes whose values uniquely identify each entity in an entity set.

3
3 Keys: (Constraints) Primary key: A key selected by the Database Administrator Characteristics of primary key: a.Uniqueness: At any given time, no two tuples can have the same value for a given primary key Example :

4
4 Keys: (Constraints) b.Minimally: None of the attributes in primary key can be discarded without distorting the uniqueness property Example:

5
5 Keys: (Constraints) Foreign key: An attribute(s) in an entity set (relation) which is the primary key of other entity set (relation) Example: Department(Name, Dept_Id, ….) Faculty(Name, Id, Dept_Id,…)

6
6 Practice: Identify the primary keys and foreign keys in your video store project.

7
7 Normal Forms (Guidelines for RD design) How do we know this design is good? If it is not a good design, What should we do? Modify our design ??.

8
8 Normal Forms (Guidelines for RD design) First Normal Form (1NF) Deals with the shape of the records A relation is in 1NF if the values of domain is atomic for each attribute.

9
9 First Normal Form: 1NF Example: R (A, B, C, …) R ( A B )R ( AB ) a1b1, b2=>a1b1 a1b2

10
10 First Normal Form: 1NF Example: Person (NameAgeChildren) Smith42John, Lori, Mark Person (NameAgeChildren) Smith42John Smith42Lori Smith42Mark

11
11 First Normal Form: 1NF Example: Student (NameBirthday) S1Feb 2,91 S2March 8,88 Student (Name, D_Birth, M_Birth, Y_Birth) Note: 2NF and 3NF Deal with the relationship between non-key and key

12
12 Second Normal Form: 2NF A relation is in 2NF if it is in 1NF and every attribute is Fully dependent on the entire key in this relation. Fact: 2NF is violated when a non-key is a fact about a subset of a key

13
13 Second Normal Form: 2NF Example: R(A,B,C,D) D partially depends on A,B C fully depends on A,B A&B are prime (part of key) If A is primary key. Is this in 2NF? If A&B is primary key. Is this in 2NF? A, B ---> C, D A ---> D

14
14 Second Normal Form: 2NF What should we do with a relation which is not in 2NF? Example: R(A,B,C,D) A, B ---> C, D A ---> D R1 (A,B,C) R2(A,D)

15
15 Second Normal Form: 2NF Example: R(PartWarehouseAddressQuantity P1W1Frostburg25 P2W1Frostburg30 P3W2Cumberland32 P4W4Frostburg25 P4W1 What is the primary key? Part, Warehouse ---> Quantity Warehouse ---> Address

16
16 Second Normal Form: 2NF Problems: 1. Repetition of information: Changing the address W! 2. Unable to present information: Warehouse with no part So … R1 (Warehouse, Address) R2 (Part, Warehouse, Quantity)

17
17 Second Normal Form: 2NF Example: R(Professor,Student,Course,Degree) P1S1C1Ph.D. P2S2C2M.S. P3S2C4M.S. P4S3C4Pg.D. Professor ---> Course Student ---> Degree Professor ---> Student Key? Not in 2NF R1(Student, Degree) R2(Professor, Course, Student)

18
18 A relation is 3NF if it is in 2NF and every non-key attribute non transitively depends on the Primary Key. Example: R(A,B,C,D) A, B --->D D ---> C Fact: 3NF is violated when a non-key is a fact about another non-key Third Normal Form (3NF): R1(A,B,D) R2(D,C)

19
19 Third Normal Form (3NF): Example: R(Employee, Dept, Location) Employee ---> Dept Dept ---> Location EmployeeDeptLocation E1D1Frostburg E2D2Frostburg E3D3Frostburg Problems? R1(Employee, Dept) R2(Dept, Location)

20
20 Third Normal Form (3NF): Example: R(A,B,C,D) A,B ---> C A,C ---> D So A,B is the Primary Key Not in 3NF R1(A,B,C) R2(A,C,D)

21
21 Practice: Check the relations in your video project for 1NF, 2NF and 3NF. If they are not in normal forms, redesign your database model.

Similar presentations

Presentation is loading. Please wait....

OK

NORMALIZATION N. HARIKA (CSC).

NORMALIZATION N. HARIKA (CSC).

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google