Lecture3: Data Modeling Using the Entity-Relationship Model.

Similar documents
LECTURE 3: ENTITY-RELATIONSHIP MODELING

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

Entity Relationship Data Model. Slides by: Shree Jaswal

Lecture4: Guidelines for good relational design Mapping ERD to Relation. Ref. Chapter3

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

Data Modeling Using the Entity-Relationship (ER) Model

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

Copyright 2016 Ramez Elmasr and Shamkant B. Navathei

Overview of Database Design Process. Data Modeling Using the Entity- Relationship (ER) Model. Two main activities:

Chapter 4. In this chapter, you will learn:

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

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

CSE 880:Database Systems. ER Model and Relation Schemas

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

CS 405G: Introduction to Database Systems

COSC 304 Introduction to Database Systems. Entity-Relationship Modeling

Sahaj Computer Solutions. Data Modeling using the Entity Relationship Model

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

LECTURE 6: GUIDELINES FOR GOOD RELATIONAL DESIGN MAPPING ERD TO RELATIONS

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

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

Elements of the E-R Model

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

ER Model. Objectives (2/2) Electricite Du Laos (EDL) Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 1

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

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

Represent entities and relations with diagrams

Data Modeling Using the Entity-Relationship Model

Definition. 02. Data Modeling. Example ABC Company Database. Data Modeling Importance

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

Chapter 2 Conceptual Modeling. Objectives

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II

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

Advance Database Management System

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

A l Ain University Of Science and Technology

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

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

Entity Relationship Modelling

EECS 647: Introduction to Database Systems

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

Conceptual Data Models for Database Design

Conceptual Data Modeling

Chapter # 4 Entity Relationship (ER) Modeling

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

Database Management Systems LECTURE NOTES 2

Data Modeling Using the Entity- Relationship Model Design & Analysis of Database Systems

MIT Database Management Systems Lesson 03: Entity Relationship Diagrams

A l Ain University Of Science and Technology

IS 263 Database Concepts

More on the Chen Notation

Lecture7: SQL Overview, Oracle Data Type, DDL and Constraints Part #2

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

Chapter 2 ENTITY RELATIONSHIP MODEL

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

MIS Database Systems Entity-Relationship Model.

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

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

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

Chapter 3. Data Modeling Using the Entity-Relationship (ER) Model (from E&N and my editing)

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

Objectives of logical design... Transforming the ERD diagram into relations. Relational database components. Mapping a composite attribute

CSE 530A. ER Model. Washington University Fall 2013

Intro to DB CHAPTER 6

Relational Database Systems Part 01. Karine Reis Ferreira

2. DatabaseDesign. Master I Software Engineering. Dr. Imed Bouchrika Dept of Mathematics & Computer Science University of Souk-Ahras

Conceptual Design. The Entity-Relationship (ER) Model

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

Lecture7: SQL Overview, Oracle Data Type, DDL and Constraints Part #2

CMP-3440 Database Systems

Agenda: Understanding Relationship Types Degree and Cardinality with Examples

ER modeling. Lecture 4

Module 2 : Entity-Relationship Model 15

DATABASE DESIGN PROCESS

COMP102: Introduction to Databases, 9.1

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

MTAT Introduction to Databases

CMSC 424 Database design Lecture 3: Entity-Relationship Model. Book: Chap. 1 and 6. Mihai Pop

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

LELCTURE 4: ENHANCED ENTITY-RELATIONSHIP MODELING (EER)

Conceptual Data Modeling Using E-R Models. PM Jat

Database Management System 6 ER Modeling...

Lecture 09. Spring 2018 Borough of Manhattan Community College

Entity-Relationship Models

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #5: Entity/Relational Models---Part 1

CS 146 Database Systems

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

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

Conceptual modeling is a very important phase in

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

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

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

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

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

CSIT5300: Advanced Database Systems

Conceptual Modeling in ER and UML

Chapter 2. Database Design. Database Systems p. 25/540

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

The Entity-Relationship (ER) Model 2

Chapter 6: Entity-Relationship Model

Transcription:

College of Computer and Information Sciences - Information Systems Dept. Lecture3: Data Modeling Using the Entity-Relationship Model. Ref. Chapter12 Prepared by L. Nouf Almujally & Aisha AlArfaj Rev. by L. Fatimah Alhayan 1 IS220 : D a t a b a s e F u n d a m e n t a l s

