Topic 3: ER – Entity Relationship Model (ERM) 6/12/2016 1.

Slides:



Advertisements
Similar presentations
Temple University – CIS Dept. CIS616– Principles of Database Systems
Advertisements

Chapter 6: Entity-Relationship Model (part I)
Conceptual Design using the Entity-Relationship Model
Chapter 6: ER – Entity Relationship Diagram
Entity-Relationship Model
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
The Entity-Relationship Model
1 541: Database Systems S. Muthu Muthukrishnan. 2 Overview of Database Design  Conceptual design: (ER Model is used at this stage.)  What are the entities.
The Entity-Relationship (ER) Model
The Entity-Relationship Model
The Entity-Relationship Model Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Text-Book Chapters (7 and 8) Entity-Relationship Model
CS157A Lecture 3 ER Diagram Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Modeling Your Data Chapter 2. Overview of Database Design Conceptual design: –What are the entities and relationships in the enterprise? – What information.
Lecture 2: Entity/Relationship modelling
The Entity-Relationship (ER) Model CS541 Computer Science Department Rutgers University.
1 Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of an E-R Database.
1–1 The E-R Model Prof. Sin-Min Lee Department of Computer Science.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Chapter 2: Entity-Relationship Model (Continued)
1 The Entity-Relationship Model Chapter 2. 2 Database Design Process  Requirement collection and analysis  DB requirements and functional requirements.
Entity-Relationship Model
1 The Entity-Relationship Model Chapter 2. 2 Overview of Database Design  Conceptual design : (ER Model is used at this stage.)  What are the entities.
Database System Concepts, 5th Ed. Chapter 6: Entity-Relationship Model.
Entity-Relationship Model
Chapter 6: ER – Entity Relationship Diagram
Chapter 2: Database Design and Entity-Relationship Model  Database Design  Entity Sets  Relationship Sets  Design Issues  Mapping Constraints  Keys.
ICS 321 Spring 2011 High Level Database Models Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 2/7/20111Lipyeow.
Christoph F. Eick: Designing E/R Diagrams 1 The Entity-Relationship Model Chapter 3+4.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 7 Database Design and The E–R Model. 2 Goals n Facilitate DB design and represent the overall logical structure of the DB. n Definition Entities.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 7: Entity-Relationship.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts DB Schema Design: the Entity-Relationship Model What’s the use of the E-R model? Entity Sets.
Entity-Relationship Model Using High-Level Conceptual Data Models for Database Design Entity Types, Sets, Attributes and Keys Relationship Types, Sets,
Computing & Information Sciences Kansas State University Wednesday, 24 Sep 2008CIS 560: Database System Concepts Lecture 12 of 42 Wednesday, 24 September.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 2 : Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping Constraints Keys E-R Diagram Extended E-R Features Design of.
Database Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
 Entity-relationship models (ERM) Entity-relationship models (ERM)  Simple E-R Diagram Simple E-R Diagram  Weak Entity Weak Entity  Strong Entity.
ITTelkom Entity Relationship Diagram (1) CS2343 Perancangan Basisdata Relasional.
1 Conceptual Design using the Entity- Relationship Model.
UNIT_2 1 DATABASE MANAGEMENT SYSTEM[DBMS] [Unit: 2] Prepared By Lavlesh Pandit SPCE MCA, Visnagar.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
Databases Illuminated Chapter 3 The Entity Relationship Model.
ICOM 5016 – Introduction to Database Systems Lecture 5 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
Database and Information Retrieval System
The Entity-Relationship (ER) Model. Overview of db design Requirement analysis – Data to be stored – Applications to be built – Operations (most frequent)
Data Modeling Using the Entity-Relationship (ER) Data Model.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
1 Entity Relationship Diagram. ER proposed by Peter Chen ER diagram is widely used in database design Represent conceptual level of a database.
LECTURE 1: Entity Relationship MODEL. Think before doing it! Like most of the software projects, you need to think before you do something. Before developing.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Mapping Constraints Keys.
Lecture 26 Enterprise Systems Development ( CSC447 ) COMSATS Islamabad Muhammad Usman, Assistant Professor.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Entity-Relationship Model Chapter 2.
Chapter 2: Entity-Relationship Model
COP Introduction to Database Structures
Lecture 5 Supplement – ER Model & Mapping to Relational Model
Entity-Relationship Model
Entity Relationship Model
Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Entity-Relationship Model
Chapter 6: Entity-Relationship Model
Chapter 7: Entity-Relationship Model
Chapter 2: Entity-Relationship Model
Presentation transcript:

