You are on page 1of 6

DATA STRUCTURES AND ALGORITHMS

Assignment # 1

Submitted by: Muhammad AHSAN SHAFIQUE


Roll#: F20BDOCS2M01134
Class: MCS (M) 2nd Semester
Section: A
Submitted to: Mam Hira Awais
Submission Date: 21/05/2021
DATA STRUCTURES AND ALGORITHMS

Un_Normalized Form (UNF) :


Doc Name Address Phone Department Id Patient no Patient CNIC Phone Room
no. Name No

D1 Dr.Nadeem AB123 0333-123, Neurology P1 Khalid 1234-1 041-1 R1


062-123

P2 Ahmed 1234-2 041-2 R2

D2 Dr.Erum BK13 0321-123 Orthopedic P3 Mehmood 1234-3 041-3 R3

P4 Khawar 12345-4 041-4

P5 Anum 12345-5 041-5 R4

D3 Dr.Hafeez ND123 0321-124 Skin P6 Ali 12345-6 041-6 R5

P7 Sohail 12345-7 041-7 R6

 First of all in UNF the relative data is placed in one Table in RDBMS.
 In UNF there could repeating groups or multi-valued attributes i.e the attributes having more than
a single value.
DATA STRUCTURES AND ALGORITHMS

1st Normal Form (1NF) :


Doc Name Address Phone Department Patient Patient CNIC Phone Room
no. Id no Name No

D1 Dr.Nadeem ABC123 0333-123 Neurology P1 Khalid 1234-1 041-1 R1

D1 Dr.Nadeem ABC123 062-123 Neurology P1 Khalid 1234-1 041-1 R2

D1 Dr.Nadeem ABC123 0333-123 Neurology P2 Ahmed 1234-2 041-2 R2

D1 Dr.Nadeem ABC123 062-123 Neurology P2 Ahmed 1234-2 041-2 R2

D2 Dr.Erum BK123 0321-123 Orthopedic P3 Mehmood 1234-3 041-3 R3

D2 Dr.Erum BK123 0321-123 Orthopedic P4 Khawar 1234-4 041-4 R4

D2 Dr.Erum BK13 0321-123 Orthopedic P5 Anum 1234-5 041-5 R4

D3 Dr.Hafeez BK13 0321-124 Skin P6 Ali 1234-6 041-6 R5

D3 Dr.Hafeez BK13 0321-124 Skin P7 Sohail 1234-7 041-7 R6

 In 1NF we have to remove these multi-valued attributes.


DATA
 The data is said to be 1NF if each cell have a single value.
 For this purpose different values are assigned a single record.
DATA STRUCTURES AND ALGORITHMS

2nd Normal Form (2NF) :


Doc no. Name Address Phone Department

D1 Dr.Nadeem ABC123 0333-123 Neurology


DOCTOR
D1 Dr.Nadeem ABC123 062-123 Neurology
D2 Dr.Erum BK13 0321-124 Orthopedic

D3 Dr.Hafeez ND13 0321-124 Skin

Patient Patient CNIC Phone Room Doc


no Name No no.
P1 Khalid 1234-1 041-1 R1 D1
P2 Ahmed 1234-2 041-2 R2 D1
P3 Mehmood 1234-3 041-3 R3 D2
P4 Khawar 12345-4 041-4 R4 D2
Patient
P5 Anum 12345-5 041-5 R4 D2
P6 Ali 12345-6 041-6 R5 D3
P7 Sohail 12345-7 041-7 R6 D3

 For 2NF the data must be in 1NF.


 Because when data comes in 1NF there exists Partial Functional Dependency such that the only
single attribute is not enough to uniquely identify each record in the data hence more than one
attributes are involved for this purpose, which is called Composite Key.
 Now the non-key attributes depends on the part of the key-attributes, that’s called Partial
Dependency.
 Data is said to be in 2NF if these partial dependency has been removed.
DATA STRUCTURES AND ALGORITHMS

 For this purpose each part of primary is separated in a separate table along its Fully Dependent
Non-key attributes.
 After doing that data is in 2NF.

3rd Normal Form (3NF) :


Doc no. Name Address Phone
D1 Dr.Nadeem ABC123 0333-123 DOCTOR
D2 Dr.Erum BK13 0321-124
D3 Dr.Hafeez ND13 0321-124

Deprt Department Name Doc


_Id no.
1 Neurology D1 DEPARTMENT
2 Orthopedic D2
3 Skin D3

Patient no Patient Name CNIC Phone Doc no.


P1 Khalid 1234-1 041-1 D1
P2 Ahmed 1234-2 041-2 D1 Patient
P3 Mehmood 1234-3 041-3 D2
P4 Khawar 12345-4 041-4 D2
P5 Anum 12345-5 041-5 D2
P6 Ali 12345-6 041-6 D3
P7 Sohail 12345-7 041-7 D3

Room
DATA STRUCTURES AND ALGORITHMS

R_Id Room No Patient no


1 R1 P1
2 R2 P2
3 R2 P3
4 R4 P4
5 R4 P5
6 R5 P6
7 R6 P7

 For 3NF data must be in exceeded till 2NF.


 After 2NF there could be some Transitional Dependencies, such that a non-key attribute
from some non-key attribute could be determined by a key-attribute.
 For data being in 3NF we have to remove Transitional Dependencies.
 Once data is in 3NF, now it becomes more vivid for accessing purpose and easily
understandable as compared to its previous forms.

You might also like