Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
40 views

Tutorial 5

This document contains 5 questions regarding relational algebra queries on various database schemas. Question 1 asks how many tuples would be returned by a given query on relations P, Q, and R. Question 2 describes the natural outer join of two relations and asks which tuples would be contained in the resulting relation. Question 3 asks for a query to return employee IDs of employees older than all their dependents. Question 4 provides a database schema and asks for queries related to flights and bookings. Question 5 asks to optimize a given relational algebra expression.

Uploaded by

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

Tutorial 5

This document contains 5 questions regarding relational algebra queries on various database schemas. Question 1 asks how many tuples would be returned by a given query on relations P, Q, and R. Question 2 describes the natural outer join of two relations and asks which tuples would be contained in the resulting relation. Question 3 asks for a query to return employee IDs of employees older than all their dependents. Question 4 provides a database schema and asks for queries related to flights and bookings. Question 5 asks to optimize a given relational algebra expression.

Uploaded by

rnbapat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Tutorial 5

CSN-351/AID-523 Database Management Systems

1. Consider the following relations P(X,Y,Z) ; Q(X,Y,T) and R(V,Y)

How many tuples will be returned by the following relational


algebra query?

2. Consider two relations R1(A, B) with the tuples (1, 5), (3, 7) and
R1(A, C) = (1, 7), (4, 9). Assume that R(A,B,C) is the full natural
outer join of R1 and R2. Consider the following tuples of the
form (A,B,C)
a = (1, 5, null); b = (1, null, 7) ; c = (3, null, 9) ; d = (4, 7,
null); e = (1, 5, 7) ; f = (3, 7, null) ; g = (4, null, 9).
Which one of the following statements is correct?
(A) R contains a, b, e, f, g but not c, d
(B) R contains a, b, c, d, e, f, g
(C) R contains e, f, g but not a, b
(D) R contains e but not f, g

3. Consider the relational schema given below, where eId of the


relation Dependent is a foreign key referring to empId of the
relation Employee. Assume that every employee has at least
one associated dependent in the Dependent relation.
Employee (empId, empName, empAge)

Dependent (depId, eId, depName, depAge)

Write a relational algebra query which returns the set of


empIds of employees whose age is greater than that of all of
his/her dependents.

4. Consider the following relational database schema consisting of


the four relation schemas:
passenger ( pid, pname, pgender, pcity)
agency ( aid, aname, acity)
flight (fid, fdate, time, src, dest)
booking (pid, aid, fid, fdate)
Answer the following questions using relational algebra queries;
a. Get the details of flights that are scheduled on either of
the dates 01/12/2020 or 02/12/2020 or both at 16:00
hours.
b. Find the agency names for agencies who do not have any
bookings for passenger with id 123.
c. Find the passenger names for those who do not have any
bookings in any flights.

5. What is the optimized version of the relation algebra expression


πA1(πA2 (σF1 (σF2(r)))) , where A1, A2 are sets of attributes in r
with A1 ⊂ A2 and F1, F2 are Boolean expressions based on the
attributes in r?
a. πA1( σ(F1∧F2)(r))
b. πA1( σ(F1∨F2)(r))
c. πA2( σ(F1∧F2)(r))
d. πA2( σ(F1∨F2)(r))

You might also like