CS157a
Chris Pollett
Oct 23, 2023
class <name> { <list of properties> };
class Movie { attribute string title; attribute integer year; attribute integer length; attribute enum Genres {drama, comedy, sciFi, teen} genre; };
class Star { attribute string name; attribute Struct Addr {string street, string city} address; };
class Movie { attribute string title; attribute integer year; attribute integer length; attribute enum Genres {drama, comedy, sciFi, teen} genre; relationship Set<Star> stars; }; class Star { attribute string name; attribute Struct Addr {string street, string city} address; relationship Set<Movie> starredIn; };
relationship Set<Star> stars; becomes relationship Set<Star> stars inverse Star::starredIn; and relationship Set<Movie> starredIn; becomes relationship Set<Movie> starredIn inverse Movie::stars;
class Cartoon extends Movie { relationship Set<Star> voices; };
class Movie (key (title, year)){ ...
Which of the following is true?
A|B --- 1|2 3|4 1|2 1|2
A|B --- 1|2 3|4 1|2 1|2then `pi_A(R)` is:
A _ 1 3 1 1
A|B|C ----- 1|2|5 3|4|6 1|2|7 1|2|7then `sigma_{C >= 6}(R)` is
A|B|C ----- 3|4|6 1|2|7 1|2|7
A|B ___ 1|2 1|2 and B|C --- 2|3 4|5 4|5their Cartesian product is:
A|R.B|S.B|C ----------- 1| 2| 2|3 1| 2| 2|3 1| 2| 4|5 1| 2| 4|5 1| 2| 4|5 1| 2| 4|5
A|B|C ----- 1|2|3 1|2|3
A|R.B|S.B|C ----------- 1| 2| 4|5 1| 2| 4|5 1| 2| 4|5 1| 2| 4|5
A|B --- 1|2 3|4 1|2 1|2then `delta(R)` is
A|B --- 1|2 3|4
A|B|C ----- 0|1|2 0|1|2 3|4|5Then the result of `pi_{A, B+C->X}(R)` is
A|X --- 0|3 0|3 3|9