Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Case of Normalisation

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

CGC-COE RDBMS II LAB

Experiment No. 2
Aim: Case Study of Normalisation.

Normal forms are use to decompose our table in such form which prevent our database
to suffer from various type of anomalies as we discussed before.

First normal form:- A relation is said to be in 1NF when its all relations are atomic
or simple. It should not be a set of value related to the attribute.

Branch Course Branch Course

ComputerSci DataStruc ComputerSci DataStruc

Biotech Biotech DataStruc

Elec DBMS Elec DBMS

Mech Mech DBMS

Table 1 Table 2

Here Atomicity is not present because we are having a group of value in courses
attribute which is related to branch. To make it in 1NF –

Now our Table is In 1NF.

__________________________________________________________________________

Second normal form:- Second normal form verifies when a relation is –

1: Is in 1NF. All its primary attributes are fully functional dependent on the key attribute
for making it in 2NF, Decompose table in two part, one is having key attribute and the
other attribute which already in functional dependency, Here (Employee Skill) –>
Current Works Location Employee –> Current works location (fails here).So, we make
two table which describe the above rule to decompose in 2NF.

3
CGC-COE RDBMS II LAB

Third Normal Form:- A relation is said to be in 3 normal form when –

1- It is in 2NF.
2- All non primary attribute have no transitive dependency on key attribute.

Games Roll Fee


Cricket 1 200
Tennis 2 300
Football 3 100
Cricket 4 200
Hockey 5 150

Here ROLL –> GAME –> FEE (Transitive dependency occurs)–> ROLL (So it is in 2NF)

Because of transitive dependency we will get: Insert anomaly, Deletion and Updation
anomaly as well.
1: Divide the table on the base of attributes where we are getting Transitive Dep.
2: In one relation put attribute which are fully functional dependent.

Games Roll
Cricket 1

Tennis 2

Football 3

Cricket 4

Hockey 5

Games Fee
Cricket 200

Tennis 300

Football 100

Hockey 150

4
CGC-COE RDBMS II LAB

Boyce Codd Normal Form:- A relation is said to be in BCNF when:

1: If every determinant is a candidate key.


2: It should be in 3NF.

(Determinant is attribute on which some other attribute is fully functionally dependant)

A BCNF relation is always be in 3NF but, 3NF relation will may be in BCNF.

Decomposition :-

1: Find the all functional Dependency.


2: Find all candidate key as determinant
3: Split in two relation 1 is containing the key attribute which is common in all the
candidate key, second will containing the attribute with not candidate key determinant.

____________________________________________________________________________

Fourth Normal Form:- A relation is said to be in 4NF when:

1: It is in BCNF.
2: There is no multivalued dependency in the relation.
MVD occurs when two or more independent multi valued attributes are about the same
attribute occur within same table. As R –> –> B.

Because of 4NF we are having delete and update anomalies.

EMPID LANG SKILLS


101 ENG TEACH
101 HIN CONVER
101 ENG CONVER
101 HIN TEACH
202 ENG SING
202 HIN CONVER

Here both the empid is having more than one skill or language known. so
EMPID –> –> LANG
EMPID –> –> SKILLS
So, if 101 stops teaching in hindi then we have to delete 1 more row ( eng, teach).
Make 2 relation to decompose the above relation in two part :-
1: EMP1 (EMPID,LANG)
2: EMP2 (EMPID,SKILLS)

5
CGC-COE RDBMS II LAB

EMPID LANG
101 ENG
101 HIN
202 ENG
202 HIN

EMPID SKILLS
101 TEACH
101 CONVER
202 SING
202 CONVER

Now Both the relations are in 4NF.

__________________________________________________________________

Fifth normal form (5nf):- A database is said to be in 5NF, if and only if,

 It's in 4NF
 If we can decompose table further to eliminate redundancy and anomaly, and
when we re-join the decomposed tables by means of candidate keys, we should
not be losing the original data or any new record set should not arise. In simple
words, joining two or more decomposed table should not lose records nor create
new records.

Consider an example of different Subjects taught by different lecturers and the lecturers
taking classes for different semesters.

AGENT_COMPANY_PRODUCT (Agent, Company, Product _Name)

This table lists agents, the companies they work for and the products they sell for those
companies. 'The agents do not necessarily sell all the products supplied by the
companies they do business with. An example of this table might be:

6
CGC-COE RDBMS II LAB

The table is necessary in order to show all the information required. Suneet , for
example, sells ABC's Nuts and Screws, but not ABC's Bolts. Raj is not an age it for CDE
and does not sell ABC's Nuts or Screws. Suppose that the table is decomposed into its
two projections, PI and P2.

You might also like