ER modeling. Lecture 4

Similar documents
MTAT Introduction to Databases

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

Conceptual Data Models for Database Design

Entity Relationship Modelling

Represent entities and relations with diagrams

Relational Model (cont d) & Entity Relational Model. Lecture 2

Data Analysis 1. Chapter 2.1 V3.1. Napier University Dr Gordon Russell

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

Unit 2 - Data Modeling. Pratian Technologies (India) Pvt. Ltd.

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

Chapter 2 Conceptual Modeling. Objectives

XV. The Entity-Relationship Model


Chapter 2: Entity-Relationship Model

Lecture3: Data Modeling Using the Entity-Relationship Model.

LECTURE 3: ENTITY-RELATIONSHIP MODELING

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

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

SOFTWARE ENGINEERING Prof.N.L.Sarda Computer Science & Engineering IIT Bombay. Lecture #10 Process Modelling DFD, Function Decomp (Part 2)

Chapter 6: Entity-Relationship Model

Chapter 4 Entity Relationship Modeling In this chapter, you will learn:

Entity-Relationship Model &

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

Entity-Relationship Model. From Chapter 5, Kroenke book

COMP Instructor: Dimitris Papadias WWW page:

Entity Relationship Data Model. Slides by: Shree Jaswal

Agenda: Understanding Relationship Types Degree and Cardinality with Examples

Entity-Relationship Model

The Entity-Relationship (ER) Model

Chapter 2 ENTITY RELATIONSHIP MODEL

Database Management Systems LECTURE NOTES 2

CSIT5300: Advanced Database Systems

The Entity/Relationship (E/R) Model & DB Design. csc343, Introduction to Databases Renée J. Miller and Fatemeh Nargesian and Sina Meraji Winter 2018

Chapter 6: Entity-Relationship Model

Conceptual Data Modeling and the Entity- Relationship Model. Department of Computer Science Northern Illinois University September 2014

Entity Relationship Modeling. From Rob and Coronel (2004), Database Systems: Design, Implementation, and Management

Major components of ER diagram Practices

course 3 Levels of Database Design CSCI 403 Database Management Mines Courses ERD Attributes Entities title 9/26/2018

Database Systems. Overview - important points. Lecture 5. Some introductory information ERD diagrams Normalization Other stuff 08/03/2015

Lecture 4. Lecture 4: The E/R Model

More on the Chen Notation

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

Data Modeling with the Entity Relationship Model. CS157A Chris Pollett Sept. 7, 2005.

Advance Database Management System

Sahaj Computer Solutions. Data Modeling using the Entity Relationship Model

Module 2 : Entity-Relationship Model 15

Chapter 3 Database Modeling and Design II. Database Modeling

Chapter 7: Entity-Relationship Model

The Entity-Relationship Model. The Entity-Relationship model. The ER model. The Entity-Relationship model. E-R Model Constructs. E-R Model Constructs

Chapter 7: Entity-Relationship Model

Chapter 6: Entity-Relationship Model

CS 405G: Introduction to Database Systems

Chapter 7: Entity-Relationship Model

MIS Database Systems Entity-Relationship Model.

Database Applications (15-415)

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

Conceptual Database Design. COSC 304 Introduction to Database Systems. Entity-Relationship Modeling. Entity-Relationship Modeling

Entity Relationship Diagram (ERD): Basics

Chapter 7: Entity-Relationship Model

Database Design with Entity Relationship Model

IS 263 Database Concepts

CSE 530A. ER Model. Washington University Fall 2013

Intro to DB CHAPTER 6

Lecture 5. Lecture 5: The E/R Model

David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation

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

MIT Database Management Systems Lesson 03: Entity Relationship Diagrams

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

CS3200 Database Design Spring 2018 Derbinsky. Entity-Relationship (ER) Diagrams. Lecture 7

Task: Design an ER diagram for that problem. Specify key attributes of each entity type.

DATABASE SYSTEMS. Chapter 5 Entity Relationship (ER) Modelling DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

Non-overlappingoverlapping. Final outcome of the worked example On pages R&C pages R&C page 157 Fig 3.52

Data Modelling and Databases. Exercise Session 2: Relational Model

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

Database Design Process

System Analysis And Design Methods ENTITY RELATIONSHIP DIAGRAM (ERD) Prof. Ali Khaleghi Eng. Hadi Haedar

Enhanced Entity- Relationship Models (EER)

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

Essentials of Database Management (Hoffer et al.) Chapter 2 Modeling Data in the Organization

THE ENTITY- RELATIONSHIP (ER) MODEL CHAPTER 7 (6/E) CHAPTER 3 (5/E)

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

The En'ty Rela'onship Model

E-R Model. Hi! Here in this lecture we are going to discuss about the E-R Model.

Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques. Fundamentals, Design, and Implementation, 9/e

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

Database Management System (15ECSC208) UNIT I: Chapter 1: Introduction to DBMS and ER-Model

II. Review/Expansion of Definitions - Ask class for definitions

