Database normalisation

589 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
589
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Database normalisation

  1. 1. Anu. S anusdhar4@gmail.com www.facebook.com/AnuSasidharan twitter.com/username in.linkedin.com/in/profilename DATABASE NORMALIZATION
  2. 2. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  3. 3. DATABASE NORMALIZATION LEVELS OF NORMALIZATION SOLVED EXAMPLE
  4. 4. DATABASE NORMALIZATION What is normalization???? Why normalize the database??? Strength and drawback of normalization..!!!
  5. 5. What is actually normalization??? The process of analyzing a given relational schema based on their functional dependencies and primary keys.
  6. 6. Why normalize database???? Minimizing redundancy Accuracy Performance
  7. 7. Strength And Drawback of Databases...!!!! Strength: Reduces Redundancy Reduces errors Drawback: No of tables increases Complexity increases
  8. 8. LEVELS OF NORMALIZATION 1NF 2NF 3NF BCNF 4NF 5NF DKNF Redundancy NumberofTables Complexity
  9. 9. FIRST NORMAL FORM-1NF A table is considered to be in 1NF if all the fields contain only scalar values Example (Not 1NF) Pk_Int_Book_id Vchr_bookname Vchr_author 111 Basic Electrical and Electronics Engineering Storey,Huggies,Tomasi 121 EVS Venugopal,Vinod
  10. 10. After performing 1NF Pk_int_book_id Vchr_Bookname Vchr_author 111 Basic Electrical and Electronics Engineering Storey 111 Basic Electrical and Electronics Engineering Huggies 111 Basic Electrical and Electronics Engineering Thomasi 121 EVS Vinod 121 EVS Venugopal
  11. 11. Second Normal Form For a table to be in 2NF, there are two requirements:  The database is in first normal form  All non_key attributes in the table must be functionally dependent on the entire primary key
  12. 12. Second Normal Form- Example Database not in 2NF: Pk_Vchr_Emp_name Pk_Vchr_emp_desig Int_Emp_Sal Vchr_emp_address Paul Manager 60000 121,PK street,Mumbai Ram Clerk 5000 111/114, Arumugam street, Chennai Primary key : {vchr_emp_name,vchr_emp_desig} Here the employee salary is dependant on both primary keys. Employee address is not dependant on employee designation. Hence it is not in 2NF
  13. 13. Second Normal Form- Example Database after performing 2NF: Pk_Vchr_Emp_n ame Pk_Vchr_emp_d esig Int_Emp_Sal Paul Manager 60000 Ram Clerk 5000 Pk_Vchr_Emp_name Vchr_Emp_address Paul 121,PK street,Mumbai Ram 111/114, Arumugam street, Chennai
  14. 14. THIRD NORMAL FORM For a table to be in 3NF, there are two requirements:  The table should be second normal form  No attribute is transitively dependent on the primary key All non key attributes of a table must be functionally dependent on a candidate key. There must be no interdependencies among non-key attributes
  15. 15. Third Normal Form- Example Database not in 3NF: Pk_int_stud_id Vchr_stud_name Int_class_id Vchr_class_name 3457 Ashish 101 CS5 4332 Abhay 121 EC6 Primary key : {pk_vchr_emp_name} Here Student name , and class_id depends on primary key pk_int_stud_id. The class name is but more dependant on the class_id (non-key) than stud_id. So there is a transitive dependency. Hence not in 3NF.
  16. 16. Third Normal Form- Example Database after performing 3NF: Pk_int_stud_id Vchr_stud_name Int_class_id 3457 Ashish 101 4332 Abhay 121 Pk_Int_class_id Vchr_class_name 101 CS5 121 EC6
  17. 17. AN EXAMPLE TO SOLVE Exam Management System ----------------------------------- Users: Admin Student Admin --------- Login View Profile Edit Profile Facility to manage student Facility to manage exam Student ---------- Attend exams View mark
  18. 18. Let us first list the required tables: Login_table User_table User_type_table Exam_table Exam_qstn_table Qstn_option_table Stud_answer_table SOLVING THE PROBLEM
  19. 19. Pk_int_login_id Vchr_username Vchr_password 1 Administrator Admin 2 Ashish Ashish123 3 Abhay abhay123 Login_table User_table Pk_int_ user_id Vchr_ uname Fk_int_ login_id Dat_dob Vchr_ place Bln_status int_user_ type 1 Pratap 1 1867-05-01 Calicut 1 1 2 Ashish 2 1993-02-01 Banglore 1 2 3 Abhay 3 1992-03-11 Chennai 1 2 Pk_int_ type_id Vchr_ utype 1 Admin 2 Student User_type_table
  20. 20. Pk_int_exam_id Vchr_exam_name int_exam_duration (in hrs) 101 Basic C programming Test 1 102 Cpp Evaluation test 1 Exam_table Exam_qstn_table Pk_int_qstn_id Fk_int_exam_id Vchr_question Vchr_answer Int_marks 1111 101 Code1 21 5 1112 101 Code2 11122133 10 1113 102 Code3 131 5 1114 102 Code4 3333 10
  21. 21. Question_option_table Pk_int_option_id Fk_int_qstn_id Vchr_option 1 1111 21 2 1111 22 3 1111 25 4 1112 11122133 5 1112 0 6 1112 11100000 7 1113 131 8 1113 100 9 1113 1 10 1114 3333 11 1114 0 12 1114 2222
  22. 22. Student_answer_table Pk_int_ answer_id Fk_int_qstn_id fk_int_user_id Vchr_stud_ answer Int_mark_ scored 116 1111 2 22 0 117 1112 2 11122133 10 118 1113 2 131 5 119 1114 2 3333 10 120 1111 3 21 5 121 1112 3 11122133 10 122 1113 3 131 5 123 1114 3 0 0
  23. 23. THANK YOU...
  24. 24. Want to learn more about programming or Looking to become a good programmer? Are you wasting time on searching so many contents online? Do you want to learn things quickly? Tired of spending huge amount of money to become a Software professional? Do an online course @ baabtra.com We put industry standards to practice. Our structured, activity based courses are so designed to make a quick, good software professional out of anybody who holds a passion for coding.
  25. 25. Follow us @ twitter.com/baabtra Like us @ facebook.com/baabtra Subscribe to us @ youtube.com/baabtra Become a follower @ slideshare.net/BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/baabtra Thanks in advance. www.baabtra.com | www.massbaab.com |www.baabte.com
  26. 26. Contact Us Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu, Kozhikode Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com

×