Chapter 7 Data Modeling Using the Entity-Relationship (ER) Model

Slides:



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

Conceptual Data Modeling: ER
Chapter 31 Chapter 3 Data Modeling Using the Entity-Relationship Model.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
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.
Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – ER Model.
Database Management COP4540, SCS, FIU Database Modeling Using the Entity-Relationship Model (Chapter 3)
CS 405G Introduction to Database Systems
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
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.
Lecture 2: Entity-Relationship Modeling
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.
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Data Modeling Using the Entity- Relationship (ER) Model Hour1 Presented.
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
Entity-Relationship Model Ch. 3
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.
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.
Dr. Ahmad R. Hadaegh A.R. Hadaegh California State University San Marcos (CSUSM) Page 1 Entity Relational Diagram (ERD) Modeling This particular lecture.
Data Modeling Using the Entity- Relationship (ER) Model.
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:
Entity – Relationship Model (E-R Model)
CS 405G: Introduction to Database Systems Lecture 2 : Database Design I.
Chapter 3 Data Modeling Using the Entity-Relationship (ER) Model Copyright © 2004 Pearson Education, Inc.
3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.
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)
Database Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
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 Elmasri and Shamkant B. Navathe Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
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.
Chapter 2 Data Modeling Using the Entity-Relationship (ER) Model Copyright © 2004 Pearson Education, Inc.
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
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Lecture # 16 July 26,2012 Data Modeling using the Entity Relationship.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
Data Modeling Using the Entity- Relationship (ER) Model
Comp 1100 Entity-Relationship (ER) Model
Databases (CS507) CHAPTER 7.
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
Lecture3: Data Modeling Using the Entity-Relationship Model.
بسم الله الرحمن الرحيم.
Initial Design of Entity Types: EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT Gender.
Conceptual Data Modeling Using Entities & Relationships
Entity Relation Model Tingting Zhang.
Presentation transcript:

Chapter 7 Data Modeling Using the Entity-Relationship (ER) Model

Entity Relationship Model (ER) ER model was proposed by Peter Chen in 1976 ER model has become the standard tool for conceptual schema design ER model consists of three basic constructs: entities, attributes and relationships.

What is an entity ? An entity is a “thing” in the real world with an independent existence. It may be an object with physical existence (e.g. person, car, house, employee), or it may be an object with conceptual existence (company, job, university, course).

Entity and Entity Set Two types of entities: Strong entity: can exist independently (or can uniquely identify itself) Weak entity: existence depends on the existence of other (strong) entity or entities Examples: An employee is a strong entity but the dependents of the employee could be weak entities An account in a bank is a strong entity but a transaction could be a week entity

Entity and Entity Set An entity type defines a set of entities that have the same attributes. STUDENT is an entity type (Schema) An entity set is a collection of entities of the same entity type Examples: Rema, Ali, Amal, Samer, Rana are entity set of an entity type STUDENT

Attributes An entity has a set of attributes that describes it. Person(SSN, Name, Address, Job-description, Salary). An entity will have a value for each of its attributes (999-010-201, John Smith, ‘20 Alebany Rd, Cardiff, UK’, ‘Manager’, 2500) The properties of an entity set are called attributes of the entity set. Students: SSN, Name, Address, GPA, Status, ... Books: Title, ISBN, Authors, Publisher, Year, ...

Types of Attributes Simple (or atomic) attribute is a one which cannot be divided into smaller parts. Examples: SSN, GPA, Salary. Composite attribute is an attribute which can be divided into smaller subparts, these subparts represent more basic attributes with independent meanings of their own Name: First_Name, Middle_Name, Last_Name Address: Street_Address, City, State, Zip code

An Example of a composite attribute Address Street-Address City State Post Code Street Name House No.

Types of Attributes A single-valued attribute is a one which has one (single) value for a particular entity. Example: Age, BirthDate A multi-valued attribute is a one which may have one or more values for the same entity. College Degrees for Person: 0, 1, 2, 3, … Color for a Car: 1, 2, ….. Authors of Books Phone Number

Types of Attributes A stored attribute is a one whose value is explicitly stored in the database. e.g. name, birth-date. Derived-attributes: whose values are computed from other attributes. Age from Birthdate Annual Salary from Monthly Salary NoOfEmployees ==> Count number of employees in the Employee table.

Relationship Types A relationship type is represented as diamond-shaped box which is connected by straight lines

Relationship Degree Degree of a relationship type is the number of participating entity types: binary relationships, ternary relationships, …. Works-for COMPANY EMPLOYEE Binary Relationships

Ternary Relationships supplies PROJECT SUPPLIER PART

Ternary Relationships Sells PRODUCT COMPANY COUNTRY

