Intro to DB CHAPTER 6

Similar documents
Chapter 2: Entity-Relationship Model

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

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

Chapter 6: Entity-Relationship Model

Chapter 6: Entity-Relationship Model

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

Chapter 6: Entity-Relationship Model

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

Example: specific person, company, event, plant

Entity-Relationship Model

Chapter 6: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

Chapter 7: Entity-Relationship Model

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

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

6.1 RELATIONSHIP CONCEPTS

CSIT5300: Advanced Database Systems

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

The En'ty Rela'onship Model

CSCC43H: Introduction to Databases

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

COMP Instructor: Dimitris Papadias WWW page:

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

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

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

The Entity Relationship Model

A l Ain University Of Science and Technology

Unit1: Introduction. Database System Concepts, 6 th Ed. Silberschatz, Korth and Sudarshan See for conditions on re-use

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

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

Conceptual Data Modeling

A l Ain University Of Science and Technology

Database Management Systems LECTURE NOTES 2

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

UNIT II A. ENTITY RELATIONSHIP MODEL

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

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

Major components of ER diagram Practices

Chapter 9: Relational DB Design byer/eer to Relational Mapping Relational Database Design Using ER-to- Relational Mapping Mapping EER Model

Entity Relationship Data Model. Slides by: Shree Jaswal

VARDHAMAN COLLEGE OF ENGINEERING Shamshabad , Hyderabad B.Tech. CSE IV Semester (VCE - R11) T P C 3+1* -- 4 (A1511) DATABASE MANAGEMENT SYSTEMS

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

Overview of db design Requirement analysis Data to be stored Applications to be built Operations (most frequent) subject to performance requirement

Lecture 10 - Chapter 7 Entity Relationship Model


Data Modeling Using the Entity-Relationship (ER) Model

More on the Chen Notation

Database Management System 6 ER Modeling...

MIS Database Systems Entity-Relationship Model.

Database Applications (15-415)

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

CS 405G: Introduction to Database Systems

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

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

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

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

High Level Database Models

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

Data Modeling and the Entity-Relationship Model

Entity-Relationship Model &

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

Lecture3: Data Modeling Using the Entity-Relationship Model.

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

CMPT 354 Database Systems I

LECTURE 3: ENTITY-RELATIONSHIP MODELING

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

SE 4DB3 TUTORIAL 2: REDUCTION TO RELATIONAL SCHEMAS

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

Conceptual Design. The Entity-Relationship (ER) Model

Conceptual Data Models for Database Design

Advance Database Management System

The Entity-Relationship Model. Steps in Database Design

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

ER to Relational Mapping

Chapter 2 ENTITY RELATIONSHIP MODEL

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

Introduction to Data Management. Lecture #3 (Conceptual DB Design) Instructor: Chen Li

Unit I. By Prof.Sushila Aghav MIT

Databases Tutorial. January 19,2012 Jing Chen Mcmaster University

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

Copyright 2016 Ramez Elmasr and Shamkant B. Navathei

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

IS 263 Database Concepts

Conceptual Modeling in ER and UML

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

The Entity-Relationship Model

CS352 Lecture - The Entity-Relationship Model

1. Considering functional dependency, one in which removal from some attributes must affect dependency is called

Chapter 3 Database Modeling and Design II. Database Modeling

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

COSC 304 Introduction to Database Systems. Entity-Relationship Modeling

CSE 880:Database Systems. ER Model and Relation Schemas

The Entity-Relationship Model. Overview of Database Design. ER Model Basics. (Ramakrishnan&Gehrke, Chapter 2)

OVERVIEW OF DATABASE DEVELOPMENT

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

Chapter (4) Enhanced Entity-Relationship and Object Modeling

Chapter 2 Conceptual Modeling. Objectives

Module 2 : Entity-Relationship Model 15

Transcription:

Intro to DB CHAPTER 6 DATABASE DESIGN &THEER E-R MODEL

Chapter 6. Entity Relationship Model Design Process Modeling Constraints E-R Diagram Design Issues Weak Entity Sets Extended E-R Features Design of the Bank Database Reduction to Relation Schemas Database Design UML Copyright 2006-2008 by S.-g. Lee Chap 6-2

Introduction Proposed by P. Chen in 1976 The Entity-Relationship Model: Toward a Unified View of Data, ACM Transactions On Database Systems, Jan.1976. A very powerful tool in the design of databases Simple model Effective means of communication between user, designer, and implementer E-R model is not an implementation model i.e., there is no DBMS whose internal structures are based on the E-R model Copyright 2006-2008 by S.-g. Lee Chap 6-3

Database Modeling A database can be modeled as: a collection of entities, relationship among entities. An entity is an object that exists and is distinguishable from other objects (entity instance). Example: specific person, company, event, plant Entities have attributes t Example: people have names and addresses An entity set is a set of entities i of the same type that share the same properties. Example: set of all persons, companies, trees, holidays Copyright 2006-2008 by S.-g. Lee Chap 6-4

