Csc 1302, Honors Principles of Computer Science II (Fall 2021)

drinks database and Relational Algebra Queries

drinks.zip

Mac-mini:ra raj$ java RA drinks
RA> project[B]
(
rename[B](bar)
join
rename[B,R](serves)
join
project[R](select[D='Clark'](rename[D,R](likes)))
);

ANSWER(B:VARCHAR)
Number of tuples: 2

Jillians:
Dugans:

RA> project[D](
rename[D](drinker)
join
rename[D,B](frequents)
join
rename[B,R](serves)
join
rename[D,R](likes)
);

ANSWER(D:VARCHAR)
Number of tuples: 4

John:
Peter:
Donald:
Jeremy:

RA> project[D](
  rename[D](drinker)
  join
  (project[D](rename[D](drinker) minus
   project[D](
     rename[D](drinker)
     join
     project[B](select[D='Peter'](rename[D,B](frequents)))
     join
     ((project[D](rename[D](drinker)) times project[B](select[D='Peter'](rename[D,B](frequents))))
      minus
      rename[D,B](frequents)
     )
   ))
  )
);

ANSWER(D:VARCHAR)
Number of tuples: 2

Peter:
Donald:

RA> (
rename[D](drinker)
join
(rename[D](drinker) minus 
 project[D](rename[D,B](frequents) join rename[B,R](serves) join rename[D,R](likes))
)
);

ANSWER(D:VARCHAR)
Number of tuples: 1

Clark:

RA> (rename[D](drinker)
 minus
 (
  project[D](rename[D,B](frequents) minus project[D,B](rename[B,R](serves) join rename[D,R](likes)))
 )
);

ANSWER(D:VARCHAR)
Number of tuples: 3

John:
Donald:
Jeremy:

RA> exit;
Mac-mini:ra raj$