The Entity-Relationship Model (ER Model) - Part 2

COSC 304 Introduction to Database Systems. Entity-Relationship Modeling

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 4 Entity Relationship (ER) Modeling

Example: specific person, company, event, plant

4. Entity Relationship Model

Data Modeling Using the Entity-Relationship Model

Lecture 14 of 42. E-R Diagrams, UML Notes: PS3 Notes, E-R Design. Thursday, 15 Feb 2007

Assignment 2: Relational Model

EECS 647: Introduction to Database Systems

Chapter 4. In this chapter, you will learn:

Conceptual Design with ER Model

Conceptual Modeling in ER and UML

Transcription:

ER modeling Lecture 4 1 Copyright 2007 STI - INNSBRUCK Today s lecture ER modeling Slides based on Introduction to Entity-relationship modeling at http://www.inf.unibz.it/~franconi/teaching/2000/ct481/er-modelling/ 2 1

Databases Data bases and data base management system the core information systems technology Example of uses: storing corporate data, web pages, on-line movies, work flow information, documents Databases are one the most applied solutions to business process reengineering (BPR) ER Modeling Purpose of ER modelling: to create an accurate reflection of the real world in a database The ER model doesn t actually give us a database description; it gives an intermediate step from which it is easy to define a database 2

Example Every department within our company is in only one division. Each division has more than one department in it. We don t have an upper limit on the number of departments that a division can have. For example, the New Business Development---the one managed by Mackenzie---and Higher Education departments are both in the Marketing division. Definitions An entity type is a collection of entities that share a common definition. An entity is a person, place, concept, or thing about which the business needs data. Example: Department is the name of one entity type. One instance of this entity type is the New Business Development department (=entity). 3

Definitions A relationship is an association between entity types. The defining characteristic of a relationship is that several entity types are involved. Example: Three entity types (Employee, Department, Division) and two relationships among these entity types (manages, contains). Graphical representation ER models are usually represented graphically. The language g we are going g to use represents entity types as rectangles and relationships as diamonds. Example: 4

Relationships No direct association between division and employee. This does not mean that there is no relationship between division and employee. An ER diagram should contain the minimum number of relationships necessary to reflect the situation. Relationships Example: divisions have multiple departments and departments can only be contained within one division. Or, for every one division there can be many departments. In the language of ER modelling this is called a 1:M (read: one to many ) relationship. Example: 5

Cardinality A relationship s cardinality defines the maximum number of entities of one type that can be associated with an entity of another type. 1:1 One entity of type X can be associated with, at most, one entity of type Y. One entity of type Y can be associated with, at most, one entity of type X. Cardinality 1:M One entity of type X can be associated with, at most, one entity of type Y. One entity of type Y can be associated with, at most, one entity of type X. -correct! M:M One entity of type X can be associated with many entities of type Y. One entity of type Y can be associated with many entities of type X. 6

Existence A relationship s existence defines what we know about the existence of any entity on the other side of a relationship from a given entity. Existence is given as optional, mandatory, or unknown. Existence Example optional A department need not have any manager. mandatory A department must have at least one manager. unknown It is unknown whether or not a department has to have a manager. 7

Existence Given any (randomly chosen) department, there must be an employee on the other side of the manage relationship. Thus, the relationship is mandatory in this direction. This is indicated by a dash on the line. Given any (randomly chosen) employee, there need not be any department on the other side of the manage relationship. Thus, the relationship is optional in this direction. This is indicated by a circle on the line. Entity subtypes An entity subtype is a collection of entities of the same type to which a narrower definition and additional attributes and/or relationships apply. 8

Entity subtypes There are many situations in which subtypes can be created but should not be. Only create subtypes if the subtype is involved in relationships that the other subtypes are not or if the subtype needs to have additional facts stored with it. Entity subtypes Example If a relationship defines the members of a proposed subtype, then use the relationship instead of the subtype. 9

Attributes An attribute is a descriptor whose values are associated with individual entities of a specific type. The attribute value for any single entity can have only one value at a given time. This value can change over time. Example: An attribute of an employee might be salary. At any one time if you asked for the salary level of a certain employee, then you should get one answer. Identifier A identifier uniquely identifies a single (at least one, and no more than one) entity. If you know the value of the identifier, then you know exactly which entity you are dealing with. The identifier s value will never change over time. 10

Degree of a relationship Relationships can be classified by the number of entity types involved. This is referred to as the degree of a relationship. Common degrees of relationships: binary This is a relationship between two entity types. ternary This is a relationship between three entity types. recursive This is a relationship involving only one entity type. Ternary relationships Example: Suppose you know the following: works-on Lindsey and Mackenzie have worked on projects A and B. applies Lindsey has used skills interface design and database design while Mackenzie only used her database design skill. used on Both skills have been used on both projects. Figure out on which projects Lindsey used which skills. 11

