I. Consider the following relational database scheme:

    drinker(dname)
    bar(bname)
    beer(rname)
    frequents(dname,bname)
    serves(bname,rname)
    likes(dname,rname)

   where frequents indicates the bars a drinker visits, 
   serves indicates what beer each bar serves, and likes tells 
   which beers each drinker likes to drink. 

   Express the following queries in TRC, DRC, and Datalog.

   1. Find bars that serve a beer that Charles Chugamug likes.
   2. Find drinkers who frequent at least one bar that serves a beer they like.
   3. Find drinkers who frequent at least all those bars that Charles 
      Chugamug frequents.
   4. Find drinkers who frequent no bar that serves a beer they like.
   5. Find drinkers who frequent only bars that serve at least
      one beer they like.

II. Using only the Armstrong's axioms (IR1-3), prove the following:

   {X --> YZ, Z --> CW }  |=  { X --> YZC }

III. Consider R = BOSQID and F = { S -->  D, I --> B, IS --> Q, B --> O }.
     Using the tabular method, determine if the decomposition 
     (SD,IB,ISQ,BO) is a lossless-join decomposition or not.

IV. Consider the following relation scheme:

    R = AID,CID,PID,ORDNO,CNAME,CITY,ANAME,PNAME,PRICE,MONTH,QTY,ZIP 

    and the set F of FDs:

    CID --> CNAME,CITY
    AID --> ANAME,CITY
    PID --> PNAME,PRICE
    PNAME --> PID
    PID,PNAME --> CITY
    ORDNO --> CID,AID
    ORDNO --> CNAME
    ORDNO --> ANAME
    ZIP --> CITY
    PNAME --> PRICE
    ORDNO,PID -->  QTY

    1. Find all the candidate keys for R,F.
    2. Find a minimal cover for F.
    3. Give a LJ and FD-Preserving decomposition of R into 3NF.