The Process of Database Design Conceptual Design Logical Design (Relational Model) Physical Design 2

Conceptual Database Design ER Diagram is used. Does not include implementation details. Users and developers can easily understand and discuss. Used to ensure all user requirements are met. Enable designers to concentrate on specifying the properties of the data, without being concerned about storage details. 3

ER Overview The Entity-Relationship (ER) model is a popular high-level conceptual data model. Based on a perception of a real world that consists of a collection of basic objects, called entities, and of the relationships among these objects. The ER model can be directly translated into relational tables. The Entity-Relationship Diagram (ERD) is a graphical model for representing the conceptual model for the data. E/R models the DB using three element types: - Entities - Attributes - Relationships 4

Example of ER Diagram 5

Entities and Attributes The ER Model describes data as entities, relationships and attributes. 1- Entity: The basic object that the ER model represents is an entity, which is a thing in the real world with an independent existence. Could be an object with a physical existence (student, car) or conceptual existence (company, course). Each entity has attributes. Rectangles represent entities Student 6

Entity Types Entity type: set of entities of the same type with the same basic attributes are grouped or typed into an entity type. For example, the Student entity type ID Student1 name name ID ID name ID name Student2 Student3 Student More Example: 7 Course book Doctor

Entities with values of their attributes An entity will have a value for each of its attributes; e.g. A specific student entity may have Name= Nora, Age = 21, ID = 1111...etc. Name = Nora e1 Age = 21 ID =1111 The attribute values that describe each entity become a part of the data stored in the database. 8

Entities and Attributes 2- Attribute: Property describing an entity. E.g. Student name, age, ID,...etc. Oval represent attributes st_name Student 9

Types of Attributes - Simple Versus Composite Simple: An attribute that has a single atomic value with an independent existence. E.g. ID, Salary, Gender Composite: An attribute composed of multiple components, each of which represent more basic attributes with independent meaning. Composite attribute indicated with sub ovals. E.g. Name (FirstName, MiddleName, LastName). ID FirstName St_no MiddleName name LastName DOB Tel_no Area_cd no EX 10 STUDENT

Types of Attributes - Simple Versus Composite Composition may form a hierarchy where some components are themselves composite. The value of a composite attribute is the concatenation of the values of its simple attributes. 11

Types of Attributes - Single-Valued Versus Multivalued Single-valued: An attribute that holds one single value for a single entity. E.g. ID. ID Multi-valued: An attribute that holds multiple values for the same entity. use double line E.g: colors attribute for a car - {Color} College degrees attribute for a person - {college degree}. Color 12

Types of Attributes - Stored Versus Derived Stored: E.g. Birth_date. Birth_date Derived: An attribute that represents a value that is derivable from the value of a related attribute or set of attributes derived attributes use dotted line For Example: The age can be determined from the current date and the value of the birth date of a person, so: age is a derived attribute and birth_date is a stored attribute. Total_cost is derived from quantity*unit_price Age 13

Types of Attributes - Stored Versus Derived Some attribute values can be derived from related entities; ID name e.g. an attribute Number_of_employees of a DEPARTMENT entity can be derived by counting the number of employees related to that department. Employee works-on Department Dept_Name Dept_No No_of_employee 14

Keys of Entity Candidate Key: is a minimal set of attributes whose values uniquely identify an entity in the set. It cannot contain NULL There could be more than one candidate key; if so, we select one of them as the primary key and the other will be an Alternate Key Candidate Key Element ( Symbol, name, atomic_no) Primary Key Alternate Key 15

Keys of Entity Primary Key The candidate key that is selected to uniquely identify an entity type. primary key attribute indicated with underline Choice of Primary Key (PK) is based on: Attribute length Number of attributes required Certainty of uniqueness PK s may be simple PK (single attribute) CUSTOMER (custno,.) STUDENT (ID,..) composite PK (multiple attributes) ORDERLINE (orderno, prodno, quantity, ) 16

Drawing Entities and Attributes stu_id name dob age student phone address street Rectangles represent entities Oval represent attributes derived attributes use dotted line multi-valued attributes use double line primary key attribute indicated with underline Composite attribute indicated with sub ovals. city 17

Lecture1 18

