Entity Hierarchies -------------------- Type hierarchy: Any subclass wil inherit the attributes of the super class Instance Hierarchy: All capitals are in Cities. Objects in the subclasses also belong in the parent hierarchy. Movies union TVShowEpisodes = ? = AllMedia No...: the hierarchy is covering Movies intersection TVShowEpisodes = emptyset Yes: the hierarchy is disjoint Converting Entity Hierarchies to Relational Data Model ========================================================= Given a parent entity and subclass entities: Option 1: ----------- Convert each subclass entity to a separate relation (if the hierarchy is covering, then the parent entity does not need a separate relation) Cities(id, name, population) Capitals(id, name, population, country) Movies(id, mediafile, title) TVShowEpisodes(id, mediafile, title) Pictures(id, image, movieid, tvshowepisodeid) PicturesM(id, image, movieid) PicturesTV(id, image, tvshowepisodeid) Students(RIN, name, address, email, class) Faculty(RIN, name, address, email, title, rank) Staff(RIN, name, address, email, title) Pros? Precise! Cons? Multiple entities copy the same information ------------- Option 2: --------- Convert the parent entity to its relation and then create a new relation for each subclass, only listing the unique attributes Cities(id, name, population) Capitals(id, country) Media(id, mediafile, title) Movies(id) TVShowEpisodes(id, seasonNo, showName) Pictures(id, image, mediaid) People(RIN, name, address, email) Students(RIN, class) Faculty(RIN, title, rank) Staff(RIN, title) Pros? No repeated tuples Cons? Need a lot of joins to get the same info Option 3: ---------- Flatten and create a single entity for the whole hierarchy. We need an attribute(s) to identify the class(es) the entity belongs to. Cities(id, name, population, country, isCapital?) Media(id, title, mediafile, mediaType(isMovie), seasonNo, showName) disjoint People(RIN, name, address, email, class, title, rank, isStudent, isFaculty, isStaff) not disjoint Pros? No additional joins Cons? Waste space with lots of empty attributes Not elegant: not modular --------- Design Principles: - Merge entities that are very similar into a single one - Break apart entities that are different (different relationships or attributes) - If information is present from other part of the ER diagram, do not add them - Only represent the information that is necessary