0% found this document useful (0 votes)
12 views42 pages

NPTEL DBMS 2 Week 4

The document is a tutorial on Database Management Systems, covering various topics such as functional dependencies, candidate keys, and normal forms through a series of questions and solutions. It includes relational schemas like CourseAssignments, FileRepo, GameRepo, and Fig, along with explanations for lossless decomposition and the identification of superkeys. The tutorial also addresses specific functional dependencies and their implications on candidate keys and normal forms.
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)
12 views42 pages

NPTEL DBMS 2 Week 4

The document is a tutorial on Database Management Systems, covering various topics such as functional dependencies, candidate keys, and normal forms through a series of questions and solutions. It includes relational schemas like CourseAssignments, FileRepo, GameRepo, and Fig, along with explanations for lossless decomposition and the identification of superkeys. The tutorial also addresses specific functional dependencies and their implications on candidate keys and normal forms.
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/ 42

NOC24-CS75

Data Base Management System


Tutorial by: Adwait P. Parsodkar
Week - 4
Question - 1
Consider the relational schema
CourseAssignments (AssignmentNo, QNo, Topic, Marks, QType)
with the following Functional Dependencies:
AssignmentNo → Topic
Topic → {Marks, AssignmentNo}
{Topic, QNo} → QType
Which of the following is not a prime attribute of CourseAssignments?
a) QNo b) Topic
c) QType d) AssignmentNo
Solution - 1
Solution: (c)

The candidate keys of CourseAssignments are {QNo, AssignmentNo} and {QNo, Topic}.
Prime attribute is an attribute that is part of any candidate key.
Question - 2
Consider the relational schemaFileRepo(RepoName, FileNo, IndexNo, AdminID,
FileCount) with the following functional dependencies:
RepoName→{AdminID, FileNo}
FileCount→{RepoName, IndexNo}
Which of the following decomposition of FileRepo is lossless?
a) FileRepo1(RepoName, FileNo), FileRepo2(IndexNo, AdminID, FileCount)
b) FileRepo1(RepoName, FileNo), FileRepo2(FileNo, AdminID, FileCount)
c) FileRepo1(RepoName, FileCount), FileRepo2(FileNo, IndexNo, AdminID, FileCount)
d) FileRepo1(RepoName, AdminID), FileRepo2(FileNo, IndexNo, AdminID, FileCount)
Solution - 2
Solution: (c)

Explanation: From the functional dependencies, the primary key of the schema can be
identified as FileCount. In option (c),

FileRepo1 ∩ FileRepo2={FileCount} and,

FileRepo1 ∪ FileRepo2={RepoName, FileNo, IndexNo, AdminID, FileCount}.

Hence, the decomposition given in option (c) is lossless.


Question - 3
Consider the relational schema CourseAssignments (AssignmentNo, QNo, Topic, Marks,
QType) with the following Functional Dependency set:

F={

QNo → {Topic, AssignmentNo}

Topic → {Marks, AssignmentNo}

{Topic, QNo} → QType

What is the canonical cover of F?


Question - 3
a) QNo → Topic c) QNo → Topic
Topic → Marks QNo → AssignmentNo
Topic → AssignmentNo Topic → AssignmentNo
QNo → QType QNo → QType
b) QNo → Topic d) QNo → Topic
QNo → AssignmentNo QNo → AssignmentNo
Topic → Marks Topic → Marks
Topic → AssignmentNo Topic → AssignmentNo
QNo → QType {Topic, QNo} → QType
Solution - 3
Solution: (a) QNo → {Topic, AssignmentNo}

Topic → {Marks, AssignmentNo}

{Topic, QNo} → QType

________________________________________________________________

QNo → Topic

Topic → Marks

Topic → AssignmentNo

QNo → QType
Solution - 3
Solution: (a)

In the FD {Topic, QNo} → QType, Topic is extraneous in L.H.S as QNo+ contains Topic
from QNo → {Topic, AssignmentNo}. Similarly, in QNo → {Topic, AssignmentNo},
AssignmentNo is extraneous as QNo+ contains AssignmentNo from F’={

QNo → {Topic}

Topic → {Marks, AssignmentNo}

{ QNo} → QType

}
Question - 4
Consider the relational schema GameRepo (GameName,GameType,Developer,PlayedBy)
with the following Functional Dependency

GameName,GameType → Developer

GameType → PlayedBy

Developer → GameName

Identify the possible number of superkeys of GameRepo.

a) 4 b) 6 c) 8 d) 10`
Solution - 4
Solution: (b)

Explanation: The candidate keys of GameRepo are {GameType, GameName},


{GameType, Developer}.

Superkeys: {GT, GN}, {GT, GN, P}, {GT, GN, D}, {GT, GN, D, P}

{GT, D}, {GT, D, GN}, {GT, D, P}, {GT, D, GN, P}


Question - 5
Consider the relation Fig(FNo,Page,Colored,Dimensions) with the following Functional
Dependencies:

FD1: FNo,Page → Colored

FD2: Colored → Dimensions

FD3: Dimensions → FNo

If Fig is decomposed into Fig1(FNo,Page,Colored) and Fig2(Colored,Dimensions), which

of the following options is (are) true?


Question - 5
a) The decomposition is both lossless and dependency preserving.

b) The decomposition is lossless but not dependency preserving.

c) The decomposition neither lossless nor dependency preserving.

d) The decomposition is not lossless but is dependency preserving.


Solution - 5
Solution: (b)

The decomposition is lossless because the common attribute is Colored, which is a key in
Fig2. The decomposition is not dependency preserving as Dimensions → FNo cannot be
preserved from the decomposition.
Question - 6
Consider the relational schema GameRepo (GameName,GameType,Developer,PlayedBy)
with the following Functional Dependency

GameName,GameType → Developer

GameType → PlayedBy

Developer → GameName

What is the highest Normal form of GameRepo?

a) 1NF b) 2NF c) 3NF d) BCNF


Solution - 6
Solution: (a)
Candidate keys: {GameType, GameName}, {GameType, Developer}
Prime Attributes: {GameType, GameName, Developer}
1NF: Yes
2NF: Proper subset of candidate key should not determine a non-prime attribute.
GameType → PlayedBy, a non-prime attribute is dependant on a proper subset of a
candidate key. Hence not in 2NF.
Question - 7
Consider the relation Fig(FNo,Page,Colored,Dimensions) with the following Functional
Dependencies:

FD1: FNo,Page → Colored

FD2: Colored → Dimensions

FD3: Dimensions → FNo

Identify the number of candidate keys and the highest normal form of Fig.
Solution - 7
Solution: Fig has 3 candidate keys and is in 3NF
Candidate keys: {Page, FNo},{Page, Colored}, {Page, Dimensions}
Prime attributes: {Page, FNo, Colored, Dimensions}
1NF: Yes
2NF: Since all attributes are prime, there is no non-prime attribute that is determined by a
proper subset of a candidate key.
3NF: Since all attributes are prime, the RHS will always be the part of some key.
BCNF: In FD2 and FD3, the LHS is not a super key.
Question - 8
Consider the instance of the relation Food (DishName, Price, Restaurant). Which of the
following Functional Dependencies hold true on Food as can be found in the given
instance?

a) {DishName, Price} → Restaurant

b) {Restaurant, Price} → DishName

c) {Restaurant, DishName} → Price

d) Restaurant → {Price, DishName}


Solution - 8
Solution: (b), (c)

Explanation: {DishName, Price} cannot identify Restaurant uniquely as {Samosa, 20}


relates to both Gupta Snacks and Roy Sweets. Similarly, Restaurant cannot identify any of
the other fields uniquely.
Question - 9
Consider the instance of the relation Food(DishName, Price, Restaurant). If a new tuple
{Risotto, 250, ItaliYum} is inserted to the given instance of Food, which of the following
can not be a possible candidate key of Food?

a) {DishName, Price}

b) {Restaurant, Price}

c) {Restaurant, DishName}

d) {DishName, Price, Restaurant}


Solution - 9
Solution: (b), (d)

Option (b) cannot be a candidate key as the tuple {250, ItaliYum} corresponds to both
MudCake and Risotto. Option (d) is incorrect as it is a superkey.
Question - 10
Consider the following relation: ClothesShop(ClothType, CColor, Designer, ShopID) with the
following functional dependencies:
FD1: ClothType → CColor
FD2: {Designer, CColor} → ShopID
According to the rule of pseudo-transitivity, which of the following functional dependencies can
be derived?
a) CColor → ShopID b) {ClothType, CColor} → ShopID
c) {ClothType, Designer} → ShopID d) ClothType → ShopID
Solution - 10
Solution: (c) {ClothType, Designer} → ShopID

Explanation: According to the rule of pseudo transitivity.

If X→Y

and YZ → W

then, XZ → W

ClothType (X) → CColor (Y)

{Designer (Z), CColor (Y)} → ShopID (W)


Question - 11
Solution - 11
Question - 12
Solution - 12
Solution: (b), (d)
Question - 13
Solution - 13
Solution: 1NF

Given: Primary Key: {sid, course}

Prime attribute: {sid, course}

1NF: Yes

2NF: We notice that sid → sname

Proper subset of candidate key determines a non-prime attribute. Hence not in 2NF.
Question - 14
Solution - 14
Question - 15
Solution - 15
Solution: (d)
Question - 16
Solution - 16
Question - 17
Solution - 17
Question - 18
Solution - 18
Solution: 1NF

Candidate Key: {Author, ISBN}


Prime Attributes: {Author, ISBN}

1NF: Yes

2NF: A subset of primary key determines a non-prime attribute in

Author → Category
ISBN → Pages
ISBN → Publisher
Question - 19
Solution - 19

Solution: 2NF

Candidate key: {Dish}


Prime attribute: {Dish}

1NF: Yes
2NF: No non-prime attribute is determined by a proper subset of a candidate key.
3NF: Table → Price does not satisfy any of the following conditions
a.RHS should be a subset of LHS
b.LHS is a superkey
c.RHS is part of some key

You might also like