Download presentation

Presentation is loading. Please wait.

Published byLeroy Soulsby Modified over 3 years ago

1
1 Relational Algebra & Calculus Chapter 4, Part A (Relational Algebra) Query Formulation Exercise

2
2 Exercises Given relational schema: Sailors (sid, sname, rating, age) Reservation (sid, bid, date) Boats (bid, bname, color) 1) Find names of sailors who’ve reserved boat #103 2) Find names of sailors who’ve reserved a red boat 3) Find sailors who’ve reserved a red or a green boat 4) Find sailors who’ve reserved a red and a green boat 5) Find the names of sailors who’ve reserved all boats

3
3 1) Find names of sailors who’ve reserved boat #103 Solution 1: Solution 2 : Solution 3 :

4
4 2) Find names of sailors who’ve reserved a red boat Boats (bid, bname, color) Information about boat color only available in Boats; so need an extra join: A more efficient solution -- why more efficient? A query optimizer can find this, given the first solution!

5
5 3) Find sailors who’ve reserved a red or a green boat Can identify all red or green boats, then find sailors who’ve reserved one of these boats: Can also define Tempboats using union! (How?) What happens if is replaced by in this query?

6
6 4) Find sailors who’ve reserved a red and a green boat Previous approach won’t work! Why? Must identify sailors who’ve reserved red boats, sailors who’ve reserved green boats, then find the intersection (note that sid is a key for Sailors):

7
7 4) Find sailors who’ve reserved a red and a green boat Previous approach won’t work! Why? Must identify sailors who’ve reserved red boats, sailors who’ve reserved green boats, then find the intersection (note that sid is a key for Sailors):

8
8 5) Find the names of sailors who’ve reserved all boats Uses division; schemas of the input relations to division (/) must be carefully chosen: To find sailors who’ve reserved all ‘Interlake’ boats:.....

Similar presentations

OK

ICS 321 Fall 2011 The Relational Model of Data (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 8/29/20111Lipyeow.

ICS 321 Fall 2011 The Relational Model of Data (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 8/29/20111Lipyeow.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on panel discussion presentation Ppt on culture of india System design ppt on software engineering Ppt on water the essence of life Ppt on obesity prevention strategies Free ppt on brain machine interface articles Ppt on inside our earth Ppt on narendra modi free download Ppt on gender in hindi Ppt on waxes structure