1 / 34

CSC 3810 Lecture Slides Relational Algebra

CSC 3810 Lecture Slides Relational Algebra. Instance S1 of Stations.  network = “NBC” (S1) . What stations are in the NBC network?.  network, town (S1) . What networks in what towns are represented?.  network (S1) . What networks are represented?.

latif
Download Presentation

CSC 3810 Lecture Slides Relational Algebra

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC 3810 Lecture SlidesRelational Algebra

  2. Instance S1 of Stations

  3. network = “NBC” (S1) What stations are in the NBC network?

  4. network, town (S1) What networks in what towns are represented?

  5. network (S1) What networks are represented?

  6. channel, town(network = “ABC” (S1)) What channels are ABC in what towns?

  7. Instances S1 and S2 of Stations

  8. S1  S2

  9. S1  S2

  10. S1 – S2

  11. Instance P1 of Programs Programs ( statid:integer, showid:integer, timeslot:integer,day:string )

  12. S2  P1

  13. Instance T1 of TVShows TVShows ( showid:integer, title:string )

  14. P1⋈P1.showid=T1.showid  T1.title=”West Wing” T1 When is the West Wing on?

  15. S1 ⋈ S1.statid = P1.statid P1 When is each station showing something?

  16. (S1 ⋈ P1) ⋈ T1 What shows are being shown on which stations, when?

  17. Instance D1 of DVDs DVDs (did: integer, title: string)

  18. Instance P1 of People People (pid: integer, name: string)

  19. Instance O1 of Owns Owns (pid: integer, did: integer)

  20. O1 ⋈ D1 Who owns which DVD? (first try)

  21. O1 ⋈ D1 ⋈ P1 Who owns which DVD? (with names this time)

  22. name,title (O1 ⋈ D1 ⋈ P1) Who owns which DVD?

  23. title=“The Matrix”(name,title(O1 ⋈ D1 ⋈ P1)) Who owns “The Matrix?”

  24. name=“Bob”(name,title(O1 ⋈ D1 ⋈ P1)) Which movies does Bob own?

  25. name=“Ellen” (O2) name=“Mary” (O2) Ellen and Mary have combined their movie collection. What is in their joint collection?

  26. name=“Ellen” (O2) name=“Mary” (O2) Which movies do they have duplicates of?

  27. pid (title=“The Matrix” (D1) ⋈ O1) Who owns “The Matrix?” Name this “MatrixOwners”

  28. pid (title=“Star Wars” (D1) ⋈ O1) Who owns “Star Wars?” Name this “StarWarsOwners”

  29. name (MatrixOwners  StarWarsOwners ) ⋈ P1) Who owns both “The Matrix” and “Star Wars?”

  30. ρ(Ownership, pid,.name,did (O1⋈P1)) Who owns which movies? Name this “Ownership”

  31. ρ( Pairs (1→pid1, 2→name1, 3→did1, 4 → pid2, 5→name2, 6→did2), Ownership  Ownership ) What are all pairs of owned movies?

  32. name1 (pid1=pid2  did1did2( Pairs ) ) Who owns at least two movies?

  33. Division Who are the people in O1 (left) where for every did in D1 (below), there is a tuple in O1? I.e., who owns every movie?

  34. Division pid (O1)  did (D1) (  pid (O1)  did (D1) ) – O1  pid ((  pid (O1)  did (D1) ) – O1 ) O1 / (  did (D1) )  name ( O1 / (  did (D1) ) ) ⋈ P1 )

More Related