Lecture 10 - Chapter 7 Entity Relationship Model

Similar documents
Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

Roadmap of This Lecture. Weak Entity Sets Extended E-R Features Reduction to Relation Schemas Database Design UML*

Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

The En'ty Rela'onship Model

Chapter 7: Entity-Relationship Model. Chapter 7: Entity-Relationship Model

Unit1: Introduction. Database System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

Unit I. By Prof.Sushila Aghav MIT

Chapter 6: Entity-Relationship Model

ER to Relational Model. Professor Jessica Lin

Chapter 6: Entity-Relationship Model. E-R Diagrams

Chapter 6: Entity-Relationship Model

CS425 Fall 2013 Boris Glavic Chapter 7: Entity-Relationship Model!

Chapter 2: Entity-Relationship Model

Other Relational Languages

Entity-Relationship Model

6.1 RELATIONSHIP CONCEPTS

Chapter 6: Entity-Relationship Model

Lecture 11 - Chapter 8 Relational Database Design Part 1

Database Design and the E-R Model (7.4, )

Intro to DB CHAPTER 6

Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

The Next Step: Designing DB Schema. Chapter 6: Entity-Relationship Model. The E-R Model. Identifying Entities and their Attributes.

A database can be modeled as: + a collection of entities, + a set of relationships among entities.

LELCTURE 4: ENHANCED ENTITY-RELATIONSHIP MODELING (EER)

Chapter (4) Enhanced Entity-Relationship and Object Modeling

Chapter 7: Entity-Relationship Model. CS425 Fall 2016 Boris Glavic. Chapter 7: Entity-Relationship Model. Database Design.

Chapter 2 Introduction to Relational Models

Enhanced Entity- Relationship Models (EER)

Chapter 2: Entity-Relationship Model. Entity Sets. Entity Sets customer and loan. Attributes. Relationship Sets. A database can be modeled as:

2. E-R Model. Entity Sets Relationship Sets Attributes

Lecture 6 - More SQL

Topic 5: Mapping of EER Diagrams to Relations

Unit I. Introduction to Database. Prepared By: Prof.Sushila Aghav. Ref.Database Concepts by Korth

Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity Sets Extended E-R Features Design of the Bank Database Reduction to

ER to Relational Mapping

CSIT5300: Advanced Database Systems

Chapter 2 ENTITY RELATIONSHIP MODEL

Chapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model

Entity Relationship Data Model. Slides by: Shree Jaswal

ER-to-Relational Mapping

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe


Chapter 8: Enhanced ER Model

Using High-Level Conceptual Data Models for Database Design A Sample Database Application Entity Types, Entity Sets, Attributes, and Keys

Chapter 4. Enhanced Entity- Relationship Modeling. Enhanced-ER (EER) Model Concepts. Subclasses and Superclasses (1)

Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

Database Design Process

Chapter 6 Formal Relational Query Languages

Chapter 6: Entity-Relationship Model

Course Logistics & Chapter 1 Introduction

Enhanced Entity-Relationship (EER) Modeling

The Entity-Relationship Model. Steps in Database Design

VARDHAMAN COLLEGE OF ENGINEERING Shamshabad , Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS

COIS Databases

Chapter 8: Relational Database Design

Data Modeling Using the Entity-Relationship (ER) Model

COMP Instructor: Dimitris Papadias WWW page:

UNIT II A. ENTITY RELATIONSHIP MODEL

Chapter 8 The Enhanced Entity- Relationship (EER) Model

FINAL EXAM REVIEW. CS121: Introduction to Relational Database Systems Fall 2018 Lecture 27

CSIT5300: Advanced Database Systems

MySQL Views & Comparing SQL to NoSQL

DATABASE DESIGN I - 1DL300

DATABASE DESIGN I - 1DL300

Conceptual Modeling in ER and UML

2004 John Mylopoulos. The Entity-Relationship Model John Mylopoulos. The Entity-Relationship Model John Mylopoulos

