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

Similar documents
Step 2: Map ER Model to Tables

Chapter 12. Entity-Relationship Modeling

Step 1: Create and Check ER Model

Chapter 4. The Relational Model

COMP102: Introduction to Databases, 9.1

Conceptual Design. The Entity-Relationship (ER) Model

Database Normalization

Introduction to Database Design. Dr. Kanda Runapongsa Dept of Computer Engineering Khon Kaen University

Introduction to Relational Databases. Introduction to Relational Databases cont: Introduction to Relational Databases cont: Relational Data structure

LECTURE 3: ENTITY-RELATIONSHIP MODELING

CSE 530A. ER Model. Washington University Fall 2013

High-Level Database Models (ii)

Lecture3: Data Modeling Using the Entity-Relationship Model.

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

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

The Relational Model

High Level Database Models

Data Modeling. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

Database Management System (15ECSC208) UNIT I: Chapter 2: Relational Data Model and Relational Algebra

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

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

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

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

Database Management System 6 ER Modeling...

Introduction to Database Design

A l Ain University Of Science and Technology

Step 4: Choose file organizations and indexes

Relational Model. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan

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

The Relational Model 2. Week 3

MIT Database Management Systems Lesson 03: Entity Relationship Diagrams

From ER to Relational Model. Book Chapter 3 (part 2 )

COSC 304 Introduction to Database Systems. Entity-Relationship Modeling

MIS Database Systems Entity-Relationship Model.

A l Ain University Of Science and Technology

CMP-3440 Database Systems

Chapter 3. The Relational database design

The Relational Model

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

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

RELATIONAL DATA MODEL

The Relational Model

CSE 530A. ER Model to Relational Schema. Washington University Fall 2013

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

Database Systems. Lecture2:E-R model. Juan Huo( 霍娟 )

Relational Data Model

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

SOLUTIONS TO REVIEW QUESTIONS AND EXERCISES FOR PART 3 - DATABASE ANALYSIS AND DESIGN (CHAPTERS 10 15)

Introduction to Databases

CS 405G: Introduction to Database Systems

Introduction to Database Design

The Relational Model. Chapter 3

The Entity Relationship Model

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

Relational Model. Topics. Relational Model. Why Study the Relational Model? Linda Wu (CMPT )

The Relational Model. Chapter 3. Database Management Systems, R. Ramakrishnan and J. Gehrke 1

Represent entities and relations with diagrams

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

Relational Model History. COSC 416 NoSQL Databases. Relational Model (Review) Relation Example. Relational Model Definitions. Relational Integrity

The Entity-Relationship (ER) Model 2

Entity Relationship Modeling

Relational Database Systems Part 01. Karine Reis Ferreira

Entity-Relationship Models 2. Connolly/Begg Chapter 11

CS403- Database Management Systems Solved Objective Midterm Papers For Preparation of Midterm Exam

The Basic (Flat) Relational Model. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

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

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

The Relational Model. Why Study the Relational Model? Relational Database: Definitions

Advance Database Management System

Chapter 17. Methodology Logical Database Design for the Relational Model

4. Entity Relationship Model

CSIT5300: Advanced Database Systems

OVERVIEW OF DATABASE DEVELOPMENT

Elements of the E-R Model

The Relational Model. Chapter 3. Comp 521 Files and Databases Fall

Database Management Systems LECTURE NOTES 2

Chapter 2 Conceptual Modeling. Objectives

Running Example Tables name location

Translation of ER-diagram into Relational Schema. Dr. Sunnie S. Chung CIS430/530

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

Chapter 4. In this chapter, you will learn:

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

Data Modeling Using the Entity-Relationship (ER) Model

The Relational Model (ii)

Entity-Relationship Models

Let s briefly review important EER inheritance concepts

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

Conceptual Data Modeling

Sahaj Computer Solutions. Data Modeling using the Entity Relationship Model

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

Data Modeling Using the Entity-Relationship Model

Entity Relationship Modelling

Review The Big Picture

Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

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

Database Applications (15-415)

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

Database Applications (15-415)

Lecture 03. Fall 2017 Borough of Manhattan Community College

The Entity-Relationship Model. Overview of Database Design

Transcription:

ER Model Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Dept of Computer Engineering Khon Kaen University Objectives (1/2) Relational Data Model Terminology of relational data model How tables are used to represent data Properties of database relations How to identify candidate, primary, and foreign keys Meaning of entity integrity and referential integrity 2 Objectives (2/2) How to use ER modeling in database design The basic concepts of an ER model A diagrammatic technique for displaying an ER model How to identify and solve problems in an ER model 3 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 1

Data Model Integrated collection of concepts for describing data, relationships between data, and constraints on the data Has three components A structural part A manipulative part A set of integrity rules 4 Relational Model Terminology Relation: table with columns and rows Attribute: named column of a relation Domain: set of allowable values for one or more attributes Tuple: a record of a relation Relational database collection of normalized relations with distinct relation names 5 RM Terminology Samples 6 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 2

Attribute Domain Samples 7 Alternative Terminology Relation, table Attribute, column, field Tuple, record, row 8 Properties of Relations (1/2) Table name is distinct from all other table names in the database Each cell of table contains exactly one atomic (single) value Each column has a distinct name Values of a column are all from the same domain 9 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 3

Properties of Relations (2/2) Each record is distinct; there are no duplicate records Order of columns has no significance Order of records has no significance 10 Relational Keys (1/2) Superkey A column, or a set of columns, that uniquely identifies a record within a table Candidate Key Superkey (K) such that no proper subset is a superkey within the table In each record, values of K uniquely identify that record (uniqueness) No proper subset of K has the uniqueness property (irreduciability) 11 Relational Keys (2/2) Primary Key Candidate key selected to identify records uniquely within table Alternate Keys Candidate keys that are not selected to be primary key Foreign Key Column, or set of columns, within one table that matches candidate key of some (possibly same) table 12 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 4

Relational Integrity (1/2) Null Represents value for a column that is currently unknown or not applicable for record Deals with incomplete or exceptional data Represents the absence of a value and is not the same as zero or spaces, which are values 13 Relational Integrity (2/2) Entity Integrity Every table must have a primary key Column or columns chosen to be the primary key should be unique and not null Referential Integrity If FK exists in a table, FK value must match a candidate key value of some record in its home table 14 Referential Integrity Broken There is a foreign key (artist_id) value in the album table that references a non-existent artist This anomaly came about when the record for an artist called "Aerosmith", with an artist_id of "4", was deleted from the artist table, even though the album "Eat the rich" 15 referred to this artist Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 5

Referential Integrity Enforced If referential integrity had been enforced The deletion of the main record would have been possible, but its associated record would have been deleted as well Alternatively, the existence of an associated record would not allow the delete operation of the referenced record, and instead return an error code. 16 Objectives (2/2) How to use ER modeling in database design The basic concepts of an ER model A diagrammatic technique for displaying an ER model How to identify and solve problems in an ER model 17 ER Modeling Top-down approach to database design Start by identifying the important data (called entities) and relationships between the data Then add more details Attributes of entities and relationships Constraints on entities, relationships, and attributes 18 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 6

Entities Entity A set of objects with the same properties, which are identified by a user or organization as having an independent existence Entity occurrence Each uniquely identifiable object within a set 19 Entities with Physical and Conceptual Existence 20 ER Diagram of Entity Entity Diagram Use a rectangle to represent an entity Insert the entity name inside the rectangle Example Video 21 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 7

Attributes Property of an entity or a relationship Hold values that describe each occurrence of an entity or relationship Represent the main source of data stored in the database 22 ER Diagram of Attributes Attribute Diagram Use an oval to represent an attribute Insert the attribute name inside the oval Video catalogno category price title dailyrental 23 Classification of Attributes Attributes can be classified as being Simple or composite Single-valued or multi-valued Derived 24 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 8

Attributes (1/3) Simple attribute Attribute composed of a single component Example: salary Composite attribute Attribute composed of multiple components Example: name (firstname, lastname) 25 Attributes (2/3) Single-valued attribute Attribute that holds a single value for an entity occurrence Example: gender (M, F) Multi-valued attribute Attribute that holds multiple values for an entity occurrence Example: phone:area-code,number (043-362-160) 26 Attributes (3/3) Derived attribute Attribute that represents a value that is derivable from value of a related attribute, or set of attributes, not necessarily in the same entity Example: age which can be derived from birthdate 27 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 9

