0% found this document useful (0 votes)
159 views

Assignment III

This document contains the solutions to two questions from an assignment on database systems. For question 1, the schema R is decomposed into fourth normal form using functional and multivalued dependencies. The decomposition involves finding the minimal cover of functional dependencies, decomposing into BCNF, and then further decomposing using the multivalued dependencies to achieve 4NF. For question 2, a trigger is written that removes courses from the OFFERINGS table if the enrollment for that course falls below 10 students after any insert, delete or update to the ENROLLMENT table.

Uploaded by

Deepesh Khaneja
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
159 views

Assignment III

This document contains the solutions to two questions from an assignment on database systems. For question 1, the schema R is decomposed into fourth normal form using functional and multivalued dependencies. The decomposition involves finding the minimal cover of functional dependencies, decomposing into BCNF, and then further decomposing using the multivalued dependencies to achieve 4NF. For question 2, a trigger is written that removes courses from the OFFERINGS table if the enrollment for that course falls below 10 students after any insert, delete or update to the ENROLLMENT table.

Uploaded by

Deepesh Khaneja
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment III

Integrated Database Systems SYSC5703F

Submitted By:
Deepesh Khaneja (101024610)
Ranjit Singh Saini
Rushabh Mahajan

Question 1
Consider the schema R over the attributes KNLMDFG with the following functional dependencies:
KN L
LM N
LMN D
DM
M FG
and the following multivalued dependencies:
MVD-1: R = NLK NDMFG
MVD-2: R = KNMF FLDG
Decompose this schema into 4NF using the following method:
i. First obtain a BCNF decomposition using the FDs only (i.e. minimal cover, 3NF, then BCNF)
ii. Then proceed to apply the MVDs to further normalize the schemas that are not yet in 4NF. List the 4NF
schemas.

Solution: Using the step 1 of method described above, Finding the minimal cover.
#1 Making the RHS FDs into singleton attributes which is
KN L
LM N
LMN D
DM
MF
MG
#2 Removing the extraneous attributes on LHS
On finding the closure of LM we get, (LM) + = LMNDMFG which can determine D without appending N.
Removing N from LHS, we get LM D.
There is no change in the rest of Functional Dependencies.
#3 Removing the redundant FDs from the schema by differentiating them as essential and redundant.
All the FDs are essential and none of them is entailed by R or any other attributes. No redundant FD.
Minimal Cover is {KN L, LM N, LM D, D M, M F, M G}
Decomposing the above minimal cover into 3NF by partitioning where LHS is same in Ri
R1 = {LMND, LM N, LM D}
R2 = {MFG, M F, M G}
R3 = {DM, D M}
R4 = {KLN, KN L}

Since there is no Ri which is a superkey of R, adding schema R0 = { KNLD, {} } guarantees Lossless


decomposition (as per step 4 from Notes of Normalization, synthesizing 3NF)

On checking the above decomposition satisfying BCNF, we can easily deduce that
R1 is not in BCNF due to the presence of D M entailed by the original set of FDs. Decomposing it further
into
R1a = {DM, D M}, R1b = {LND, {} }
Where R1a = R3
Rest all schemas satisfies BCNF.
Therefore, the resultant decomposition satisfying BCNF is
X1 = {LND, {}}
X2 = {DM, D M}
X3 = {MFG, M F, M G}
X4 = {KLN, KN L}
Now checking which of the schemas are not in 4NF due to the presence of MVD given above and
decomposing them further to satisfy conditions of 4NF.
X1 = R1b = LND is not in 4NF due to the presence of MVD1 NLK NDMFG.
Decomposing it into
R5 = {LN, {}}
R6 = {DN, {}}
Also, X3 = R2 = MFG is not in 4NF due to the presence of MVD2 KNMF FLDG
Decomposing it into
R7 = MF
R8 = FG

Rest all schemas are in 4NF.


So, the resultant 4NF decomposition has following attributes in their schemas
LN, DN, MF, FG, DM, KLN
Resultant Schemas are
U1 = {LN, {}}
U2 = {DN, {}}
U3 = {MF, M F}
U4 = {FG, {}}
U5 = {DM, D M}
U6 = {KLN, KN L}

Question 2
Consider the following schema:
OFFERINGS (Course, Semester)
ENROLLMENT (StudId, Course, Semester)
Write a statement level trigger, which removes courses from OFFERINGS for all those courses whose
enrollment falls below 10 students. Note that the trigger must happen after delete, insert, and update.
Solution
CREATE TRIGGER LOWENROL
AFTER DELETE, INSERT, UPDATE ON ENROLLMENT
FOR EACH STATEMENT
DELETE, INSERT, UPDATE
FOR EACH STATEMENT
DELETE FROM OFFERINGS
WHERE EXISTS
(SELECT E.COURSE, E.SEMESTER
FROM ENROLLMENT E
WHERE E.COURSE = COURSE AND E.SEMSTER = SEMESTER
GROUP BY E.COURSE , E.SEMESTER
HAVING COUNT(E.STUDID<10)

You might also like