Entity & Entity Sets - examples customer-id customer- customer- customer- loan- amount name street city number Copyright 2006-2008 by S.-g. Lee Chap 6-5

Attributes The descriptive properties p of an entity An entity is represented by a set of attributes Student = (id, name, dept, address, ) Value set (domain) set of permitted values for an attribute Formally: Attribute is a mapping from the entity set to the value set Domain1 Entity Set1 e1 e2 e3 Domain2 A1 e4 A2 Copyright 2006-2008 by S.-g. Lee Chap 6-6

Types of Attributes Simple vs Composite attributes Simple attribute values cannot be divided into subparts firstname, lastname, phone# Composite attribute composed of multiple parts name = (lastnm, firstnm) Phone# = (number, extension) Null attributes null value: a special ilvalue meaning missing i or unknown some attributes are not allowed to have null values Copyright 2006-2008 by S.-g. Lee Chap 6-7

Types of Attributes (cont.) Single-valued vs multivalued : Single-valued attribute each attribute has a single value for an entity id, name, dept Multivalued attribute an attribute may have more than one value for an instance children = {john, tom}, phone#={5567, 5568} Derived attributes value can be derived from the values of other related attributes or entities duration, count, sum, Copyright 2006-2008 by S.-g. Lee Chap 6-8

Relationships Relationships are defined between entities Relationship set: R = { [e 1,..., e n ] e 1 E 1,,ee n E n } E i : entity set, [e 1,..., e n ] : relationship Entity Set1 e1 e2 e3 e4 Relationship Set Entity Set2 f1 f2 f3 f4 f5 Copyright 2006-2008 by S.-g. Lee Chap 6-9

Relationship Set borrower Copyright 2006-2008 by S.-g. Lee Chap 6-10

Attribute of Relationship Relationships can have attributes An attribute can also be property of a relationship set. Copyright 2006-2008 by S.-g. Lee Chap 6-11

Mapping Constraints Relationship cardinality Number of entities to which another entity can be associated via a relationship set Generic types 1 : 1 1 : m m:1 m : n Relationship eato pcardinality a can affect the placement pace e tof relationship eato attributes Copyright 2006-2008 by S.-g. Lee Chap 6-12

Mapping Cardinalities One to one One to many Note: Some elements in A and B may not be mapped to any elements in the other set Copyright 2006-2008 by S.-g. Lee Chap 6-13

Mapping Cardinalities (cont.) Many to one Many to many Note: Some elements e e in A and B may not be mapped to any elements e e in the other set Copyright 2006-2008 by S.-g. Lee Chap 6-14

Mapping Cardinalities affect ER Design Can make access-date an attribute of account, instead of a relationship attribute, if each account can have only one customer Copyright 2006-2008 by S.-g. Lee Chap 6-15

E-R Diagrams Rectangles represent entity sets. Diamonds represent relationship sets. Lines link attributes to entity sets and entity sets to relationship sets. Ellipses represent attributes - Double ellipses represent multivalued li l attributes. - Dashed ellipses denote derived attributes. Underline indicates primary key attributes Copyright 2006-2008 by S.-g. Lee Chap 6-16

Attributes Copyright 2006-2008 by S.-g. Lee Chap 6-17

Relationship Sets with Attributes Copyright 2006-2008 by S.-g. Lee Chap 6-18

Roles Entity sets of a relationship need not be distinct Role labels are optional, and are used to clarify semantics of the relationship Copyright 2006-2008 by S.-g. Lee Chap 6-19

m-ary Relationships Most relationships are binary R = { [e 1, e 2 ] e 1 E 1, e 2 E 2 } You can define non-binary relationships R = { [e 1, e 2, e 3 ] e 1 E 1, e 2 E 2, e 3 E 3 } : ternary Copyright 2006-2008 by S.-g. Lee Chap 6-20

Cardinality Constraints Express cardinality constraints by a directed line ( ): signifying one an undirected line ( ): signifying many Copyright 2006-2008 by S.-g. Lee Chap 6-21

Many-To-Many yrelationship A customer is associated with several (possibly 0) loans via borrower A loan is associated with several (possibly 0) customers via borrower Copyright 2006-2008 by S.-g. Lee Chap 6-22

Participation in a Relationship Total participation p (indicated by double line): every entity in the entity set participates in at least one relationship in the relationship set Partial participation: some entities may not participate in any relationship in the relationship set Copyright 2006-2008 by S.-g. Lee Chap 6-23

Alternative Notation for Cardinality Cardinality limits can also express participation p constraints min.. max Copyright 2006-2008 by S.-g. Lee Chap 6-24

