Download presentation
Presentation is loading. Please wait.
Published byCoral Lamb Modified over 6 years ago
1
INF385T: Information Modeling — Class Relational Database Design from ER Models Presented November 2 Karen Wickett, School of Information University of Texas at Austin Fall 2016
2
Agenda An example database design exercise to work through together
Mapping from an E-R model to a relational DB schema entities, 1:N relationships, M:N relationships
3
MOVIE Database Design Exercise
Requirements Each movie is identified by title and year of release, has a length in minutes. Each movie has one or more directors and one or more actors appear in it. Each movie was produced by a production company. Each movie has a plot outline and is classified under a genre (e.g. horror, comedy, action, etc.) Each movie has zero or more quotable quotes, each spoken by a particular actor in the movie. Actors are identified by name and date of birth, and appear in one or more movies. Each actor has a role in each movie in which they appear. Directors are identified by name and date of birth and direct one or more movies. Production companies are identified by name and each has an address. A production company produces one or more movies.
4
Mapping
5
Example
6
Mapping (strong) Entity Types
For each entity type, create a relation schema (empty table) that includes the attributes of the entity (as the columns of the table). For example, for the EMPLOYEE entity type we create the EMPLOYEE relation schema
7
Mapping Weak Entity Types
For each weak entity W with owner entity type E, create a relation R and include all attributes of W as attributes of R. In addition, include as foreign key attributes of R, the primary key attributes of the owner entity type E. The primary key of R is the combination of the primary of the owner relations and the partial key of W, if any. For example, DEPENDENT is a weak entity type with the owner type EMPLOYEE
8
Mapping: I:N Relationship Types
For each 1:N relationship, take the relation schema corresponding to the entity type on the N-side of the relationship and include as a foreign key attribute, the primary key of the relation schema that corresponds to the other entity type.
9
Mapping: M:N Relationship Types
Create a new relation schema S (empty table) that will act to connect the primary keys on each side of the relationship. Include as foreign keys, the primary keys of each participating entity type. The combination will act as the primary key of S. Include any attributes of the relationship type as attributes of S Where Essn points to Ssn in the EMPLOYEE Relation And Pno points to Pnumber in the PROJECT Relation
10
Example: resulting Relational Database Schema
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.