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

Relational Algebra Practice - 2

Uploaded by

anik.additional
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)
55 views

Relational Algebra Practice - 2

Uploaded by

anik.additional
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/ 4

9/4/23, 12:10 PM Computer Science and Engineering - Tutorials, Notes, MCQs, Questions and Answers: Relational algebra in database

in database manageme…

One stop guide to computer science students for solved questions, Notes, tutorials, solved exercises,
online quizzes, MCQs and more on DBMS, Advanced DBMS, Data Structures, Operating Systems,
Machine learning, Natural Language Processing etc.

Advanced Database Concepts Data structures, Operating Systems Natural Language Processing Quiz Questions and Ans

DBMS, ADBMS Question Bank SQL RDBMS Exam and Interview Questions Parallel Databases ADBMS Quizzes

Advanced DBMS Concepts Distributed Databases Modern Databases - Special Purpose Databases

Object Based Database Systems

Please visit, subscribe and share 10 Minutes Lectures in Computer Science

Monday, April 27, 2020 Translate

Relational algebra in database management systems solved exercise Select Language

Powered by Translate

Relational algebra in database management systems solved exercise


Share Your Articles

Relational algebra – solved exercise


Question:
Consider the following relational database schema consisting of the four relation schemas:
passenger ( pid, pname, pgender, pcity)
agency ( aid, aname, acity)
You can share your articles
flight (fid, fdate, time, src, dest) questions, etc on any of the
computer science subjects
booking (pid, aid, fid, fdate) clicking the above IMAGE

Answer the following questions using relational algebra queries;


Pages

Home

Solution: RDBMS Exam and Interview Q


Quiz Questions and Answers
Other Computer Science Subje
Relational algebra operators:
Parallel Databases
σ – selection with conditions (It selects all tuples that satisfies the conditions. Shows entire table ADBMS Quizzes
with respect to the structure) Advanced DBMS Concepts
Distributed Databases
Π – projection operator (It selects the attributes which are listed here)
Advanced Database Concepts
⨝ - natural join operator (Binary operator that join two relations on common attributes’ values) Links to Useful Video Lectures
SQL
-, ∪, and ∩ - set operators (difference, union and intersection) DBMS, ADBMS Question Bank
Animations, Graphics, and Vide
Modern Databases - Special Pu
Databases
Most of the following queries can be written in many different ways.
Object Based Database System
Miscellaneous
Privacy policy
a) Get the complete details of all flights to New Delhi.
Natural Language Processing

σ destination = “New Delhi” (flight) Vellore Institute of Technology

https://www.exploredatabase.com/2020/04/relational-algebra-in-database-solved-exercise.html 1/4
9/4/23, 12:10 PM Computer Science and Engineering - Tutorials, Notes, MCQs, Questions and Answers: Relational algebra in database manageme…

----------------------------------------------------------------------------------------------------- Ranked within top 200 in Asia (


University Rankings 2022.
Seven Subjects of VIT are rank
World University Ranking by Su
b) Get the details about all flights from Chennai to New Delhi. 2021.
12th best research institution of
(NIRF Ranking, Govt. of India 2
σ src = “Chennai” ^ dest = “New Delhi” (flight) NAAC Accreditation with highes
the last three consecutive cycle
Recognized as Institution of
----------------------------------------------------------------------------------------------------- Eminence(IoE), Govt. of India.

Labels
c) Find only the flight numbers for passenger with pid 123 for flights to Chennai before 06/11/2020.
Normalization
Π fid (σ pid = 123 (booking) ⨝ σ dest = “Chennai” ^ fdate < 06/11/2020 (flight)) Database Quizzes
Machine Learning Qu
Distributed Database (52) N
Data Structures (41) Quest
[Hint: Given conditions are pid, dest, and fdate. To get the flight id for a passenger given a pid, we (36) NLP Quiz Questio
Transaction Managemen
have two tables flight and booking to be joined with necessary conditions. From the result, the flight Solved Exercises (34) ER M
id can be projected] DBMS Question Paper (29)
Real Time Database (22) Min
----------------------------------------------------------------------------------------------------- (20) Parallel Database (17) Ind
Normal Forms (16) Object Data
2PC Protocol (13) NLP solved ex
natural language processing
d) Find the passenger names for passengers who have bookings on at least one flight. Storage Access Exercises (12) SQ
(12) Concurrency Control (11) De

Π pname (passenger ⨝ booking) Distributed Database Quiz (9) Se


(9) Transaction (8) ACID (7)
Languages (7) Intraoperation Par
Distributed Lock Manager (4)
----------------------------------------------------------------------------------------------------- Transaction (4) File organization
Processing (4) Fragmentation (3) Trigg

e) Find the passenger names for those who do not have any bookings in any flights.

Π pname ((Π pid (passenger) - Π pid (booking)) ⨝ passenger)

[Hint: here applied a set difference operation. The set difference operation returns only pids that have
no booking. The result is joined with passenger table to get the passenger names.]
-----------------------------------------------------------------------------------------------------