Weak Entity Sets Strong entity Regular entity with its own primary key Weak entity An entity set that does not have sufficient attributes to form a primary key B# Bus Seat S# Time Type A weak entity set is dependent on a strong entity set Primary key of a weak entity set = primary key of its dominant entity set + its descriminator B# + S# Copyright 2006-2008 by S.-g. Lee Chap 6-25

Weak Entity Sets (Cont.) Depict a weak entity set by double rectangles. Underline the discriminator with a dashed line. Primary key for payment (loan-number, payment-number) Copyright 2006-2008 by S.-g. Lee Chap 6-26

Existence Dependencies If the existence of entity x depends on the existence of entity yy, then x is said to be existence dependent on y. y is a dominant entity (in example below, loan) ) x is a subordinate entity (in example below, payment) loan loan-payment payment If a loan entity is deleted, then all its associated payment entities must be deleted eted also. Copyright 2006-2008 by S.-g. Lee Chap 6-27

Extended E-R Features Specialization The process of designating i subgroupings within ihi an entity set (ex. account - savings-account, checking account) a subentity will share common attributes asubentitywill have its own specific attributes Generalization combine a number of entity sets that share the same features into a higher-level entity set opp: specialization - depends on where you start Inheritance The attributes and relationships of the higher-level entity sets are inherited by (applies to) the lower-level entity sets Types of generalization (super-sub entities) Disjoint vs Overlapping: whether an entity can belong to more than two sub entity set Total vs Partial: whether every higher level entity belong to a lower level entity set Copyright 2006-2008 by S.-g. Lee Chap 6-28

Copyright 2006-2008 by S.-g. Lee Chap 6-29

E-R Notations Copyright 2006-2008 by S.-g. Lee Chap 6-30

Alternative E-R Notations Copyright 2006-2008 by S.-g. Lee Chap 6-31

UML Class Diagram Notation Copyright 2006-2008 by S.-g. Lee Chap 6-32

UML Class Diagram Notation (cont.) *Note reversal of position in cardinality constraint depiction Copyright 2006-2008 by S.-g. Lee Chap 6-33

Design Issues Entity vs Attribute an employee s telephone as an attribute : simple as an entity : independent Decision should be based on whether the telephone must be treated as an independent entity the number of telephones an employee can have whether telephones are shared between employees Entity vs Relationship "customer having an account at a branch" account as relationship : simple but limited (cannot participate in other relationships) account as entity : account can act as separate entity Copyright 2006-2008 by S.-g. Lee Chap 6-34

Design Issues (cont.) Binary vs n-ary relationships all n-ary relationships can be represented by binary relationships by adding additional entities and corresponding relationships however, this is not always desirable => decision should be based on how the model best represents the real world situation i Strong or weak entity set Generalization and specialization Aggregation g Copyright 2006-2008 by S.-g. Lee Chap 6-35

Design Phases Requirement specification identify data needs of user Conceptual design translate into a conceptual schema Logical design map onto the implementation data model of the DBMS Physical design specify physical features of the database (issues pertaining to performance rather than information contents; index, sequential order, etc.) Copyright 2006-2008 by S.-g. Lee Chap 6-36

Reducing ER schema to tables Basic rule each entity set => unique table each relationship set => unique table Strong entity set E with attributes a 1,..., a n table E with n distinct columns each of which corresponds to a i D i : set of all values (domain) for a i table E will contain elements of D 1 X...X D n Copyright 2006-2008 by S.-g. Lee Chap 6-37

ER schema to tables (cont.) A strong entity set reduces to a table with the same attributes. Copyright 2006-2008 by S.-g. Lee Chap 6-38

ER schema to tables (cont.) Relationship set R involving E 1,..., E k => table R with columns corresponding to PK(E 1 ) U... U PK(E k ) U attr(r) if one-to-many or one-to-one E 1 R E 2 => add columns representing PK(E 1 ) U attr(r) to table representing E 2 Copyright 2006-2008 by S.-g. Lee Chap 6-39

Representing Weak Entity Sets A weak entity set becomes a table that includes a column for the primary key of the identifying strong entity set Copyright 2006-2008 by S.-g. Lee Chap 6-40

Representing Relationship Sets many-to-many yrelationship set: as a table with the primary keys of the two participating entity sets + any descriptive attributes Copyright 2006-2008 by S.-g. Lee Chap 6-41

Redundancy of Tables Many-to-one and one-to-many relationship sets that are total on the many-side can be represented by adding an extra attribute to the many side, containing the primary key of the one side Copyright 2006-2008 by S.-g. Lee Chap 6-42

Generalization Account <= savings, checking General case Create a table for the higher level entity set For each subentity, create a table that includes the attributes of that entity set plus the primary key of the higher level entity savings checking If disjoint and complete account For each subentity, create a table that includes the attributes of that entity plus the super entity savings checking Copyright 2006-2008 by S.-g. Lee Chap 6-43

END OF CHAPTER 6