Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views8 pages

DBMS Assignment 3

The document outlines a DBMS assignment involving normalization of relations, identifying candidate keys, and checking normal forms. It details the steps for determining candidate keys, decomposing relations into 2NF and 3NF, and checking for BCNF violations with examples. The final answers include the identification of candidate keys and the necessary decompositions to achieve the desired normal forms.

Uploaded by

Harsh Sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views8 pages

DBMS Assignment 3

The document outlines a DBMS assignment involving normalization of relations, identifying candidate keys, and checking normal forms. It details the steps for determining candidate keys, decomposing relations into 2NF and 3NF, and checking for BCNF violations with examples. The final answers include the identification of candidate keys and the necessary decompositions to achieve the desired normal forms.

Uploaded by

Harsh Sri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

🌻

DBMS Assignment 3
Ans1:
Step 1: Find Candidate Key(s)
Let’s compute closures of attributes:

1. A⁺ = {A, B, C, D} (since A → B, AB → C, C → D)
Therefore, A is a candidate key.

Hence, the candidate key is:


Candidate Key = {A}

Step 2: Identify Prime and Non-Prime Attributes


Prime attribute: A (since it is part of candidate key)

Non-prime attributes: B, C, D

Step 3: Check Normal Forms

1NF (First Normal Form):


All attribute values are atomic.
✅ Therefore, R is in 1NF.

DBMS Assignment 3 1
2NF (Second Normal Form):
Since the candidate key is a single attribute (A), there
are no partial dependencies.
✅ Therefore, R is in 2NF.
3NF (Third Normal Form):
For 3NF, for every functional dependency X → Y, one of the
following must hold:

1. X is a superkey, or

2. Y is a prime attribute.

Let’s check the functional dependencies:

AB → C: AB is a superkey (since A is a candidate key), so


this satisfies 3NF.

A → B: A is a candidate key, so this satisfies 3NF.

C → D: C is not a superkey, and D is a non-prime attribute.


❌ Hence, this violates 3NF.
Therefore, R is not in 3NF.

BCNF (Boyce-Codd Normal Form):


For BCNF, for every functional dependency X → Y, X must be a
superkey.

C → D violates BCNF as C is not a superkey.


❌ Hence, R is not in BCNF.
Final Answer:
The highest normal form for the given relation R is:

2NF

Ans 2:
Given:

DBMS Assignment 3 2
Relation: Book(BookID, AuthorID, AuthorName, BookTitle, Price)
Candidate Key: (BookID, AuthorID)

Step 1: Identify Partial Dependencies


A partial dependency exists when a non-prime attribute is
dependent on a part of the composite key. Let's check the
dependencies:

BookID → BookTitle, Price (BookTitle and Price depend only


on BookID)

AuthorID → AuthorName (AuthorName depends only on AuthorID)

Hence, partial dependencies exist in the relation.

Step 2: Decompose into 2NF


To remove partial dependencies and achieve 2NF, we decompose
the relation into the following:

Decomposed Relations:
1️⃣ R1(BookID, BookTitle, Price)
(Attributes dependent on BookID)

2️⃣ R2(AuthorID, AuthorName)


(Attributes dependent on AuthorID)

3️⃣ R3(BookID, AuthorID)


(To maintain the relationship between books and authors)

Final Relations in 2NF:


R1(BookID, BookTitle, Price)

R2(AuthorID, AuthorName)

R3(BookID, AuthorID)

Ans 3:
1️⃣ Primary Key Identification
DBMS Assignment 3 3
The table has the following functional dependencies:

EmployeeID → EmployeeName

ProjectID → ProjectName

EmployeeID, ProjectID → HoursWorked

From the above dependencies, the minimal set of attributes


that determines all other attributes is (EmployeeID,
ProjectID).

Hence, the Primary Key is:

👉 (EmployeeID, ProjectID)
2️⃣ Normalization Check and Decomposition
✅ 1NF Check:
The table is in 1NF because it has atomic attributes and no
repeating groups.

✅ 2NF Check:
The table is not in 2NF because there are partial
dependencies:

EmployeeID → EmployeeName

ProjectID → ProjectName
These attributes are dependent on only part of the
composite key.

✅ 3NF Check:
Since the table is not in 2NF, it is also not in 3NF.

3️⃣ Normalization to 3NF


To normalize to 3NF, decompose the table into:

1️⃣ Employee(EmployeeID, EmployeeName)


2️⃣ Project(ProjectID, ProjectName)
3️⃣ EmployeeProject(EmployeeID, ProjectID, HoursWorked)
This eliminates partial dependencies and ensures the table is
in 3NF.

DBMS Assignment 3 4
Final Tables in 3NF:

Employee Project EmployeeProject

EmployeeID, ProjectID, EmployeeID, ProjectID,


EmployeeName ProjectName HoursWorked

Ans 4:
To find candidate keys, we need to find minimal sets of
attributes whose closure includes all attributes (ABCDEFGH).

1. Start with the closure of each attribute and combinations:

{F}+ = F → EG → A → BC → CFH → ABCEFGH (only missing D)

So F alone is not sufficient, need to add D

2. Check {DF}+:

DF → F → EG → A → BC → CFH → ABCDEFGH (all attributes)

DF is a candidate key

3. Check for other minimal combinations:

{EF}+ = EF → A → BC → CFH → G → ABCEFGH (missing D)

{EFD}+ would work but is not minimal since DF already


works

{BF}+ = BF → CFH → G → EG → A → BC → ABCEFGH (missing D)

{BDF}+ would work but again not minimal

1. Other potential candidate keys:

{AF}+ = AF → BC → CFH → G → EG → ABCEFGH (missing D)

{ADF}+ would work but not minimal

{HF}+ = HF → (no direct FDs) → need more attributes

After checking various combinations, the only minimal


candidate key appears to be {DF}.
Final Answer: The relation R has 1 candidate key, which is
DF.

DBMS Assignment 3 5
Ans 5:
1. Find the closure of {AB}:

AB → C → D → E → A

So {AB}+ = ABCDE (all attributes)

AB is a candidate key

2. Check if any subset of AB is a candidate key:

{A}+ = A (no FD with just A on left)

{B}+ = B

Neither A nor B alone is a candidate key

3. Check other potential candidate keys:

{EB}+:

EB → A (from E→A) → AB → C → D → E

{EB}+ = ABCDE

EB is another candidate key

4. Check for other combinations:

{CB}+:

CB → D (from C→D) → E → A

{CB}+ = ABCDE

CB is another candidate key

{DB}+:

DB → E → A → (but no way to get C without AB→C)

{DB}+ = ABDE (missing C)

Not a candidate key

Final Answer: The candidate keys are AB, EB, and CB.

Part 2: Check if R is in BCNF and decompose if


not

DBMS Assignment 3 6
Solution:
A relation is in BCNF if for every non-trivial FD X → Y, X
is a superkey.

Check each FD:

1. AB → C: AB is a candidate key (superkey) - OK

2. C → D: C is not a superkey (C+ = CDEA ≠ ABCDE) -


Violation

3. D → E: D is not a superkey (D+ = DEA ≠ ABCDE) -


Violation

4. E → A: E is not a superkey (E+ = EA ≠ ABCDE) - Violation

Since multiple FDs violate BCNF, we need to decompose.

Decomposition Steps:

1. Pick the first violating FD: C → D

Create R1 = {C,D} with FD C → D

Create R2 = {A,B,C,E} with remaining FDs (but need


to project them)

Original FDs in R2: AB → C, E → A

C → D is handled in R1

D → E is not applicable (D not in R2)

E → A remains

2. Check R2 for BCNF:

AB → C: AB is a superkey in R2 (AB+ = ABCE)

E → A: E is not a superkey in R2 (E+ = EA)

Need to decompose further using E → A

3. Decompose R2:

R21 = {E,A} with FD E → A

R22 = {B,C,E} with FD (projecting AB → C gives no


non-trivial FDs)

DBMS Assignment 3 7
Actually, in R22 we have BE → C (since AB → C in
original and A is determined by E)

Need to check if BE is a superkey in R22: BE+ =


BEC (all attributes in R22)

So BE → C is OK for BCNF

Final decomposition:

R1(C,D) with C → D

R21(E,A) with E → A

R22(B,C,E) with BE → C

Final Answer:

1. R is not in BCNF because of the FDs C → D, D → E, and E → A


where the left sides are not superkeys.

2. Decomposition into BCNF:

R1(C, D) with FD: C → D

R2(E, A) with FD: E → A

R3(B, C, E) with FD: BE → C

DBMS Assignment 3 8

You might also like