Binary Recursive Relationships EMPLOYEE Supervises Marry PERSON

Relationships The role name signifies the role that a participating entity from the entity type plays in each relationship instance entity e1 plays the role of a supervisor, while entity e2 plays the role of a supervisee supervisee EMPLOYEE e2 Supervises e1 supervisor

Cardinality Ratio Specifies the number of relationship instances that an entity can participate in Common cardinality ratios for binary relationship types are 1:1, 1:N, and M:N

1:N Works_for N 1 COMPANY EMPLOYEE An employee works for one company, and a company has many employees working for it

A department has one manager and a manager manages one department 1:1 Has 1 1 MANAGER DEPARTMENT A department has one manager and a manager manages one department

M:N Works-on M N PROJECT EMPLOYEE An employee works on many projects, and a project has many employees working on it

Participation Constraints Specifies whether the existence of an entity depends on its being related to another entity via the relationship type There is total and partial participation

Total participation Works-for N 1 DEPARTMENT EMPLOYEE Total participation. Every employee must be related to a department via WORKS-FOR relationship. A department must have at least one employee.

Partial participation 1 N Buys PERSON CAR A person may buy a car and car may be bought by a person

Total & Partial participation 1 1 PROFESSOR DEPARTMENT Manages A professor may manage a department (partial participation), but a department must be managed by a professor (total participation).

Attributes of Relationship Types Works-for N 1 EMPLOYEE DEPARTMENT Start-Date We may keep a start date attribute to record for each employee the date he/she started work for a certain department.

A weak entity type is an entity which does not have any key attributes Works-for DEPARTMENT EMPLOYEE 1 identifying relationship Dependents Fname N Sex DEPENDENT Birthdate Relationship

Weak Entity Types A weak entity type always has a total participation with its identifying entity type A Weak entity type has a partial key, i.e. this key is enough to identify its extension within the scope of its identifying entity type In the previous example, the first name is enough to identify kids within a single family, but is not enough to identify entities as stand alone entities (two families may use identical names for their kids)

ER Notations Entity Type <Name> Attribute <Name> Key Attribute Multi-valued attribute <Name>

Identifying Relationship Type ER Diagram Notations <Name> Weak Entity Type <Name> Relationship Type Identifying Relationship Type <Name>

ER Notations partial key attribute Composite Attribute <Name> <Name> Composite Attribute <Name> Derived Attribute <Name> partial key attribute <Name>

Notations Entity Types singular name, capital letters Relationship Types usually singular verbs, capital letters Attribute nouns, capitalized Role names are in lowercase letters ER diagrams are drawn such that they are readable from left to right and top to bottom (Except weak entity types)

Relationships Several relationships may exist among the same set of entity sets. Works_in EMPLOYEE DEPARTMENT Manages

Degree of a Relationship (1) Definition: The degree of a relationship is the number of entity sets participating the relationship. Recursive relationship Examples: Supervises on Employees is_prerequisite_of on Courses is_classmate_of on Students

Degree of a Relationship (2) Binary relationship (degree = 2) Examples: takes between Students and Courses owns between Persons and Cars Ternary relationship (degree = 3) orders among Customers, Parts and Suppliers skill_used among Engineers, Skills and Projects

Cardinality (1) One-to-one (1-to-1) relationship between E1 and E2: for each entity in E1, there is at most one associated entity in E2, and vice versa. Examples of 1-to-1 relationships: Binary 1-to-1 relationship manages between Employees and Departments recursive 1-to-1 relationship is_married_to on Persons

Cardinality (2) One-to-many (1-to-m) relationship from E1 to E2: for each entity of E1, there are zero or more associated entities of E2, but for each entity of E2, there is at most one associated entity of E1 Examples of 1-to-m relationships: binary 1-to-m relationship advises between Professors and Students recursive 1-to-m relationship is_mother_of on Persons Many-to-one (m-to-1) relationship from E1 to E2: same as 1-to-m relationship from E2 to E1

Cardinality (3) Many-to-many (m-to-m) relationship between E1 and E2: for each entity in E1, there are zero or more associated entities in E2, and vice versa Examples of m-to-m relationships: binary m-to-m relationship takes between Students and Courses recursive m-to-m relationship is_component_of on Parts

Recursive relationship ER Diagram (1) Recursive relationship is_married_to 1 1 PERSON SSN Name Age

ER Diagram (2) binary relationship SSN Age Name SSN Name Age advises 1 PROFESSOR advises STUDENT SSN Age Name SSN Name Age

ER Diagram (3) ternary relationship ENGINEER Skill_used SKILL PROJECT

Role of an Entity Set (1) Definition: The role of an entity set in a relationship is the function it performs in the relationship. Case 1: Role can be determined from properly chosen names. m takes n STUDENT COURSE 1 is_TA_of 1

