db_assignment_of_normalization (2)
db_assignment_of_normalization (2)
Contents
1 Scenario 1: University Course Registration System 3
8 Final Outcome 7
1
9.4.3 Patient Table (Same as 2NF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
9.4.4 Treatment Table (Same as 2NF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
9.4.5 PatientTreatment Table (Same as 2NF) . . . . . . . . . . . . . . . . . . . . . . . . 10
2
1 Scenario 1: University Course Registration System
2 Unnormalized Form (UNF)
Student ID Student Name Course IDs Course Names Instructor IDs Instructor Names
S1 Alice C101, C102 DBMS, OOP I1, I2 Dr. Smith, Prof. Lee
S2 Bob C101 DBMS I1 Dr. Smith
3
4.5 Registration Table
Student ID Course ID
S1 C101
S1 C102
S2 C101
Course ID Instructor ID
C101 I1
C102 I2
4
Order ID Customer Customer Product IDs Product Categories Quanti Price
ID Name Names ty
Shipping
Address
O101 C001 Ali Khan P001, P002 Laptop, Electronics 1, 2 1000, 50
Mouse
Lahore
O102 C002 Sara Malik P003 T-Shirt Clothing 3 20
Karachi
O103 C001 Ali Khan P004, P005 Book, Pen Books 2, 1 15, 2
Lahore
Issues in UNF:
• Multiple products in a single order (Product IDs, Product Names, Categories, Quantity, and Price
contain multiple values in a single row).
Improvements in 1NF:
• Atomic values (each field contains a single value).
• Separate rows for each product in an order.
Issues in 1NF:
• Customer Name and Shipping Address depend only on Customer ID (not on the full composite
key).
• Product Name, Category, and Price depend only on Product ID (not on the full composite key).
Breaking into Separate Tables: Now, we divide data into three tables to remove partial depen-
dencies:
5
7.3.1 Customer Table (2NF-compliant)
Order ID Customer ID
O101 C001
O102 C002
O103 C001
Improvements in 2NF:
• Customer details stored separately, reducing redundancy.
6
7.4.3 Order Table (3NF)
Order ID Customer ID
O101 C001
O102 C002
O103 C001
Improvements in 3NF:
• No transitive dependencies.
• Category stored separately, reducing redundancy.
8 Final Outcome
Now, the database is in 3NF:
7
9 Hospital Patient Record Normalization
9.1 1. Unnormalized Form (UNF)
• Repeating Groups: A patient can have multiple treatments, leading to repeated pa-
tient and doctor information.
• Non-Atomic Fields: Although the fields themselves are generally atomic in this exam-
ple, the combination of multiple treatments per patient within the same rows leads
to logical non-atomicity.
• Data Redundancy: Patient and doctor details are repeated across multiple rows.
PatientID PatientName
101 Alice Smith
102 Bob Johnson
103 Carol Williams
8
9.3.2 Doctor Table
TreatmentID TreatmentName
T101 Angioplasty
T102 Medication
T201 Physiotherapy
T301 ECG
T302 Medication
T303 MRI
SpecializationID Specialization
S01 Cardiology
S02 Orthopedics
S03 Neurology
PatientID PatientName
101 Alice Smith
102 Bob Johnson
103 Carol Williams
9
9.4.4 Treatment Table (Same as 2NF)
TreatmentID TreatmentName
T101 Angioplasty
T102 Medication
T201 Physiotherapy
T301 ECG
T302 Medication
T303 MRI
• Repeating Groups: A member can borrow multiple books, leading to repeated mem-
ber information.
• Data Redundancy: Book and author details are repeated across multiple rows.
10
BookID BookTitle AuthorName Nationality MemberID MemberName LoanDate ReturnDate
B001 The Hobbit J.R.R. British M101 Alice John- 2023-10-26 2023-11-09
Tolkien son
B002 Pride and Jane British M102 Bob 2023-10-27 2023-11-10
Prejudice Austen Williams
B001 The Hobbit J.R.R. British M103 Carol 2023-10-28 2023-11-11
Tolkien Davis
B003 Dune Frank Her- American M101 Alice John- 2023-10-29 2023-11-12
bert son
B004 1984 George Or- British M102 Bob 2023-10-30 2023-11-13
well Williams
MemberID MemberName
M101 Alice Johnson
M102 Bob Williams
M103 Carol Davis
11
AuthorName Nationality
J.R.R. Tolkien British
Jane Austen British
Frank Herbert American
George Orwell British
MemberID MemberName
M101 Alice Johnson
M102 Bob Williams
M103 Carol Davis
• Repeating Groups: Employees can belong to multiple departments, leading to repeated employee
and salary information.
• Data Redundancy: Tax bracket and tax deduction information is repeated for each employee-
department combination.
• Transitive Dependency: Tax deduction depends on the tax bracket via tax rate and salary,
creating unnecessary dependencies.
12
11.2 2. First Normal Form (1NF)
To convert to 1NF, we need to ensure each field contains atomic values and eliminate repeating groups.
This means each row should represent a single employee-department combination.
EmployeeID Emp Name Dept ID Dept Name Salary TaxBracketID TaxRate TaxDeduction
E001 John Doe D101 Sales 60000 TB01 0.15 9000
E001 John Doe D102 Marketing 60000 TB01 0.15 9000
E002 Jane Smith D201 HR 75000 TB02 0.20 15000
E003 David Lee D101 Sales 50000 TB01 0.15 7500
E004 Emily D202 Finance 90000 TB03 0.25 22500
White
E004 Emily D102 Marketing 90000 TB03 0.25 22500
White
DepartmentID DepartmentName
D101 Sales
D102 Marketing
D201 HR
D202 Finance
EmployeeID DepartmentID
E001 D101
E001 D102
E002 D201
E003 D101
E004 D202
E004 D102
13
11.4 4. Third Normal Form (3NF)
To convert to 3NF, we need to eliminate transitive dependencies. In this case, TaxDeduction depends on
TaxBracketID through TaxRate and Salary. to fully remove this transitive dependency, the taxDeduction
should be calculated when needed, not stored. However, if we need to store it, we would use the following
tables.
TaxBracketID TaxRate
TB01 0.15
TB02 0.20
TB03 0.25
DepartmentID DepartmentName
D101 Sales
D102 Marketing
D201 HR
D202 Finance
EmployeeID DepartmentID
E001 D101
E001 D102
E002 D201
E003 D101
E004 D202
E004 D102
14