Docsity

Algebraic Query Language for Database Interaction - Prof. le duy, Lab Reports of Database Programming

Toggle sidebar
bg1
LAB1: DBI202
An Algebraic Query Language
1. Find the names of sailors who have reserved boat 103
๐œ‹sname (Reserve โ‹ˆbid=103 Sailor)
๐œ‹sname ((๐œŽbid=103 Reserve) ร— Sailor)
๐œ‹sname (๐œŽbid=103 (Reserve โ‹ˆ Sailor))
๐œ‹sname ((๐œŽbid=103 Reserve) โ‹ˆ Sailor)
๐œ‹sname (๐œŒ(R, (๐œŽbid=103 Reserve)) โ‹ˆr.sid=sailor.sid Sailor)
2. Find the names of sailors who have reserved a red boat
๐œ‹sname ((๐œŽcolor= โ€˜redโ€™ Boats) โ‹ˆ Reserve โ‹ˆ Sailor
๐œ‹sname (๐œ‹sid ((๐œ‹bid ๐œŽcolor= โ€˜redโ€™ Boats) โ‹ˆ Reserve) โ‹ˆ Sailor)
3. Find the colors of boats reserved by Lubber
๐œ‹color ((๐œŽsname= โ€˜Lubberโ€™ Sailor) โ‹ˆ Reserve โ‹ˆ Boats)
4. Find the names of sailors who have reserved at least one boat
๐œ‹sname (Sailor โ‹ˆ Reserve)
5. Find the names of sailors who have reserved a red or a green boat
๐œ‹sname (๐œŽcolor= โ€˜redโ€™ or color= โ€˜greenโ€™ Boats โ‹ˆ Reserve โ‹ˆ Sailor)
6. Find the names of sailors who have reserved a red and a green
boat
๐œ‹sname (๐œŽcolor= โ€˜redโ€™ Boats โ‹ˆ Reserve โ‹ˆ Sailor)
โˆฉ
๐œ‹sname (๐œŽcolor= โ€˜greenโ€™ Boats โ‹ˆ Reserve โ‹ˆ Sailor)
pf2

Partial preview of the text

Download Algebraic Query Language for Database Interaction - Prof. le duy and more Lab Reports Database Programming in PDF only on Docsity!

LAB1: DBI

An Algebraic Query Language

  1. Find the names of sailors who have reserved boat 103 ๐œ‹sname (Reserve โ‹ˆbid=103 Sailor) ๐œ‹sname ((๐œŽbid=103 Reserve) ร— Sailor) ๐œ‹sname (๐œŽbid=103 (Reserve โ‹ˆ Sailor)) ๐œ‹sname ((๐œŽbid=103 Reserve) โ‹ˆ Sailor) ๐œ‹sname (๐œŒ(R, (๐œŽbid=103 Reserve)) โ‹ˆr.sid=sailor.sid Sailor)
  2. Find the names of sailors who have reserved a red boat ๐œ‹sname ((๐œŽcolor= โ€˜redโ€™ Boats) โ‹ˆ Reserve โ‹ˆ Sailor ๐œ‹sname (๐œ‹sid ((๐œ‹bid ๐œŽcolor= โ€˜redโ€™ Boats) โ‹ˆ Reserve) โ‹ˆ Sailor)
  3. Find the colors of boats reserved by Lubber ๐œ‹color ((๐œŽsname= โ€˜Lubberโ€™ Sailor) โ‹ˆ Reserve โ‹ˆ Boats)
  4. Find the names of sailors who have reserved at least one boat ๐œ‹sname (Sailor โ‹ˆ Reserve)
  5. Find the names of sailors who have reserved a red or a green boat ๐œ‹sname (๐œŽcolor= โ€˜redโ€™ or color= โ€˜greenโ€™ Boats โ‹ˆ Reserve โ‹ˆ Sailor)
  6. Find the names of sailors who have reserved a red and a green boat ๐œ‹sname (๐œŽcolor= โ€˜redโ€™ Boats โ‹ˆ Reserve โ‹ˆ Sailor) โˆฉ ๐œ‹sname (๐œŽcolor= โ€˜greenโ€™ Boats โ‹ˆ Reserve โ‹ˆ Sailor)
  1. Find the sids of sailors with age over 20 who have not reserved a red boat ๐œ‹sid (๐œŽage>20 Sailor) - ๐œ‹sid ((๐œŽcolor=โ€™redโ€™ Boats) โ‹ˆ Reserve โ‹ˆ Sailor)
  2. Find the names of sailors who have reserved all boats ๐œ‹sname ((๐œ‹sid,bid (Reserve) / ๐œ‹bid (Boats)) โ‹ˆ Sailor)
  3. Find the names of sailors who have reserved all boats called Interlake ๐œ‹sname ((๐œ‹sid,bid (Reserve) / ๐œ‹bid (Boats)) โ‹ˆ Sailor) ๐œ‹sname ((๐œ‹sid,bid (Reserve) / ๐œ‹bid (๐œŽbname=โ€™interlakeโ€™ Boats))โ‹ˆ Sailor)
  4. Find the names of sailors who have reserved at least two boats Let T = ๐œŒsid.1:=sid (๐œ‹sid.1,sname,bid (Sailor โ‹ˆ Reserve)) In ๐œ‹sname.1 ( ๐œŽsid.1=sid.2^bid.1โ‰ bid.2(T x T))