Relationship Association between two (or more) entities Relationships represented by diamond ENTITY Relationship ENTITY Examples Students Register for Subjects School Has Staff Driver Commits Traffic Offence Customer Orders Product Supplier Supplies Parts To Projects Relationship type (relationship set) Set of similar associations among entity sets. primary key attribute attribute 19

Attributes of Relationship Types Relationship types can also have attributes. E.g. customer orders a product quantity is attribute of orders relationship customer orders product quantity E.g. Employee WORKS-ON Project To record the number of hours per week that an employee works on a particular project. The attribute Hours can be included to the WORKS-ON relationship type. Employee works-on Project 20 Hours

Types of Relationships Degree of relationship: is the number of entity types that participate in it UNARY between entities from one entity set BINARY between entities from two entity sets N-ARY among entities from more than two entity sets 21

ER Model Unary(Recursive) Relationship Unary relationship is a relationship type where the same entity type participates more than once in a different role. It is a Recursive relationship. Employee Supervises 22

Relationship Degree - Unary relationship EMPLOYEE SUPERVISION : e 1 e 2 e 3 e 4 e 5 e 6 e 7 1 2 2 2 1 2 1 1 2 1 1 2 r 1 r 2 r 3 r 4 r 5 r 6 23 :

ER Model Roles Role indicates the purpose that each participating entity type plays in a relationship. (e.g. prerequisite, requester) COURSE requester prerequisite require 24

ER Model Roles Role can be used when two entities are associated through more than one relationship to classify the purpose of each relationship. Manager manages Branch office STAFF BRANCH Staff member allocated Branch office 25

ER Model Relationship Degree - Binary relationship A relationship of degree two (2 entity types) are binary. Employee Works for Department 26

Relationship Degree - Binary relationship EMPLOYEE WORKS_FOR DEPARTMENT r 1 e 1 e 2 e 3 e 4 e 5 e 6 r 2 r 3 r 4 r 5 r 6 d 1 d 2 d 3 : : e 7 : r 7 27

ER Model Relationship Degree - Ternary relationship A relationship of degree three (3 entity types) are ternary. e.g. Supplying a part to a project by a supplier. Supplier Supply Project Part 28

Relationship Degree - Ternary relationship SUPPLIER SUPPLY PROJECT : s 1 s 2 r 1 r 2 r 3 j 1 j 2 PART p 1 r 4 r 5 r 6 j 3 : : p 2 p 3 : r 7 29

Relationship Degree M UNARY : One entity set, recursive. SUBJECT N prerequisite BINARY : Two entity sets linked (mostly used). STUDENT M enrolls in N SUBJECT TERNARY :Three entity sets linked. RENTAL SHOP M owns N VIDEO 1 30 BORROWER

Example Relationships 31

Constraints on Relationships There are two types of relationship constraints: Cardinality ratio. Participation. 32

Cardinality Ratio Cardinality ratio Express the number of relationship an entity can participate in. Relationships can be classified as : one-to-one (1:1) one-to-many (1:M) Many-to-one (M:1) many-to-many (M:N) 33

One-to-one Relationship (1:1) Professor Manage Department P1 r1 D001 P2 P3 r2 D002 Professor 1 Manage 1 Department Each professor manages at most one department; and each department is managed by only one professor 34

One-to-Many Relationship (1:M) Professor teach Section P1 r1 3C01 r2 3C03 P2 r3 3C02 Professor 1 teach M Section Each professor teaches many sections; but each section is taught by only one professor (or at most one professor) 35

Many-to-One Relationship (M:1) Professor work-in Department P1 r1 Com. Science P2 r2 Network P3 r3 Info. Sys Professor M Work-in 1 Department Each professor works in only one Department; but each Department has many professors (many professors work in one department) 36

Many-to-Many Relationship Student Enroll-in Course S1 r1 is300 S2 r2 is400 S3 r3 is500 S4 r4 is600 Student M Enroll-in M course Each student can enroll in many courses; and each course can be enrolled by many students. 37

