Monday, July 22, 2013

DW - Normalization

Answers collected from the below site.Please refer to the site for details. database-normalization

Normalization of Database (eliminate data duplication & maintain data integrity)
1NF: student(s_id,s_name) subject(subject_id,student_id,subject)
Each column have a unique value.
Each row of data have a unique identifier i.e. Primary key.
Table:Student , Subject (sid,sname,subject - sname repeats in rows)
2NF: All 1NF + if table has concatenated primary key ( no partial dependency
of any column on primary key.) ( if any column depends on one part of  concatenated key then table fails 2NF)
Customer(cust_id,cust_name,ord_id,ord_name,sale_det)
PK:(cust_id+ord_id)
cust_name ( depends on only customer_id:FAILURE)
ord_name   ( depends on only ord_id:FAILURE)
Customer(cust_id,cust_name)  Order_Detail( ord_id, ord_name)
Sales(cust_id,ord_id,sale_det)
3NF: move the transitive functional dependency to another table.non-prime attribute must depend on primary key.
Student(stud_id,stud_name,dob,zip(street,city,state - transitive) -move to)
Student(stud_id,stud_name,dob,zip)  Address(Zip,Street,city,state)
BCNF:higher version of 3 NF does not have multiple candidate keys.

SQL SERVER – Difference Between Candidate Keys and Primary Key
Primary key: not null & uniquely defines the row              Candidate Key: can be null, unique

No comments:

Post a Comment