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

DBMS Solution 3

The document contains a 6 question assignment on database management systems worth a total of 20 marks. It includes questions on relational algebra expressions and their outputs given sample relations, tuple relational calculus queries, entity relationship diagrams, relational schema design, and embedded SQL queries.

Uploaded by

Nithi B
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)
85 views

DBMS Solution 3

The document contains a 6 question assignment on database management systems worth a total of 20 marks. It includes questions on relational algebra expressions and their outputs given sample relations, tuple relational calculus queries, entity relationship diagrams, relational schema design, and embedded SQL queries.

Uploaded by

Nithi B
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/ 10

Database Management System: Assignment 3

Total Marks : 20

December 24, 2022

Question 1
Consider the following instance of the relation MovieBooking(MovieName, TheatrID, HallNo,
Glasses3D, MLanguage, ShowtimeID, ShowDay)

MovieBooking
MovieName TheatrID HallNo Glasses3D MLanguage ShowtimeID ShowDay
The Martian Inx K 2 Yes English 12 Monday
Interstellar Iks B 4 Yes English 15 Wednsday
Gravity Bssr K 1 No Hindi 178 Wednesday
Gravity Bssr K 4 No English 24 Thursday
Inception Inx K 3 Yes English 13 Friday

Which of the following MovieNames are produced by the Relational Algebra expression given
below?
ΠMovieName (σHallNo>2∧MLanguage=0 English0 (MovieBooking)) ∩
ΠMovieName (σGlasses3D=0 Yes0 (MovieBooking))
Marks: 2 MSQ

a) The Martian

b) Interstellar

c) Gravity

d) Inception

Answer: b), d)
Explanation: ΠMovieName (σHallNo>2∧MLanguage=0 English0 (MovieBooking)) produces
Interstellar, Gravity, Inception. However, Gravity is not associated with 3D Glasses
in the instance. Hence, the intersection operation produces Interstellar and Inception.
Hence, options (b) and (d) are correct.

1
Question 2
Consider the relation Employee(EID, Dept, Experience, Salary).
What is the Tuple Relational Calculus expression equivalent to the statement
“Select those Employee IDs (EID) whose Experiences are more than 10 years ”?
Marks: 2 MCQ

a) {<t>|∃ p,t ∈ Employee (t[Salary]=p[Dept] ∨ p[Experience]=10)}

b) {t|∃p ∈ Employee (t[EID]=p[EID] ∧ p[Experience]>10)}

c) {t|∃ p,t ∈ Employee (t[Salary]=p[EID] ∧ p[EID]>10)}

d) {<t>|∃p ∈ Employee (t[EID]=p[EID] ∧ p[Employee]>10)}

Answer: b)
Explanation: According to the syntax and semantics of Tuple Relational Calculus. Hence,
option (b) is correct.

2
Question 3
Consider the following Entity Relationship Diagram:

If n[Payment] is the number of attributes present in the relational schema of Payment,


n[In Cash] is the number of attributes present in the relational schema of In Cash and
n[In Cheque] is the number of attributes present in the relational schema of In Cheque,
which of the following options can NOT be true? Marks: 2 MSQ

a) n[Payment] = 6

b) n[In Cheque] = 6

c) n[In Cash] = 4

d) n[In Cheque] = 3

Answer: a), b)
Explanation: The relational schema can be designed as:
Method 1 (Refer to slide 15.10):
Payment(TransactionID, Amount, Paid By)
In Cash(TransactionID, ReceiptNo)
In Cheque(TransactionID, ChqNo, ChqDate)

Method 2 (Refer to slide 15.11):


Payment(TransactionID, Amount, Paid By)
In Cash(TransactionID, Amount, Paid By, ReceiptNo)
In Cheque(TransactionID, Amount, Paid By, ChqNo, ChqDate)
Thus, n[Payment] = 3, n[In Cheque]=3/5, n[In Cash] = 2/4. Hence, options (a) and (b) are
correct.

3
Question 4
Consider the Entity Relationship diagram:

Which attribute will not be present in the schema of ManagedBy? Marks: 2 MCQ

a) cnumber

b) id

c) experience

d) Enrolment

Answer: d)
Explanation: In Aggregation, the schema representation contains the primary keys of the
relationship set, associated entity and any descriptive attribute that is present. Here, the
primary keys of the relationship set Enrolment are id and pnumber. That of the associated
entity ADMIN is cnumber and the descriptive attribute is experience. Hence, option d) is
correct.

4
Question 5
In a company, the Building relation maintains information about the BuildingLocation,
BuildingFloors, BuildingType and BuildingColor.
What will be the Domain Relational Calculus expression to obtain the BuildingLocations of
those Buildings whose BuildingColor is “Gray”? Marks: 2 MCQ

a) {p|∃n,t,c (<n,t,c> ∈ Building ∧ c="Gray")}

b) {p|∃n,t,c (n,t,c ∈ Building ∧ c="Gray")}

