Data Model: MarvelHeroes(hid, hero, realname) DCHeroes(hid, hero, realname) Movies(mid, moviename, year) HeroInMovie(hid, mid) Relational Algebra ---------------------- Set Operations: R Union S R Intersection S R Set Difference S Rename: Given R(A,B,C) T(A1, B1, C1) = R SELECTION SELECT_C R = {t in R such that t satisfies the boolean condition C} PROJECTION PROJECT_{A1,...AN} (R) = {t in R but only the values for the attributes A1,...,AN} CARTESIAN PRODUCT Assume R and S have no common attributes R x S = { t such that t has all the attributes in R and all the attributes in S, such that there is a tuple r in R and a tuple s in S where t is equal to r for attributes in R and to s for attributes in S} R(A,B) = { , } S(C,D) = { , , } T = R x S T(A,B,C,D) = {, , , , , } T1(Hid1, Hero, Realname) = Marvel_Heroes HID1 HERO REALNAME ------------------------------------ m1 Spiderman Peter Parker m2 Black Panther T’Challa m3 Thor Thor m4 Jessica Jones Jessica Jones m5 Iron Man Tony Stark HeroInMovie hid Mid ------------- d1 1 m1 2 d3 3 d4 4 d5 5 m2 6 m3 7 m3 8 m3 9 m5 9 T2 = HeroInMovie x T1 hid Mid HID1 HERO REALNAME ------------------------------------------------- d1 1 m1 Spiderman Peter Parker m1 2 m1 Spiderman Peter Parker d3 3 m1 Spiderman Peter Parker d4 4 m1 Spiderman Peter Parker d5 5 m1 Spiderman Peter Parker m2 6 m1 Spiderman Peter Parker m3 7 m1 Spiderman Peter Parker m3 8 m1 Spiderman Peter Parker m3 9 m1 Spiderman Peter Parker m5 9 m1 Spiderman Peter Parker d1 1 m2 Black Panther T’Challa m1 2 m2 Black Panther T’Challa d3 3 m2 Black Panther T’Challa d4 4 m2 Black Panther T’Challa d5 5 m2 Black Panther T’Challa m2 6 m2 Black Panther T’Challa m3 7 m2 Black Panther T’Challa m3 8 m2 Black Panther T’Challa m3 9 m2 Black Panther T’Challa m5 9 m2 Black Panther T’Challa d1 1 m3 Thor Thor m1 2 m3 Thor Thor d3 3 m3 Thor Thor d4 4 m3 Thor Thor d5 5 m3 Thor Thor m2 6 m3 Thor Thor m3 7 m3 Thor Thor m3 8 m3 Thor Thor m3 9 m3 Thor Thor m5 9 M3 Thor Thor d1 1 m4 Jessica Jones Jessica Jones m1 2 m4 Jessica Jones Jessica Jones d3 3 m4 Jessica Jones Jessica Jones d4 4 m4 Jessica Jones Jessica Jones d5 5 m4 Jessica Jones Jessica Jones m2 6 m4 Jessica Jones Jessica Jones m3 7 m4 Jessica Jones Jessica Jones m3 8 m4 Jessica Jones Jessica Jones m3 9 m4 Jessica Jones Jessica Jones m5 9 m4 Jessica Jones Jessica Jones d1 1 m5 Iron Man Tony Stark m1 2 m5 Iron Man Tony Stark d3 3 m5 Iron Man Tony Stark d4 4 m5 Iron Man Tony Stark d5 5 m5 Iron Man Tony Stark m2 6 m5 Iron Man Tony Stark m3 7 m5 Iron Man Tony Stark m3 8 m5 Iron Man Tony Stark m3 9 m5 Iron Man Tony Stark m5 9 m5 Iron Man Tony Stark Name of all marvel heroes who have been in a movie in the database! T3 = SELECT_{hid=hid1} ( HeroInMovie x T1 ) PROJECT_{HERO} (T3) hid Mid HID1 HERO REALNAME ------------------------------------------------- m1 2 m1 Spiderman Peter Parker m2 6 m2 Black Panther T’Challa m3 7 m3 Thor Thor m3 8 m3 Thor Thor m3 9 m3 Thor Thor m5 9 m5 Iron Man Tony Stark PROJECT_{HERO} (T3) Spiderman Black Panther Thor Iron Man ------------- ID all movies who featured a DC comic hero T1(hid1, hero, realname) = DC_Heroes T2 = T1 x HeroInMovie All movies that feature a DC comic hero T3 = SELECT_{hid1 = hid} (T2) T3 schema? hid1, hero, realname, hid, mid Results = PROJECT_{mid} (T3) ------------------