Comp 1100 Entity-Relationship (ER) Model

Slides:



Advertisements
Similar presentations
the Entity-Relationship (ER) Model
Advertisements

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Outline: Data modeling using ER-model (Chapter 3 - 3rd, 4th, 5th ed.)
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Copyright © 2007 Ramez Elmasr and Shamkant B. Navathei Week 3 Outline Overview of Database Design Process Example Database Application (COMPANY) ER Model.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Entity-Relationship Model Database Management Systems I Alex Coman, Winter.
Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – ER Model.
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas.
Data Modeling Using the Entity-Relationship Model
Data Modeling Using the Entity-Relationship Model
Data Modeling Using the Entity-Relationship Model
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Chapter 3 Data Modeling Using the Entity-Relationship (ER) Model.
the Entity-Relationship Model
CONCEPTS OF E-R MODEL. CONTENTS Entity Attributes Data Value Entity Types Types of Entity Types Relationships Relationship Constraints.
Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model.
Entities and Attributes
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Data Modeling Using the Entity-Relationship
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Chapter 7: Modeling Data in the Organization Dr. Taysir Hassan Abdel Hamid IS Department Faculty of Computer and Information Assiut University March 8,
Initial Design of Entity Types for the COMPANY Database Schema Based on the requirements, we can identify four initial entity types in the COMPANY database:
Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.
Database Management COP4540, SCS, FIU Database Modeling Using the Entity-Relationship Model (Continued)
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Conceptual Modeling and Database Design.
Entity-Relationship Model Chapter 3 II COSC 457 Sungchul Hong.
Data Modeling Using the Entity-Relationship (ER) Data Model (Based on Chapter 3 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
Copyright © 2007 Ramez Elmasr and Shamkant B. Navathei Slide 3- 1.
Data Modelling Using Entity-Relationship (ER) Model
Database Systems – ER Diagrams EXAMPLE COMPANY DATABASE Requirements of the Company (oversimplified to illustrate) The company is organized into DEPARTMENTs.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 3 Data Modeling Using Entity-Relationship Model.
Data Modeling Using the Entity-Relationship (ER) Data Model.
Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 3: Data Modeling Using the Entity-Relationship (ER) Data Model
Conceptual Modelling The Entity-Relationship (ER) Model The ER diagram Data Modelling.
Chapter 7 Data Modeling Using the Entity-Relationship (ER) Model
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Lecture # 16 July 26,2012 Data Modeling using the Entity Relationship.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model تنبيه :
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Lecture # 17 July 28,2012 Data Modeling using the Entity Relationship.
Entity Relationship (E-R) Model
Data Modeling Using the Entity- Relationship (ER) Model
Databases (CS507) CHAPTER 7.
Chapter 3 Data Modeling Using the Entity-Relationship Model
CS4222 Principles of Database System
Data Modeling Using the Entity- Relationship (ER) Model
Database Management Systems
Entity- Relationship (ER) Model
ER model Ashima Wadhwa.
Entity-Relationship Model
Entity Relationship Model
Entity-Relationship Model
Chapter -3- Data Modeling Using the Entity-Relationship Model
Outline of the ER Model By S.Saha
Lecture3: Data Modeling Using the Entity-Relationship Model.
بسم الله الرحمن الرحيم.
Entity Relationship Diagrams
Data Modeling Using the Entity- Relationship Model
Initial Design of Entity Types: EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT Gender.
Database Modeling using Entity Relationship Model (E-R Model)
376a. Database Design Dept. of Computer Science Vassar College
Review of Week 1 Database DBMS File systems vs. database systems
Conceptual Data Modeling Using Entities & Relationships
Chapter 7: Entity-Relationship Model
Mapping an ERD to a Relational Database
Entity Relation Model Tingting Zhang.
ER MODELING Instructor: SAMIA ARSHAD
Presentation transcript:

Comp 1100 Entity-Relationship (ER) Model David J. Stucki

Outline Overview Entities Attributes Binary relationships Weak entity types

Overview Recall: Conceptual model Model of the concepts that the data is built on Close to how the users perceive the data

Why model? Learn from the modeling process Not all elements of your application are going to be obvious Reduce complexity via abstraction COMMUNICATION With team members Documentation With stakeholders At all levels – end users, managers, etc.

ER modeling Helpful for conceptualizing the world Provides a simple description of a complex system Breaks the world down into: Entities E.g. employee, project, department, student, major, section, etc. Entity set E.g. employees, projects, departments, students, etc. Attributes E.g. employee – name, address, ssn, etc. Domain E.g. ssn – 9 digit number

Sample Database Application COMPANY database Employees Have ssn, name and address Work for a department May work on many projects (or no projects at all) Departments Have unique department number and a manager Projects Have unique project number, location and name Need to track hours per week employee works on a project

Entities and Attributes Entities are “things” in the world Employee, Department, Project Each entity will have attributes Employee Name, Address, Ssn, Salary, etc. Department Name, Number, Location Project

Entities and Attributes In the ER model, we represent entity types rather than individual entities Individual entity – a single employee, a single department Entity set – all employees, all departments All members have same attributes – same entity type Entity type – list of attributes for an entity Represented as a rectangle EMPLOYEE

Entities and Attributes Entity types have associated attributes Attributes associated with each individual entity type Represented as circles connected to the entity type via lines Ssn Name Address EMPLOYEE

Entities and Attributes We can also define composite attributes Attributes made up of smaller subparts Represented as circles connected to the composite attribute via lines Used when we want to refer to a collection of attributes as a single unit Fname M Lname Ssn Name Address EMPLOYEE

Attributes Attributes can be singled valued or multi-valued Single valued – only one value makes sense Date of birth, Ssn Multi-valued – attribute can have multiple values Projects worked on, courses taken, phone numbers Multi-valued attributes denoted by a double circle Can have their own attributes Fname M Lname Ssn Name Address Project Address WorksOn Hours EMPLOYEE

Attributes Attributes can be derived from other attributes Age is a derived attribute from the birthdate attribute Number of projects worked on is a derived attribute from the identity of projects worked on Derived attributes shown with a dashed circle rather than a solid circle Fname M Lname Ssn Name Address Project Address WorksOn Age Hours EMPLOYEE

Attributes NULL NULL is a special value used for attributes. We use NULL as a value when: We don’t have the value for an attribute OR when there is no value applicable for an attribute We might not know the Date of Birth for a new employee NULL as a placeholder until we get the value An employee might not have a middle name NULL because the attribute is “not applicable” for this employee

Attributes Key attribute Attribute that uniquely identify an individual entity in an entity set Each individual entity in the set must have a distinct key attribute value Key attribute is identified by underlining the name of the attribute Fname M Lname Ssn Name Address EMPLOYEE

Key Attributes Entity sets can have more than one key attribute Sometimes multiple values need to be unique – each one is a key attribute Unlike in schema diagrams, each underlined attribute is a separate key All keys are equal in an ER diagram – no concept of “primary” If we need a multi-valued key, we create a composite attribute to represent it Name Number Manager DEPARTMENT ManagerStartDate

Attributes Each attribute has a set of values that may be assigned to that attribute Known as a value set Also known as the domain of the attribute Value sets not explicitly noted on ER diagram Typically specified using basic data types int, boolean, float, string, etc. Sometimes useful to use enumerated types Also usually include date, time, timestamp Value set is the set of all possible values for an attribute

Sample (preliminary) Conceptual Designs

Relationships Whenever one attribute of an entity type refers to an attribute of another entity type, a relationship between those entities exists EMPLOYEE’s “Department” attribute refers to an entity in the DEPARTMENT entity set Relationship: what department does the employee work for? DEPARTMENT’s “Manager” attribute refers to an entity in the EMPLOYEE entity set Relationship: which employee manages the department? PROJECT’s “Controlling Department” attribute refers to an entity in the DEPARTMENT entity set Relationship: which department controls this project?

Relationships These kinds of associations should be represented as relationships in the ER model In the initial design phase, relationships modeled as attributes As the design is refined, relationships explicitly modeled as connections between entity types

Relationships A relationship type defines a relationship set among entities Suppose we have n entity sets: E1 … En A relationship set R is a set of relationship instances ri that associates n different entities (e1..en) where each entity ej is in an entity set Ej above Each of the entity types Ej participates in the relationship type R Each of the individual entities ej participates in the relationship instance ri Informally – a relationship instance ri is an association of entities that includes exactly one entity from each of the participating entity types

Relationship Example Suppose we have two entity types – EMPLOYEE (E) and DEPARTMENT (D) We have a relationship between these two entity sets – each employee entity works for one department entity We define a relationship set WORKS_FOR (W) Each relationship instance in W contains two elements – one from the entity set E and one from the entity set D Each relationship instance associates one employee with one department

Relationships

Relationships In ER diagrams relationships are shown as diamond boxes, connected by lines to the participating entities Fname M Lname Name Number Ssn Name Address Manager DEPARTMENT EMPLOYEE WorksFor ManagerStartDate

Relationships The degree of the relationship is the number of participating entities WORKS_FOR has degree 2 – “binary” relationship Most common relationship is the binary relationship Larger degrees possible – “ternary” relationships of degree 3

Ternary Relationship

Recursive Relationships Same entity type participates in a relationship with itself in different roles Example: Supervision relationship One EMPLOYEE supervises another EMPLOYEE Here we need to represent the role of each entity participating in the relationship e.g. “SUPEVISOR” vs. “SUPERVISEE” We include the relationship on the lines connecting the entity to the relationship

Recursive Relationships EMPLOYEE SUPERVISOR SUPERVISEE SUPERVISION

Cardinality Ratios The cardinality ratio of a binary relationship specifies the maximum number of relationship instances an entity can participate in Can be: 1-to-1 (1:1) 1-to-many (1:M) Many-to-1 (M:1) Many-to-Many (M:N)

1:1 binary relationship - MANAGES

M:N binary relationship – WORKS_ON

Cardinality ratios We indicate cardinality ratios on ER diagrams by annotating the lines connecting entities to relationships Fname M Lname Name Number Ssn Name Address Manager 1 N DEPARTMENT EMPLOYEE WorksFor ManagerStartDate

Participation constraints Specifies the minimum number of relationship instances each entity can participate in “minimum cardinality constraint” Total participation constraint Every entity in an entity set must be related to an entity in the other entity set Example: WORKS_FOR – every EMPLOYEE must be related to a DEPARTMENT entity via the WORKS_FOR relationship Partial participation constraint Some entities in an entity set are related to an entity in the other set, but this is not required Example: MANAGES – only some EMPLOYEE entities are managers for DEPARTMENT entities

Participation constraints Total participation constraints indicated by double lines Partial participation constraints indicated by single lines Fname M Lname Name Number Ssn Name Address Manager 1 N DEPARTMENT EMPLOYEE WorksFor 1 ManagerStartDate 1 Manages

Relationship attributes Relationship types can have attributes For 1:N or 1:1 relationships, the attributes can be on either the entity types or on the relationship type 1:1 – relationship between two entities, attribute could be on either MANAGES relationship – relates EMPLOYEE entity as manager of a DEPARTMENT entity START_DATE attribute – could be on EMPLOYEE or on DEPARTMENT 1:N – relationship between one entity and many entities, attribute needs to be on the “many entity” side WORKS_FOR relationship – relates EMPLOYEE entity as working for a DEPARTMENT entity START_DATE attribute – could ONLY be on EMPLOYEE type – start date varies by EMPLOYEE

Relationship attributes For M:N relationships, attributes are determined by a combination of both entities Cannot be modeled as part of the entity type – must be part of the relationship type WORKS_ON relationship – relates an EMPLOYEE entity with a PROJECT entity Attribute: HOURS_WORKED – how many hours an EMPLOYEE worked on a particular PROJECT Can’t associate it with the EMPLOYEE entity – could work on many projects Can’t associate it with the PROJECT entity – could have many EMPLOYEEs working on the project Must associate it with the relationship directly

Relationship attributes We indicate relationship attributes by connecting them to the relationship entity via a line Fname M Lname Name Number Ssn Name Address Manager 1 N DEPARTMENT EMPLOYEE WorksFor 1 ManagerStartDate 1 Manages 37 Start_date

Weak Entity Types Entity types without a key attribute Considered to “belong” to another entity in another entity set We can only identify an entity in a weak entity type uniquely if we know which entity it “belongs” to Known as the identifying entity type Connected to weak entity type via an identifying relationship Total existence constraint – every entity in the weak entity type MUST have an associated entity in the identifying entity type Partial key – key that uniquely identifies the line IF you know which entity it belongs to

Weak Entity Types Example: DEPENDENT entity type Attribute are Name, Birth_date, Sex and Relationship to the employee (son, daughter, spouse) None of these attributes are uniquely identifying on their own or in combination You could have two people with the same first name, same birth date, same gender and same relationship to their respective employees The only unique distinction between them is which employee they are associated with Partial key – Name – as long as you assume that first names are unique in a household Name and Birthdate as a compound key is probably safer

Weak Entity Types We denote weak entities by double lines around their boxes Identifying relationship identified the same way Dashed line under the partial key 1 EMPLOYEE Dependents_of N Sex DEPENDENT Bdate Name Relationship

Sample conceptual model