Ternary relationships In order to capture the necessary information the database needs a ternary relationship. The used on relationship captures information three pieces at a time. It stores facts such as: Lindsey used interface design skill on project A. Mackenzie used database design skill on project A. Recursive relationship A recursive relationship is a relationship that an entity has with itself. Example: An employee who is the manager of other employees. A manager is really just another employee 12

Recursive relationship Reading from left, down, and back up: An employee may not manage any other employees but may manage many. Reading from right, down, and back up: All employees are managed by exactly one other employee. Attributes of a relationship Relationships can also have attributes Example: Store when a person has joined a club If the attribute is of the person entity, then this would indicate when the person joined a club but we would not know which club. If the attribute is of the club entity, then this would indicate (possibly) when the club was founded or (possibly) when the most recent member joined the club but we would not know the dates on which each person joined. Solution: make join date an attribute of the is member relationship. 13

Entity subtype partitioning Optional versus mandatory mandatory He/she can demand that the person be classified as one of the subtypes. optional He/she can allow a person to be created without classifying the person as any subtype. Neither one is preferable to the other. The proper one to choose depends d on the business situation. Entity subtype partitioning Disjoint versus overlapping disjoint If entities are allowed to be no more than one subtype, then the subtypes are said to be disjoint. overlapping If entities can be classified as several subtypes, then the subtypes are said to be overlapping. 14

Aggregation of entity types Subtypes are generally thought of in terms of X is a Y (which is why these are commonly referred to as is-a relationships). Another type of relationship that needs to be represented in a database is the part of relationship, more formally called aggregation. Aggregation of entity types Example 15

Parallel relationships Two entities can have more than one type of relationship Example the entity types person and insurance policy and the relationships between them of pays for and is insured under. Weak entities Weak entities are entities, but with a difference weak entities only exist because some other entity exists. Example: 16

Types of attributes Basic These are values provided to the business. These are the types of attributes that we have been discussing so far. Think of name, address, etc. These values cannot be deduced from the values of other attributes. Designed This is invented and exists only in the database. An example might be a unique identifier for a department. This value is not changed once, it is set. Derived This is a value that can be calculated from the value of other attributes in the database. An example might be the age of an employee when the birth date is in the database. These attributes should, generally, not be stored in the database but should be calculated when needed. Attribute optionality Not all entities have a value for every attribute; however, some attributes must have a value for all entities. optional An entity need not have a value associated with an optional attribute. mandatory An entity must have a value associated with a mandatory attribute. 17

Attribute optionality Example an employee entity type has attributes hire date and termination date. Hire date would certainly be classified as a mandatory attribute; if the employee didn t have a hire date, then the person couldn t very well be an employee. The optionality of an attribute depends highly on the business situation. More about attributes default This is the value that an attribute should take if it is not assigned a value. permitted range These are the values that an attribute is allowed to take. composite A composite attribute is an attribute made up of many other attributes. 18

More about attributes Examples default the state field of an employee table might have the default value of employed. permitted range the sale_price field of the inventory table might have a permitted range of sale_price > 0 composite an employee s address that is made up of the house number, street, city, state, and zip Summary The ER model captures domain knowledge in terms of objects (entities) and relationships among these objects. An entity is a identifiable object that exists in the respective domain. Entities are described in terms of a set of attributes. A relationship is an association among several entities. The set of all entities or relationships of the same type is called the entity type or relationship type. Cardinalities express the number of entities to which another entity can be associated via a relationship type. 19

Assignment 5 a) What is the cardinality and existence of each of the following relationships in just the direction given? State any assumptions you have to make. 1. Husband to wife 2. Student to degree 3. Child to parent 4. Player to team 5. Student to course b) For each of the following pairs of rules, identify two entity types and one relationship. State the cardinality and existence of the relationship in each case. If you don t think enough information is available to define either of these, then state an assumption that makes it clear. Draw the ER diagram. 1. A department employs many persons. A person is employed by, at most, one department. 2. A manager manages, at most, one department. A department is managed by, at most, one manager. 3. An author may write many books. A book may be written by many authors. 4. A team consists of many players. A player plays for only one team. 5. A lecturer teaches, at most, one course. A course is taught by exactly one lecturer. 6. A flight-leg connects two airports. An airport is used by many flight-legs. 7. A purchase order may be for many products. A product may appear on many purchase orders. 8. A customer may submit many orders. An order is for exactly one customer. 39 Assignment 5 (cont d) c) For each of the following sets of sentences, draw the corresponding ER diagram. 1. An account can be charged against many projects, though it may not be charged against any. A project must have at least one, though it may have many, accounts charged against it. 2. Projects must be classified as either top secret or civilian (but not both). There is information specific to top secret projects and specific to civilian projects that we want to record. 3. An employee must manage exactly one department. A department may or may not have one employee manage it. 4. Men are only allowed to supervise men. Women are only allowed to supervise women. We do not want to allow the database to hold data representing a man supervising a woman. An employee, regardless of sex, is assigned to exactly one office, with each office having exactly one employee in it. (Be sure to include the office entity in this diagram.) 40 20

Thank You! Questions? 41 21