Example: Entity ER diagram of an entity Employees ssn name Staff lot The key of this entity is ssn which is underlined Entity set Staff ssn name lot 111 A 12 222 B 24 Entity 111 A 12 is similar to Entity 222 B 24 since both of them are described using the same set of attributes 28 Relationships Relationship A set of meaningful associations among entities Relationship occurrence Each uniquely identifiable association within a set 29 ER Diagram of Relationships 30 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 10

Degree of a Relationship Degree of a relationship is the number of participating entities in relationship Relationship of degree Two is binary Three is ternary Four is quaternary 31 Example of ternary relationship 32 Recursive relationships Relationship where same entity participates more than once in different roles Relationships may be given role names to indicate purpose that each participating entity plays in a relationship 33 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 11

Example of a recursive relationship 34 Example1: Relationships A relationship between Employees and Departments ssn name lot since did dname budget Employees Works_In Departments since is a descriptive attribute of this relationship A relationship must be uniquely identified by the participating entities 35 Example2: Relationships Same entity set could participate in different relationship sets, or in different roles in same set. name Manages ssn lot Employees Employees Works_In Departments supervisor super-visee Reports_To 36 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 12

Multiplicity constraints on relationships Represents the number of occurrences of one entity that may relate to a single occurrence of an associated entity Represents policies (called business rules) established by user or company 37 Multiplicity constraints The most common degree for relationships is binary Binary relationships are generally referred to as being One-to-one (1:1) One-to-many (1:*) Many-to-many (*:*) 38 1:1 relationship individual examples 39 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 13

1:1 relationship - multiplicity 40 1:* relationship individual examples 41 1:* relationship multiplicity 42 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 14

*:* relationship individual examples 43 *:* relationship - multiplicity 44 Complex relationships individual examples 45 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 15

Complex relationship - multiplicity 46 Summary of multiplicity constraints 47 Cardinality and Participation Constraints Cardinality Describe the number of possible relationships for each participating entity Participation Determine whether all or only some entity occurrences participate in a relationship 48 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 16

Cardinality and Participation Constraints Examples 49 Relationship with attributes 50 Strong and weak entities Strong entity Entity that is not dependent on the existence of another entity for its primary key Weak entity Entity that is partially or wholly dependent on the existence of another entity, or entities, for its primary key 51 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 17

Weak Entities A weak entity can be identified uniquely only by considering the primary key of another (owner) entity Owner entity set and weak entity set must participate in a one-to-many relationship set (one owner, many weak entities) Weak entity set must have total participation in this identifying relationship set 52 Example: Weak Entities Employees is an owner entity set and Dependents is a weak entity set Dependents have total participation in the relationship name ssn lot cost pname age Employees Policy Dependents 53 Problems with ER models Problems may arise when designing an ER model called connection traps Often due to a misinterpretation of the meaning of certain relationships Two main types of connection traps Fan traps Chasm traps 54 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 18

Fan trap Two entities have a 1:* relationship that fan out from a third entity But the two entities should have a direct relationship between them to provide the necessary information 55 An example of a fan trap 56 Fan trap individual example Cannot tell which member of staff uses car SH34 57 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 19

Resolving the fan trap 58 Fan trap resolved individual example Can now tell which car staff use 59 Chasm trap A model suggests the existence of a relationship between entities But the pathway does not exist between certain entity occurrences 60 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 20

An example of a chasm trap 61 Chasm trap individual example Cannot tell which branch staff S0003 works at 62 Resolving the chasm trap 63 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 21

Chasm trap resolved individual example Can now tell which branch each member of staff works at. 64 Summary (1/2) ER model popular for conceptual design Constructs are expressive, close to the way people think about their applications Basic constructs of ER model Entities Relationships Attributes (of entities and relationships) 65 Summary (2/2) Superkey A column, or a set of columns, that uniquely identifies a record within a table Candidate Key Superkey (K) such that no proper subset is a superkey within the table Entity Integrity Every table must have a primary key Referential Integrity If FK exists in a table, FK value must match a candidate key value of some record in its home table 66 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 22

References (1/2) Connolly and Begg, Database Systems: A Practical Approach to Design, Implementation and Management, Pearson, 2004 http://en.wikipedia.org/wiki/entity_inte grity http://en.wikipedia.org/wiki/referentia l_integrity 67 References (2/2) http://www.docstoc.com/docs/421235 1/E-R-Diagram-(Entity-Relationship- Diagram) 68 Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 23