An Extra Problem: the beer database - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

An Extra Problem: the beer database

Description:

likes(drinker, beer) visits(drinker, bar) serves(bar, beer) Obs. ... 1. all drinkers who go to a bar that serves beer(s) they like ... – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 8
Provided by: marily288
Category:

less

Transcript and Presenter's Notes

Title: An Extra Problem: the beer database


1
An Extra Problem the beer database
  • likes(drinker, beer)
  • visits(drinker, bar)
  • serves(bar, beer)
  • Obs. 1 We assume that every drinker likes at
    least one beer, every drinker goes to at least
    one bar and every bar serves at least one beer.

2
1. all drinkers who go to a bar that serves
beer(s) they like
  • Obs.1 the bar can also serve beers they dont
    like
  • Obs.2 drinkers can also go to other bars, where
    they dont like the beer
  • I) relational algebra
  • ?drinker(likes visits serves) (? A)
  • II) tuple relational calculus
  • t ? l ?likes ( tdrinker ldrinker ?
    ? v ?visits ( tdrinker
    vdrinker ? ? s ?serves (vbar
    sbar ? lbeer sbeer ) ) )
  • III) domain relational calculus
  • ltdgt ?be,ba (ltd,begt ?likes ? ltd,bagt ?visits ?
    ltba,begt ?serves )

3
2. all drinkers who go to bars that serve a
beer they dont like
  • Obs.1 drinkers can also go to other bars, where
    they like the beer
  • I) relational algebra
  • ?drinker(?drinker,beer (visits serves) -
    likes) (? B)
  • II) tuple relational calculus
  • t ?v ?visits ( tdrinker vdrinker ?
    ?s ?serves (vbar sbar ? ? l
    ?likes ( tdrinker ldrinker gt lbeer ?
    sbeer ) ) )
  • III) domain relational calculus
  • ltdgt ?be,ba (ltd,bagt ?visits ? ltba,begt ? serves
    ? ? b (ltd,bgt ?likes gt b
    ? be) )

4
3. all drinkers who only go to bars that serve a
beer they like
  • Obs.1 the bar has to serve at least a beer they
    like, but can serve others
  • Obs.2 drinkers dont have to go to all bars that
    serve the beers they like
  • I) relational algebra
  • ?drinker (visits ) - ?drinker (visits -
    ?drinker,bar (serves likes ))
  • II) tuple relational calculus
  • t ? v ?visits ( tdrinker vdrinker gt
    ? l ?likes ( tdrinker ldrinker
    ? ? s ?serves ( lbeer sbeer ?
    sbar vbar ) ) )
  • III) domain relational calculus
  • ltdgt ?ba (ltd,bagt ?visits gt ? be (ltba,begt
    ?serves ? ltd,begt ? likes) )

5
4. all drinkers who only go to bars that serve NO
beer they like
  • I) relational algebra
  • ?drinker (visits ) - A
  • II) tuple relational calculus
  • t ? v ?visits ( tdrinker vdrinker ?
    ? s ?serves (sbar vbar ) gt
    ? ? l ?likes ( tdrinker ldrinker ?
    lbeer sbeer ) )
  • III) domain relational calculus
  • ltdgt ?ba,be (ltd,bagt ?visits ? ltba,begt ? serves
    gt ltd,begt ? likes)

6
5. all drinkers who only go to bars that serve
only beer they like
  • I) relational algebra
  • ?drinker (visits ) - B
  • II) tuple relational calculus
  • t ? v ?visits ( tdrinker vdrinker ?
    ? s ?serves (sbar vbar ) gt
    ? l ?likes ( tdrinker ldrinker ?
    lbeer sbeer ) )
  • III) domain relational calculus
  • ltdgt ?ba, be (ltd,bagt ?visits ? ltba,begt ?serves
    gtltd,begt ? likes)

7
6. all the drinkers who like all the beers that
are served somewhere
  • Obs. 1 the drinkers may also like some beers
    that are not served anywhere.
  • I) relational algebra
  • likes ?beer(serves )
  • II) tuple relational calculus
  • t ? v ?visits ( tdrinker vdrinker ?
  • ? s ?serves (? l ?likes ( tdrinker
    ldrinker ? lbeer sbeer ) )
  • III) domain relational calculus
  • ltdgt ? b (ltd,bgt?visits ?
    ?ba, be
    (ltba,begt ?serves gt ltd,begt ? likes)
Write a Comment
User Comments (0)
About PowerShow.com