Multiplicity Multiplicity is the number (range) of possible entities that may relate to a single association through a particular relationship Takes the form (min#, max#) 38

Multiplicity Professor Manage Department P1 r1 D001 P2 P3 r2 D002 Professor 1 1 manage (0,1) (1,1) Department Each Professor may manage 0 to 1 department, Each Department should be managed by only one Professor. 39

Multiplicity Professor teach Section P1 r1 3C01 P2 r2 3C03 P3 r3 3C02 Professor 1 teach Each Professor may teach 0 to 5 Sections, Each Section should be taught by only one Professor. * = many.. Use it if the number is not specified M (0,5) (1,1) (0,*) Section 40

Multiplicity Student Student Enroll-in Course S1 r1 is300 S2 r2 is400 S3 r3 is500 S4 r4 is600 M Enroll-in Each student should enroll in 1 to 7 Courses, Each Course may be enrolled by 0 to 100 students. * = many.. Use it if the number is not specified M (1,7) (0,100) (1,*) (0,*) Course 41

Participation Participation constraints determine whether all or only some entities participate in a relationship. Two type of participation: Mandatory (Total) Optional (Partial) 42

Participation Optional (partial) (0:*) if an entity s existence does not require a corresponding entity in a particular relationship. (Not existence-dependent). eg, an employee may not have a spouse not every staff manages a department Partial participation is represented by single line Mandatory (total) (1:*) if an entity s existence requires the existence of an associated entity in a particular relationship (existence-dependent). eg, every spouse must be that of an employee Every department is managed by some staff. Mandatory participation is represented by double line R R E E 43

Examples employee 1 1 has spouse CUSTOMER 1 N place (0,M) (1,1) ORDER STUDENT M (1:M) enrol (0:N) N SUBJECT 44

Lecture1 45

Strong & Weak Entity Type A strong entity type is an entity that have a key attribute. (I.e. It exists independently of other entity types) A weak entity type is an entity that does not have a key attribute. (I.e. Its existence depend on some other entity type) The entity type which the weak entity type depends on is called the identifying entity type (owner).e.g EMPLOYEE Weak entities are identified by the combination of: A partial key of the weak entity type. The primary key of the owner entity type. 46

Representing Weak Entities and Relationships Weak entity is indicated by a double line rectangle, and weak relationship is represented by a double line diamond. Employee 1 Has M Dependent Participation of weak entity in weak relationship is always mandatory. 47

Weak Entity Type The relationship between the weak entity and its owner entity is called weak relationship. Eg: Employee Has Dependent Dependent can be regarded as a weak entity only when the attributes of Dependent can not uniquely identify a dependent. Eg, Dependent has the attributes d_name and d_birthdate only, but two employees may have dependents with the same name and date of birth. However employee_no and d_name uniquely identify each dependent. Employee is the owner entity Has is the weak relationship 48

Weak Entity Type SSN Salary Name Sex EMPLOYEE 1 N DEPENDENTS -OF DEPENDENT BDate Relationship 49

Modelling with E-R Diagram List the major entity sets in the system Represent the entity sets graphically by a rectangle Search for relationships between the entities and represent them graphically by a diamond Add attributes, underline PK attribute/s Model relationship cardinality and participation 50

Summary of Notation For ER-Diagrams Symbol Meaning ENTITY TYPE WEAK ENTITY TYPE RELATIONSHIP TYPE IDENTIFYING RELATIONSHIP TYPE ATTRIBUTE KEY ATTRIBUTE MULTIVALUED ATTRIBUTE COMPOSITE ATTRIBUTE DERIVED ATTRIBUTE E 1 E 1 1 R E 2 N R E 2 TOTAL PARTICIPATION OF E2 in R CARDINALITY RATIO 1:N FOR E1:E2 IN E 51 R (min,max) E STRUCTURAL CONSTRAINT (min, max) ON PARTICIPATION OF E IN R

Example (Company) The COMPANY database keeps track of a company s employees, departments and projects. The company is organized into departments. Each department has a unique number, name, several locations, and a particular employee who manages the department. We keep track of the start date when that employee began managing the department. Each department may control many projects. However, Each project should be controlled by one department only. Project has a unique number, name, and a single location. 52

Example (Company) We store each employee s name, social security number, address, salary, sex, and birth date. An employee should be assigned to one department only but each department must have many employees. Each employee should work on several projects and each project should run by many employees. We keep track of the number of hours per week that an employee works on each project. We also keep track of the direct supervisor of each employee. 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. 53

54

Tool For Drawing ER Diagrams In Oracle software 55

Lecture1 56

Lecture2 References Database Systems: A Practical Approach to Design, Implementation and Management. Thomas Connolly, Carolyn Begg. 5 th Edition, Addison-Wesley, 2009. 57