Role of an Entity Set (2) Case 2: Roles need to be explicitly given. is_married_to supervises 1 1 1 m wife husband supervisor supervisee PERSON EMPLOYEE

Attribute of Relationship (1) Where to keep the grade information? m n takes STUDENT COURSE grade

Attribute of Relationship (2) Another example: SUPPLIER m Quantity orders n r PART PROJECT

Cardinality Constraint min/max (1) One in ER model means zero or one Many in ER model means zero or more Cardinality constraints make them more precise (1, 5) takes (15, 60) STUDENT COURSE

Cardinality Constraint min/max (2) General format: 0  min_card  max_card Interpretation: Each entity in E may involve between min_card and max_card relationships in R. (min_card, max_card) E R

Cardinality Constraint min/max (3) Definition: If every entity in E involves at least one relationship in R (i.e., min_card >= 1), E is said to have total participation in R If min_card = 0, E is said to have partial participation in R

Cardinality Constraint min/max (4) Employees has a partial participation. Departments has a total participation. (0, 1) manages (1, 1) EMPLOYEE DEPARTMENT

Representing 1-to-1, 1-to-m, m-to-m Relationships (0, 1) (0, 1) one-to-one: E R F (0, m) (0, n) many-to-many: E R F (0, m) (0,1) one-to-many: E R F 1 m E R F

An Example Database Application Company Database

An Example Database Application The Company database keeps track of a company’s Employees, Departments, Projects The following are the requirements and specifications The company is organized into departments. Each department has a: unique name, unique number particular employee who manages the department We keep track of the start date when that employee began managing the department A department may have several locations

An Example Database Application A department controls a number of projects, each of which has a unique name, unique number, and single location We store each employee’s name, social security number, address, salary, sex, and birth date. An employee is assigned to one department but may work on several projects, which are not necessarily controlled by the same department We keep track of the number of hours per week that an employee works on each project We keep track of the direct supervisor of each employee

An Example Database Application We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent’s first name, sex, birth date, and relationship to the employee

ER diagram for the company database Each department has a unique name, a unique number, particular employee who manages the department. A department may have several locations. Name Number Locations NumberOfEmployee DEPARTMENT

ER diagram for the company database A department controls a number of projects, each of which has a unique name, unique number, and single location Name Number Location PROJECT

ER diagram for the company database We store each employee’s name, social security number, address, salary, sex, and birth date. Minit Lname Fname Name SSN Address Sex Salary EMPLOYEE BDate

ER diagram for the company database We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent’s first name, sex, birth date, and relationship to the employee Fname Relationship Sex DEPENDENT BDate

ER diagram for the company database Each department has a particular employee who manages the department We keep track of the start date when that employee began managing the department Manages (1,1) (0,1) EMPLOYEE DEPARTMENT manager department managed StartDate

ER diagram for the company database An employee is assigned to one department. Works_for (1,N) (1,1) EMPLOYEE DEPARTMENT employee department

ER diagram for the company database A department controls a number of projects Controls (1,1) (0,N) DEPARTMENT PROJECT controlling department controlled project

ER diagram for the company database An employee is assigned to one department but may work on several projects, which are not necessarily controlled by the same department. We keep track of the number of hours per week that an employee works on each project Works_on (1,N) (0,N) EMPLOYEE PROJECT worker project Hours

ER diagram for the company database We keep track of the direct supervisor of each employee EMPLOYEE Supervises (0,N) (0,1) supervisor supervisee

ER diagram for the company database We want to keep track of the dependents of each employee for insurance purposes. has (1,1) (0,N) EMPLOYEE DEPENDENT employee dependent

ER diagram for the company database

Example of Other Notation: UML Class Diagrams UML methodology Used extensively in software design Many types of diagrams for various software design purposes UML class diagrams Entity in ER corresponds to an object in UML

Example of Other Notation: UML Class Diagrams (cont’d.) Class includes three sections: Top section gives the class name Middle section includes the attributes; Last section includes operations that can be applied to individual objects

Example of Other Notation: UML Class Diagrams (cont’d.) Associations: relationship types Relationship instances: links Binary association Represented as a line connecting participating classes May optionally have a name Link attribute Placed in a box connected to the association’s line by a dashed line

Example of Other Notation: UML Class Diagrams (cont’d.) Multiplicities: min..max, asterisk (*) indicates no maximum limit on participation Types of relationships: association and aggregation Distinguish between unidirectional and bidirectional associations Model weak entities using qualified association

Relationship Types of Degree Higher than Two Degree of a relationship type Number of participating entity types Binary Relationship type of degree two Ternary Relationship type of degree three