Normal Forms in Relational Database Management System

 

Normal Forms in Relational Database Management System:



TO watch YouTube Video ,

    




raw-data-:

name  , phone  city,  state

Ram,    919876543210 , 918987654327, Banaglore,                       KA

Dave,    919876543212 , 918987654328, Banaglore,                       KA

Ali,    919876543213 Jaipur,                            RJ

Milkha,    919876543219,  918987654329, Bathinda,                           PA




1st Normal Form -


1. each table cell contain a single value (atomic)

2. each record needs to be unique


eliminate the repetition



Solution:



name    ,  Phone ,    City,    State

Ram ,  919876543210,      Banaglore, KA

Ram ,  918987654327,      Banaglore, KA

Dave                ,  919876543212,        Banaglore, KA

Dave                ,  918987654328,        Banaglore, KA

Ali                     , 919876543213,     Jaipur, RJ

Milkha,                919876543219         Bathinda,           PA

Milkha,                918987654329         Bathinda,           PA




2nd  Normal Form ->


1,  Must Be in 1st Normal Form

2,  No non-prime attribute is dependent on the  proper subset of any candidate key of the table


TeacherId ,  Subject ,           SubjectId

111, Maths  ,          11

111,                Physics,          12

222,                Biology,  13

333,                Physics,          12

333,                Chemistry, 15


Candidate-Key = {TeacherId, SubjectId}


Non-Prime attribute = Subject


as the non-prime attribute Subject is dependent on SubjectId which is part (subset of the candidate key)

, hence its not in 2nd Normal Form.


   OR 

   

   There should not be partial dependency


Solution:


subject-detail table ,    

SubjectId  , Subject

11,   Maths

12,   Physics

13,   Biology

15,   Chemistry




subject-teacher table

SiubjectId , TeacherId

11, 111

12, 111

12, 333

13, 222

15, 333




3Rd Normal Form ->


1, Must be in 2nd Normal Form

2, Transitive functional dependency of any non prime attribute on any super key must be removed

                OR

there should not be any transitive dependency



EmpId , EmpName,  EmpZip, EmpState, EmpCity, EmpDistrict

--------------------------------------------------------

1001, John,   28005,  UP, Agra, D1

1002, Ajith,   22208,  TN,       Chennai, D2

1006,   Laura,    282007, TN,       Chennai, D3

1101,   Lilly,    292008, UK,       Massorie, D4

1201,   Ram,      22999,  HR,       Karnal,    D5

1203,   Sudha,   22999,  HR,       Karnal,     D5



Super Key = {EmpId}, {EmpId,EmpName}, {EmpId,EmpName,EmpZip}


Candidate-Key = EmpId


Non-Prime Attribute -  All attribute except EmpId


here EmpState, EmpCity, EmpDistrict transitively dependent on super key EmpId


Non-Prime Attribute (EmpState, EmpCity, EmpDistrict) are transitively dependent 

on super key which is EmpId, this violates the 3rd Normal Form.


EmpId->EmpZip->EmpState


Solution:


Emp Table

EmpId, EmpName

1001, John

1002, Ajith

...


Address Table

Empzip , EmpState, EmpId

28005, UP,         

...

22999, HR,        1201

22999, HR,   1203



For more Database concepts, Abinitio, AWS and data engineering videos please subscribe , view , like and share my YouTube channel 

Click DataPundit

Comments

Popular posts from this blog

Abinitio Interview Question # 1 - Write Multiple Files in Abinitio

Next In Sequence in ABinitio | How next_in_sequence() works in MFS