Topic 3: ER – Entity Relationship Model (ERM) 6/12/2016 1

Example ER An ER diagram represents several assertions about the real world. What are they? When attributes are added, more assertions are made. How can we ensure they are correct? A DB is judged correct if it captures ER diagram correctly. Students Professor teaches Department faculty major offers Courses enrollment advisor

Database Design Process Requirement collection and analysis ◦ DB requirements and functional requirements Conceptual DB design using a high-level model ◦ Easier to understand and communicate with others Logical DB design (data model mapping) ◦ Conceptual schema is transformed from a high-level data model into implementation data model Physical DB design ◦ Internal data structures and file organizations for DB are specified

Overview of Database Design Conceptual design: (ER Model is used at this stage.) ◦ What are the entities and relationships in the enterprise? ◦ What information about these entities and relationships should we store in the database? ◦ What are the integrity constraints or business rules that hold? ◦ A database `schema’ in the ER Model can be represented pictorially (ER diagrams). ◦ An ER diagram can be mapped into a relational schema.

ER 1976 proposed by Peter Chen ER diagram is widely used in database design ◦Represent conceptual level of a database system ◦Describe things and their relationships in high level 6/12/2016 5

Basic Concepts Entity: Real-world object distinguishable from other objects Entity set – an abstraction of similar things, e.g. cars, students ◦An entity set contains many entities Attributes: common properties of the entities in a entity sets Relationship – specify the relations among entities from two or more entity sets 6/12/2016 6

Basic Concepts… Relationship: Association among two or more entities. e.g., Jack works in Pharmacy department. Relationship Set: Collection of similar relationships. ◦ An n-ary relationship set R relates n entity sets E1... En; each relationship in R involves entities e1 in E1,..., en in En ◦Same entity set could participate in different relationship sets, or in different “roles” in same set. 6/12/2016 7

ER Model Basics Key and key attributes: ◦Key: a unique value for an entity ◦Key attributes: a group of one or more attributes that uniquely identify an entity in the entity set Super key, candidate key, and primary key ◦ Super key: a set of attributes that allows to identify and entity uniquely in the entity set ◦ Candidate key: minimal super key ◦ There can be many candidate keys ◦ Primary key: a candidate key chosen by the designer ◦ Denoted by underlining in ER attributes

Difference between Candidate Key and Primary key Candidate Key – A Candidate Key can be any column or a combination of columns that can qualify as unique key in database. There can be multiple Candidate Keys in one table. Each Candidate Key can qualify as Primary Key. Primary Key – A Primary Key is a column or a combination of columns that uniquely identify a record. Only one Candidate Key can be Primary Key. 6/12/2016 9

An Example 6/12/

Relationship A relationship may be thought as a set as well ◦For binary relationship, it enumerates the pairs of entities that relate to each other ◦For example, entity set M = {Mike, Jack, Tom} entity set F = {Mary, Kate}. The relationship set married between M and F may be {, } 6/12/

Relationship 6/12/ A relationship set is a mathematical relation among n  2 entities, each taken from entity sets A relationship set is a mathematical relation among n  2 entities, each taken from entity sets {(e 1, e 2, … e n ) | e 1  E 1, e 2  E 2, …, e n  E n } where (e 1, e 2, …, e n ) is a relationship Example: Example: (Hayes, A-102)  depositor

Relationship Example 6/12/

Attribute of A Relationship Set 6/12/

Relationship The degree of a relationship = the number of entity sets that participate in the relationship ◦Mostly binary relationships ◦Sometimes more Mapping cardinality of a relationship ◦1 –1 ◦1 – many ◦many – 1 ◦Many-many 6/12/

Key Constraints Consider Works_In: An employee can work in many departments; a dept can have many employees. In contrast, each dept has at most one manager, according to the key constraint on Manages. Many-to-Many 1-to-11-to ManyMany-to-1 dname budgetdid since lot name ssn Manages Employees Departments

One-One and One- Many 6/12/

Many-one and many- many 6/12/

1- many 6/12/

Many - 1 6/12/

Many - many 6/12/

Alternative Cardinality Specification 6/12/

Note on Mapping Cardinality Both many and 1 include 0 ◦Meaning some entity may not participate in the relationship 6/12/

Participation Constraints Does every department have a manager? ◦ If so, this is a participation constraint: the participation of Departments in Manages is said to be total (vs. partial). ◦Every Departments entity must appear in an instance of the Manages relationship. lot name dname budgetdid since name dname budgetdid since Manages since Departments Employees ssn Works_In

Total Participation 6/12/ When we require all entities to participate in the relationship (total participation), we use double lines to specify Every loan has to have at least one customer

Self Relationship Sometimes entities in a entity set may relate to other entities in the same set. Thus self relationship Here employees manage some other employees The labels “manager” and “worker” are called roles the self relationship 6/12/

More examples on self- relationship People to people ◦Parent – children ◦Manager – employee ◦Husband – wife Word to word ◦Root – synonym 6/12/

Attributes Both entity sets and relationships can have attributes Attributes may be ◦Composite ◦Multi-valued (double ellipse) ◦Derive (dashed ellipse) 6/12/

Another Example 6/12/

Keys A super key of an entity set is a set of one or more attributes whose values uniquely determine each entity. A candidate key of an entity set is a minimal super key Although several candidate keys may exist, one of the candidate keys is selected to be the primary key. 6/12/

Key Examples Suggest super keys for the following entity? What are the candidate keys? Primary key? 6/12/ author name birthday death description

Ternary Relationship 6/12/

Can We Decompose a Ternary Relationship? Some relationships that appear to be non-binary may be better represented using binary relationships ◦E.g. A ternary relationship parents, relating a child to his/her father and mother, is best replaced by two binary relationships, father and mother ◦Using two binary relationships allows partial information (e.g. only mother being know) ◦But there are some relationships that are naturally non- binary ◦E.g. works-on, why? 6/12/

Converting Ternary to binary In general, any non-binary relationship can be represented using binary relationships by creating an artificial entity set. ◦Replace R between entity sets A, B and C by an entity set E, and three relationship sets: 1. R A, relating E and A 2.R B, relating E and B 3. R C, relating E and C ◦Create a special identifying attribute for E ◦Add any attributes of R to E ◦For each relationship (a i, b i, c i ) in R, create 1. a new entity e i in the entity set E 2. add (e i, a i ) to R A 3. add (e i, b i ) to R B 4. add (e i, c i ) to R C 6/12/

Converting Ternary to binary 6/12/

Design an ER Diagram Design a database for an on-line reservation system for microscopes in material science lab There are two types of users: microscope administrators and microscope end users Each microscope is located in a specific lab Each request is assigned to an administrator who can authorize or deny the request Using of some microscope requires the presence of an administrator Time is divided into 1 hour slots. Each reservation can only take one or more time slots 6/12/

Weak Entity Set Some entity sets in real world naturally depend on some other entity set ◦They can be uniquely identified only if combined with another entity set Example: ◦section1, section2, … become unique only if you put them into a context, e.g. csce4350 6/12/

Weak Entity Set Notations 6/12/ Double rectangles for weak entity set Double diamond for weak entity relationship Dashed underscore for discriminator

Specialization A lower-level entity set inherits all the attributes and relationship participation of the higher-level entity set to which it is linked. A lower-level entity set may have additional attributes and participate in additional relationships 6/12/

6/12/

Specification Disjoint Completeness constraint (use double lines) ◦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 6/12/

Design Considerations Use of entity sets vs. attributes ◦Whether we want to keep additional information Use of entity sets vs. relationship sets ◦Actions among entities are usually represented by relationships Binary versus n-ary relationship sets ◦N-nary relationships are usually more natural for actions among entity sets Weak entity set vs. strong entity set Generalization 6/12/

Notations 6/12/

Notations 6/12/

ER Practice Again Design an ER diagram for an online music store. The database will contain at least the following concepts: songs, artists, bands, albums, and genres. State your design assumptions you make to support design decisions. Be sure your assumptions are reasonable. 6/12/

Best Practice Guide for ER Design Use of entity sets vs. attributes Use of entity sets vs. relationship sets Binary versus n-ary relationship sets Weak entity set vs. strong entity set ◦Choose the natural one Generalization ◦If specialized entities need to keep additional information and participate in additional relationships 6/12/

ER for Banking Enterprise Description handhout 6/12/

Read ER Diagrams Following are some ER diagrams grabbed from the web Read to understand/criticize 6/12/

6/12/ ? ? ? ? ? ? ? ? ?

6/12/ ?? ? ? ?

6/12/ ?

6/12/