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

Tutorial_8_Questions

The document contains a tutorial on database management systems, focusing on relational algebra queries related to a Pubs database schema and various relational schemas. It includes exercises on querying authors, publications, and employee-dependent relationships, as well as optimizing relational algebra expressions. Additionally, it poses questions regarding the expected outputs of certain queries and the correctness of statements based on relational joins.

Uploaded by

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

Tutorial_8_Questions

The document contains a tutorial on database management systems, focusing on relational algebra queries related to a Pubs database schema and various relational schemas. It includes exercises on querying authors, publications, and employee-dependent relationships, as well as optimizing relational algebra expressions. Additionally, it poses questions regarding the expected outputs of certain queries and the correctness of statements based on relational joins.

Uploaded by

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

Tutorial 8

CSN-351/AID-523 Database Management Systems

1. Pubs Database Schema

Author (author id, f irst name, last name) author pub


(author id, pub id, author position) Book (book id, book
title, month, year, editor) Pub (pub id, title, book id)

• author id in author pub is a foreign key referencing author


• pub id in author pub is a foreign key referencing pub
• book id in pub is a foreign key referencing book
• editor in book is a foreign key referencing author(author id)
• Primary keys are underlined

How many tuples will be returned by the following relational algebra query?

What question does the following expression answer?


Write a relational algebra expression that returns the names of all authors who are
book editors.

Write a relational algebra expression that returns the names of all authors who are not
book editors.

Write a relational algebra expression that returns the names of all authors who have at
least one publication in the database.

How many tuples are returned by the following relational algebra expression?

What question does the following relational algebra expression answer?

2.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?

3. Consider two relations R1(A, B) with the tuples (1, 5), (3, 7) and R2(A, C) = (1, 7),
(4, 9). Assume that R(A,B,C) is the full naturalouter 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

4. 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.

5. 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.

6. 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