Data Model: MarvelHeroes(hid, hero, realname) DCHeroes(hid, hero, realname) Movies(mid, moviename, year) HeroInMovie(hid, mid) Databases: A set of relations. Relational Algebra ---------------------- Basic Definitions: input: set of tuples, a relation, or two relations Output: set of tuples Set Compatibility: Two relations are set compatible, if they have the same schema: the same set of attributes Set Operations: R Union S R Intersection S R Set Difference S are defined for two relations R and S, only if R and S are set compatible. R Union S = { tuples t such t is either in relation R or in relation S} R Intersection S = { tuples t such that t is in both relation R and S } R Set Difference S = { tuples t such that t is in R but not in S } Find all heroes in either Marvel or DC Universe T = Marvel_Heroes union DC_Heroes Find all heroes that are both in Marvel and DC Universes T = Marvel_Heroes intersect DC_Heroes Find all heroes that in the Marvel Universe but not in the DC Universe T = Marvel_Heroes - DC_Heroes --------------- RIN is a key. Assume that a student can be both grad and undergrad. Ugrad(RIN, Name) Grad(RIN, Name) Find students who are coterm, but not have graduated with their BS Ugrad intersect Grad Find undergraduate students who are not coterm Ugrad - Grad Find graduate students who are not also undergraduates Grad - Ugrad Find all students in the database Grad union Ugrad