f) Find the agency names for agencies that located in the same city as passenger with passenger id
123.

Π aname (agency ⨝ acity = pcity (σ pid = 123 (passenger)))

[Hint: we performed a theta join on equality conditions (equi join) here. This is done between details
of passenger 123 and the agency table to get the valid records where the city values are same. From
the results, aname is projected.]
-----------------------------------------------------------------------------------------------------

g) Get the details of flights that are scheduled on both dates 01/12/2020 and 02/12/2020 at 16:00
hours.

(σ fdate = 01/12/2020 ^ time = 16:00 (flight)) ∩ (σ fdate = 02/12/2020 ^ time = 16:00


(flight))
[Hint: the requirement is for flight details for both dates in common. Hence, set intersection is used
between the temporary relations generated from application of various conditions.]
-----------------------------------------------------------------------------------------------------
https://www.exploredatabase.com/2020/04/relational-algebra-in-database-solved-exercise.html 2/4
9/4/23, 12:10 PM Computer Science and Engineering - Tutorials, Notes, MCQs, Questions and Answers: Relational algebra in database manageme…

h) 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.

(σ fdate = 01/12/2020 ^ time = 16:00 (flight)) ∪ (σ fdate = 02/12/2020 ^ time = 16:00


(flight))
-----------------------------------------------------------------------------------------------------

i) Find the agency names for agencies who do not have any bookings for passenger with id 123.

Π aname (agency ⨝ (Π aid (agency) – Π aid (σ pid = 123 (booking)))


-----------------------------------------------------------------------------------------------------

j) Find the details of all male passengers who are associated with Jet agency.

Π passengers.pid, pname, pcity (σ pgender = “Male” ^ aname = ‘Jet’ (passengers


⨝ booking ⨝ agency))
[Hint: To get the link between passengers and agency, we need to join all three tables passengers,
booking, and agency with necessary condition. Here, agency links both passengers and agency. As we
have performed natural join operation between all three tables, the degree of the result will consist of
all attributes from all the three tables. Hence, we project only passengers details as these are
mentioned as required.]

*************
Related links:

Go to DBMS - solved exercises page


Go to DBMS - Multiple Choice Questions (MCQs) page
solved exercises in dbms

solved exercises in relational algebra

solved exercises in SQL

SQL and relational algebra short answers

SQL and relational algebra short exercises

Relational algebra exercises with answers explained

RELATED POSTS:

Schedules that Conflict Number of Query How many disk


are conflict serializable records fit into a processing and block accesses
seriali... schedules - o... disk b... optimization e... requir...

By K Saravanakumar Vellore Institute of Technology - April 27, 2020

Labels: Solved Exercises

4 comments:

Anonymous October 24, 2022 at 1:49 AM

Is that last RA query wrong ? .. I think you forgot to filter upon the Jet agency

Reply

https://www.exploredatabase.com/2020/04/relational-algebra-in-database-solved-exercise.html 3/4
9/4/23, 12:10 PM Computer Science and Engineering - Tutorials, Notes, MCQs, Questions and Answers: Relational algebra in database manageme…

Replies

Anonymous October 27, 2022 at 8:29 PM

Thanks. Corrected

Reply

Anonymous January 25, 2023 at 11:43 PM

OMG THANK YOU SO MUCH

Reply

Anonymous March 7, 2023 at 7:07 AM

nyc presentation
Reply

Enter Comment

Newer Post Home Older Post

Subscribe to: Post Comments (Atom)

Featured Content

Multiple choice questions in Natural Language Processing Home

MCQ in Natural Language Processing, Quiz questions with answers in NLP, Top interview questions in NLP with answers Multiple Choice Que...

All time most popular contents

Relational algebra in database management systems solved exercise


Relational algebra in database management systems solved exercise Relational algebra – solved exercise Question: Consider the fo...

Multiple Choice Questions with Answers in Information Retrieval SET 2


Top 5 quiz questions in IR, Information retrieval quiz, information retrieval mcqs with answers, information retrieval, stop word removal...

Differentiate between dense index and sparse index


Differentiate between dense and sparse indexes - Dense index - Sparse index - Difference between sparse and dense index Dense index ...

Various disadvantages of file processing system over DBMS


Disadvantages of file processing system over database management system, List down the disadvantages of file processing systems. ...

Normalization in DBMS - Multiple Choice Questions with Answers


Normalization process in RDBMS, multiple choice questions with answers in RDBMS, normal forms and functional dependencies MCQs. Database...

Contributors

K Saravanakumar Vellore Institute of Technology

Saravanakumar Kandasamy

Report Abuse

Disclaimer

Dear readers, though most of the content of this site is written by the authors and contributors of this site, some of the content are searched, found and compiled from various other Internet sources for the
readers.

Copyright © exploredatabase.com 2020. All rights reserved. Theme images by gaffera. Powered by Blogger.

data recovery

https://www.exploredatabase.com/2020/04/relational-algebra-in-database-solved-exercise.html 4/4

You might also like