c) {<p>|∃n,t,c (p,n,t,c ∈ Building ∨ c="Gray")}

d) {<p>|∃n,t,c (<p,n,t,c> ∈ Building ∧ c="Gray")}

Answer: d)
Explanation: According to the syntax and semantics of Tuple Relational Calculus. Hence,
option (d) is correct.

5
Question 6
Consider the Entity Relationship diagram: Marks: 2 MCQ
Which of the following statement(s) is/are TRUE?

a) DOGS inherit the attributes of CARNIVORES but not of ANIMALS.

b) DOGS inherit the attributes of CARNIVORES and ANIMALS.

c) CARNIVORES inherit the attributes of DOGS but not of OMNIVORES.

d) ANIMALS inherit the attributes of CARNIVORES, OMNIVORES, HERBIVORES and DOGS.

Answer: b)

Explanation: As per the rule of specialization. Hence, option (b) is correct.

6
Question 7
In a company, a Handicraft is made by multiple Artisans and an Artisan makes multiple
Handicrafts. The Handicrafts are identified by their unique Tags. A Handicraft is made of
a particular Material and is multi- Colored. An Artisan has a unique ID. Assuming there
is a Creates relation between Handicraft and Artisan, what will be the correct schema for
Creates and Handicraft? Marks: 2 MCQ

a) Creates(Tag, ID)
Handicraft(Tag, Material, Color)

b) Creates(ID)
Handicraft(Tag Material)
Handicraft color(Tag, Color)

c) Creates(Tag, ID, Color)


Handicraft(Tag, Material)

d) Creates(Tag, ID)
Handicraft(Tag, Material)
Handicraft color(Tag, Color)

Answer: d)
Explanation: In many-to-many relation, the relation Creates should have the primary keys
of the participating entities and since Color is multivalued, a separate schema has to be created
named Handicraft color. Hence, option (d) is correct.

7
Question 8
Consider 2 instances:

Chapter
PageNumber Topic Length
Paragraph
11 Introduction 5
PageNumber Topic
20 SQL 136
20 SQL
33 RA 567
33 RA
40 FD 898
33 ERD 204

Which PageNumber is not produced by the following Relational Algebra?


ΠChapter.PageNumber ((ΠPageNumber,Topic (Chapter) − Paragraph) × Paragraph)
Marks: 2 MCQ

a) 11

b) 40

c) 20

d) 33

Answer: c)
Explanation: (ΠPageNumber,Topic (Chapter) − Paragraph) produces the following tuples:
Chapter.PageNumber Chapter.Topic
11 Introduction
40 FD
33 ERD
The Cartesian product of these tuples with Paragraph, followed by the projection produces
PageNumbers 11, 40 and 33. Hence, option(c) is correct.

8
Question 9
Consider the relation GROCERY(ITEM, PRICE, MONTH).
Select the SQL query from within a host language, to find those ITEMS whose PRICE has
exceeded the price stored in monthly budget in a specific MONTH defined in target month.
monthly budget and target month are declared in host language. Marks: 2 MCQ

a) EXEC SQL
DECLARE c CURSOR FOR
SELECT ITEM
FROM GROCERY
WHERE PRICE > monthly_budget AND MONTH= target_month
END_EXEC

b) EXEC SQL
DECLARE c CURSOR FOR
SELECT GROCERY
FROM GROCERY
WHERE PRICE > monthly_budget AND MONTH= :target_month
END_EXEC

c) EXEC SQL
DECLARE c CURSOR FOR
SELECT ITEM
FROM GROCERY
WHERE PRICE > :monthly_budget
END_EXEC

d) EXEC SQL
DECLARE c CURSOR FOR
SELECT ITEM
FROM PRODUCT
WHERE PRICE > :monthly_budget AND MONTH= :target_month
END_EXEC

Answer: d)
Explanation: The variables declared in host language must begin with : in the embedded
SQL query. Hence, option (d) is correct.

9
Question 10
Consider the following instance of a relation Uniform:

School Color
EduSys Red
APL Green
KidSys Green
GlobalEd Blue
LPInternational Blue
EduSys White

How many tuples will be returned by the following Relational Algebra Query?
((σSchool=0 KidSys0 ∨Color=0 Blue0 Uniform) ÷ ΠColor (σColor=0 Blue0 Uniform)) ∪
ΠSchool (σColor=0 White0 Uniform)
Marks: 2 MCQ

a) 1

b) 2

c) 3

d) 4

Answer: c)
Explanation: ((σSchool=0 KidSys0 ∨Color=0 Blue0 Uniform)÷ΠColor (σColor=0 Blue0 Uniform))
produces the names of those schools whose uniform colors are blue (2 tuples).
ΠSchool (σColor=0 White0 Uniform) produces the name of that school whose uniform color is
white (1 tuple). Hence, option (c) is correct.

10

You might also like