Copyright 2007 Ramez Elmasri and Shamkant B. Navathe Slide 4-1

Relational DB Design by ER- and EER-to-Relational Mapping Design & Analysis of Database Systems

THE ENHANCED ER (EER) MODEL CHAPTER 8 (6/E) CHAPTER 4 (5/E)

Database Design Process. Requirements Collection & Analysis

Copyright 2016 Ramez Elmasr and Shamkant B. Navathei

Chapter Outline. Note 1. Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

CMPT 354 Database Systems I

Database Management System by

CS 338 The Enhanced Entity-Relationship (EER) Model

1/24/2012. Chapter 7 Outline. Chapter 7 Outline (cont d.) CS 440: Database Management Systems

Relational Database Design (II)

Advance Database Management System

Weak Entity Sets. A weak entity is an entity that cannot exist in a database unless another type of entity also exists in that database.

Module 2 : Entity-Relationship Model 15

Database Management

Database Systems. A Practical Approach to Design, Implementation, and Management. Database Systems. Thomas Connolly Carolyn Begg

CSCC43H: Introduction to Databases

Example: specific person, company, event, plant

SE 4DB3 TUTORIAL 2: REDUCTION TO RELATIONAL SCHEMAS

DATABASE SCHEMA DESIGN ENTITY-RELATIONSHIP MODEL. CS121: Relational Databases Fall 2017 Lecture 14

Database Management Systems LECTURE NOTES 2

EECS 647: Introduction to Database Systems

Database Systems. Lecture2:E-R model. Juan Huo( 霍娟 )

Conceptual Data Models for Database Design

DATABASDESIGN FÖR INGENJÖRER F

Unit 3 : Relational Database Design

Sahaj Computer Solutions. Data Modeling using the Entity Relationship Model

Contents. Database. Information Policy. C03. Entity Relationship Model WKU-IP-C03 Database / Entity Relationship Model

ENTITY-RELATIONSHIP MODEL III. CS121: Relational Databases Fall 2017 Lecture 16

Database Systems ER Model. A.R. Hurson 323 CS Building

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

Transcription:

CMSC 461, Database Management Systems Spring 2018 Lecture 10 - Chapter 7 Entity Relationship Model These slides are based on Database System Concepts 6th edition book and are a modified version of the slides which accompany the book (http://codex.cs.yale.edu/avi/db-book/db6/slide-dir/index.html), in addition to the 2009/2012 CMSC 461 slides by Dr. Kalpakis Dr. Jennifer Sleeman https://www.csee.umbc.edu/~jsleem1/courses/461/spr18

Logistics HW2 key will be available Mon March 5th Start phase 2 sooner vs. later due Wed 3/7/2018 HW3 will be released this week See the project page for a description of the rest of the phases 2

Lecture Outline Review and Clarification Reduction to Relational Schemas Design Issues Extended ER Features Database Design Tools 3

Lecture Outline Review and Clarification Reduction to Relational Schemas Design Issues Extended ER Features Database Design Tools 4

Database Design Phases Entity Relationship Model Relational Model Conceptual Design Phase Logical Design Phase Three levels of modeling Physical Design Phase 5

Redundancy Revisited 6

Redundancy Revisited We first identify entity sets Then we choose identifying attributes And relationship sets among entities This results in redundant attributes across entity sets Try to remove During the ER modeling phase 7

Cardinality Revisited draw directed line ( ) signifying one undirected line ( ), signifying many Between the relationship set and the entity set at most 1 instructor at most 1 student at most 1 instructor many students many instructors many students 8

Total vs. Partial Participation Revisited There could be an entity that does not participate in a relationship set This means there is partial participation If we want to indicate that there must be total participation, use the double line: 9

Total vs. Partial Participation Revisited Some entities may not participate in any relationship in the relationship set Example: participation of instructor in advisor is partial 10

Total vs. Partial Participation Revisited Use double lines Every entity in entity set participates in at least one relationship in the relationship set Example: participation of section in sec_course is total 11

Total vs. Partial Participation Revisited Total Partial 12

Strong vs Weak Entity Sets Revisited Total Partial 13

Lecture Outline Review and Clarification Reduction to Relational Schemas Design Issues Extended ER Features Database Design Tools 14

Reduction to Relation Schemas Entity sets and relationship sets can be expressed as relation schemas represent the contents of the database Database conforms to an E-R diagram represented by a collection of schemas 15

Reduction to Relation Schemas For each entity set and relationship set create a unique schema name corresponds to entity set or relationship set For each schema create columns corresponds to attributes 16

Representing Entity Sets With Simple Attributes A strong entity set reduces to a schema with the same attributes course(course_id, title, credits) A weak entity set becomes a table that includes a column for the primary key of the identifying strong entity set section ( course_id, sec_id, sem, year ) 17

Composite and Multivalued Attributes Composite attributes are flattened out by creating a separate attribute for each component attribute Example: given entity set instructor with composite attribute name with component attributes first_name and last_name the schema corresponding to the entity set has two attributes name_first_name and name_last_name Prefix omitted if there is no ambiguity Ignoring multivalued attributes, extended instructor schema is instructor(id, first_name, middle_initial, last_name, street_number, street_name, apt_number, city, state, zip_code, date_of_birth) 18

Composite and Multivalued Attributes A multivalued attribute M of an entity E is represented by a separate schema EM Schema EM has attributes corresponding to the primary key of E and an attribute corresponding to multivalued attribute M Example: Multivalued attribute phone_number of instructor is represented by a schema: inst_phone= ( ID, phone_number) Each value of the multivalued attribute maps to a separate tuple of the relation on schema EM For example, an instructor entity with primary key 22222 and phone numbers 456-7890 and 123-4567 maps to two tuples: (22222, 456-7890) and (22222, 123-4567) 19

Representing Relationship Sets A many-to-many relationship set is represented as a schema with attributes for the primary keys of the two participating entity sets, and any descriptive attributes of the relationship set. Example: schema for relationship set advisor advisor = (s_id, i_id) 20

Representing Relationship Sets Many-to-one and one-to-many relationship sets that are total on the many-side can be represented by adding an extra attribute to the many side, containing the primary key of the one side Example: Instead of creating a schema for relationship set inst_dept, add an attribute dept_name to the schema arising from entity set instructor 21

Representing Relationship Sets For one-to-one relationship sets, either side can be chosen to act as the many side That is, extra attribute can be added to either of the tables corresponding to the two entity sets If participation is partial on the many side, replacing a schema by an extra attribute in the schema corresponding to the many side could result in null values 22

Redundancy of Schemas Schema for the relationship set linking a weak entity set to its corresponding strong entity set is redundant and doesn't need to be present in a relational database design 23

Combination of Schemas Consider a many-to-one relationship set AB where A is an entity set and B is an entity set This would result in 3 schemas A B AB If participation of A is total, then we can combine A and AB Union of attributes between the 2 schemas Example: A= instructor, B=department, schema inst_dept can be combined with the instructor schema (ID, name, dept_name, salary) 24

Lecture Outline Review and Clarification Reduction to Relational Schemas Design Issues Extended ER Features Database Design Tools 25

Design Issues Entity Sets vs. Attributes Sometimes attributes can be seen as an entity on its own Example: Use of phone as an entity allows extra information about phone numbers (plus multiple phone numbers) If we treat it as an attribute, constraints how many values for that attribute Else the concept of a phone number becomes more generalized 26

Design Issues Entity Sets vs. Attributes Key Mistakes: Using primary key of an entity set as an attribute of another entity set instead of a relationship Student ID in Instructor relation Designation of primary keys as attributes of the relationship set Implied by the relationship set 27

Design Issues Entity Sets vs. Relationship Sets Possible guideline is to designate a relationship set to describe an action that occurs between entities Here we used a registration entity set instead of the takes relationship set. 28

Lecture Outline Review and Clarification Reduction to Relational Schemas Design Issues Extended ER Features Database Design Tools 29

Extended ER Features Extensions to basic concepts Specialization Generalization Higher/Lower level entity sets Attribute Inheritance Aggregation 30

Specialization Top down design process - designate subgroupings within an entity set that are distinctive from other entities in the set These subgroupings become lower-level entity sets that have attributes or participate in relationships that do not apply to the higher-level entity set Depicted by a triangle component labeled ISA (E.g., instructor is a person). Attribute inheritance - a lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set to which it is linked 31

Specialization 32

Specialization Entity set may be specialized by more than one distinguishing feature Entities can belong to multiple specializations Overlapping specialization multiple sets permitted Disjoint specialization At most one specialized entity set 33

Generalization A bottom-up design process a number of entity sets that share same features combine into higher-level entity set Specialization and generalization inversions of each other represented in an E-R diagram in same way Specialization and generalization are used interchangeably 34

Generalization Can have multiple specializations of an entity set based on different features permanent_employee vs. temporary_employee and instructor vs. secretary Each particular employee would be a member of one of permanent_employee or temporary_employee and also a member of instructor or secretary The ISA relationship also referred to as superclass/subclass relationship 35

Generalization vs Specialization 36

Attribute Inheritance Attributes of higher level entity sets inherited by lower level entity sets Participation also inherited Outcome: High-level entity set with attributes and relationships, apply to low-level entity set Lower-level entity sets with distinctive features 37

Attribute Inheritance 38

Specialization/Generalization Design Constraints Constraint on which entities can be members of a given lower- level entity set condition-defined Example: all customers over 65 years are members of senior-citizen entity set; senior-citizen ISA person. user-defined 39

Specialization/Generalization Design Constraints 40

Specialization/Generalization Design Constraints Constraint on whether or not entities may belong to more than one lower-level entity set within a single generalization Disjoint an entity can belong to only one lower-level entity set Noted in E-R diagram by having multiple lower-level entity sets link to the same triangle Overlapping an entity can belong to more than one lower-level entity set 41

Specialization/Generalization Design Constraints 42

Specialization/Generalization Design Constraints Completeness constraint -- specifies whether or not an entity in the higher-level entity set must belong to at least one of the lower-level entity sets within a generalization total: an entity must belong to one of the lower- level entity sets partial: an entity need not belong to one of the lower-level entity sets 43

Specialization/Generalization Design Constraints 44

Specialization via Schemas 45

Specialization via Schemas 46

ER Design Decisions The use of an attribute or entity set to represent an object Whether a real-world concept is best expressed by an entity set or a relationship set The use of a strong or weak entity set The use of specialization/generalization contributes to modularity in the design 47

Lecture Outline Review and Clarification Reduction to Relational Schemas Design Issues Extended ER Features Database Design Tools 48

E-R Diagramming Tools - Lucid 49

E-R Diagramming Tools - Lucid 50

E-R Diagramming Tools draw.io 51

E-R Diagramming Tools draw.io 52

E-R Diagramming Tools draw.io 53

E-R Diagramming Tools dia 54

E-R Diagramming Tools dia 55

E-R Diagramming Tools dia 56

E-R Diagramming Tools Visual Paradigm 57

Working Example - Dog Shelter I own a dog shelter and I want to build a system that can support me in managing the dogs and the families that adopt dogs. I like to know a lot of information about the people so I can make suggestions on what type of dog would be best for the family wishing to adopt. Some of my dogs have medical conditions I need to keep track of. After an adoption I like to check in with the family at different points in time to ensure the adoption was a success. What are the entity sets and relationship sets involved? 58

Working Example - Dog Shelter What you should consider: 1. Entity Sets 2. Relationship Sets 3. Attributes (Composite, Multi-valued, Derived) 4. Weak entity sets 5. Binary and non-binary relationships 6. Cardinality 7. Relationship set roles 59