Relational Algebra Exercises

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Relational Algebra

Exercises
Exercise - 1
1. Consider a db with the following schema:
Exercise - 1
• Write relational algebra expressions for the following:
Exercise - 2
Exercise - 3
Exercise - 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 complete details of all flights to New Delhi.

σ destination = “New Delhi” (flight)

b) Get the details about all flights from Chennai to New Delhi.

σ src = “Chennai” ^ dest = “New Delhi” (flight)


c) Find only the flight numbers for passenger with pid 123 for flights to Chennai before 06/11/2020.
• Π fid (σ pid = 123 (booking) ⨝ σ dest = “Chennai” ^ fdate < 06/11/2020 (flight))

d) Find the passenger names for passengers who have bookings on at least one flight.
• Π pname (passenger ⨝ booking)

e) Find the passenger names for those who do not have any bookings in any flights.
• Π pname ((Π pid (passenger) - Π pid (booking)) ⨝ passenger)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy