The Entity-Relationship Model. Overview of Database Design

Similar documents
Conceptual Design Using the Entity-Relationship (ER) Model

The Entity-Relationship Model

The Entity-Relationship Model

Databases Model the Real World. The Entity- Relationship Model. Conceptual Design. Steps in Database Design. ER Model Basics. ER Model Basics (Contd.

Review: Participation Constraints

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

Outline. Data Modeling. Conceptual Design. ER Model Basics: Entities. ER Model Basics: Relationships. Ternary Relationships. Yanlei Diao UMass Amherst

The Relational Model. Ramakrishnan&Gehrke, Chapter 3 CS4320 1

Lecture 6. SQL, Logical DB Design

Winter Winter

Introduction to Database Systems CS4320/CS5320. CS4320/4321: Introduction to Database Systems. CS4320/4321: Introduction to Database Systems

Database Design Overview. Conceptual Design ER Model. Entities and Entity Sets. Entity Set Representation. Keys

2. Conceptual Modeling using the Entity-Relationship Model

CSC 742 Database Management Systems

Data Modeling. Database Systems: The Complete Book Ch ,

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

not necessarily strictly sequential feedback loops exist, i.e. may need to revisit earlier stages during a later stage

OVERVIEW 1.1 DATABASE MANAGEMENT SYSTEM (DBMS) DEFINITION:-

Chapter 2: Entity-Relationship Model. Entity Sets. " Example: specific person, company, event, plant

Why Is This Important? Schema Refinement and Normal Forms. The Evils of Redundancy. Functional Dependencies (FDs) Example (Contd.)

Review Entity-Relationship Diagrams and the Relational Model. Data Models. Review. Why Study the Relational Model? Steps in Database Design

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

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

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

IV. The (Extended) Entity-Relationship Model

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

ER modelling, Weak Entities, Class Hierarchies, Aggregation

DATABASE DESIGN. - Developing database and information systems is performed using a development lifecycle, which consists of a series of steps.

Database Design Process

Database Design Process. Databases - Entity-Relationship Modelling. Requirements Analysis. Database Design

Foundations of Information Management

COMP 378 Database Systems Notes for Chapter 7 of Database System Concepts Database Design and the Entity-Relationship Model

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Chapter 4. Entity: an object that is involved in the enterprise

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #5: En-ty/Rela-onal Models- - - Part 1

Foundations of Information Management

Schema Refinement and Normalization

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

Chapter 8 The Enhanced Entity- Relationship (EER) Model

Entity-Relationship Model. Purpose of E/R Model. Entity Sets

Lecture 12: Entity Relationship Modelling

Relational Schema Design

Databases and BigData

Database Design Process

Chapter 2: Entity-Relationship Model

XV. The Entity-Relationship Model

Entity Relationship Diagram

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

CSCI-GA Database Systems Lecture 7: Schema Refinement and Normalization

Relational model. Relational model - practice. Relational Database Definitions 9/27/11. Relational model. Relational Database: Terminology

11 November

LiTH, Tekniska högskolan vid Linköpings universitet 1(7) IDA, Institutionen för datavetenskap Juha Takkinen

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

Reverse Engineering of Relational Databases to Ontologies: An Approach Based on an Analysis of HTML Forms

We know how to query a database using SQL. A set of tables and their schemas are given Data are properly loaded

Database Design. Goal: specification of database schema Methodology: E-R Model is viewed as a set of

Basics of Dimensional Modeling

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Implementing evolution: Database migration

Modern Systems Analysis and Design

A brief overview of developing a conceptual data model as the first step in creating a relational database.

BİL 354 Veritabanı Sistemleri. Entity-Relationship Model

The Entity-Relationship Model

Rose Data Modeler (logical)

ER & EER to Relational Mapping. Chapter 9 1

Database Design Methodologies

Databases What the Specification Says

The E-R èentity-relationshipè data model views the real world as a set of basic objects èentitiesè and

A Tool for Generating Relational Database Schema from EER Diagram

Database Design Methodology

DATABASE INTRODUCTION

Fundamentals of Database System

Database Management Systems. Chapter 1

Database IST400/600. Jian Qin. A collection of data? A computer system? Everything you collected for your group project?

Requirement Analysis & Conceptual Database Design. Problem analysis Entity Relationship notation Integrity constraints Generalization

CS2Bh: Current Technologies. Introduction to XML and Relational Databases. The Relational Model. The relational model

DATABASE MANAGEMENT SYSTEMS. Question Bank:

2. Supports eæcient access to very large amounts

Requirements are elicited from users and represented either informally by means of proper glossaries or formally (e.g., by means of goal-oriented

Lesson 8: Introduction to Databases E-R Data Modeling

Answers to Review Questions

Concepts of Database Management Seventh Edition. Chapter 9 Database Management Approaches

Relational Algebra and SQL

Entity-Relationship Model

WHITE PAPER TOPIC DATE Enabling MaaS Open Data Agile Design and Deployment with CA ERwin. Nuccio Piscopo. agility made possible

THE OPEN UNIVERSITY OF TANZANIA FACULTY OF SCIENCE TECHNOLOGY AND ENVIRONMENTAL STUDIES BACHELOR OF SIENCE IN INFORMATION AND COMMUNICATION TECHNOLOGY

Data Modeling: Part 1. Entity Relationship (ER) Model

Unit 2.1. Data Analysis 1 - V Data Analysis 1. Dr Gordon Russell, Napier University

SQL DDL. DBS Database Systems Designing Relational Databases. Inclusion Constraints. Key Constraints

Data Modeling Basics

IT2305 Database Systems I (Compulsory)

Database Design Methodology

The University of British Columbia

Designing a Database Schema

Object-Oriented Data Modeling

Questions? Assignment. Techniques for Gathering Requirements. Gathering and Analysing Requirements

Concepts of Database Management Seventh Edition. Chapter 6 Database Design 2: Design Method

Iteration 3 Kick Off, Domain Model Refinement. Curt Clifton Rose-Hulman Institute of Technology

Overview. Physical Database Design. Modern Database Management McFadden/Hoffer Chapter 7. Database Management Systems Ramakrishnan Chapter 16

Transcription:

The Entity-Relationship Model Chapter 2 Database Management Systems, R. Ramakrishnan and J. Gehrke 1 Overview of Database Design Requirements Analysis What data are to be stored in the enterprise? What are the required applications? What are the most important operations? Conceptual database design What are the entities and relationships in the enterprise? What information about these entities and relationships should we store in the database? What are the integrity constraints or business rules that hold? ER model to represent conceptual schema Database Management Systems, R. Ramakrishnan and J. Gehrke 2

Overview of Database Design Logical database design What data model should be used to implement the DBS? What DBMS to use? Map the conceptual schema (ER diagram) to a database schema of the chosen data model. Physical database design What are the typical workloads of the DBS? Build appropriate indexes to support efficient query processing. What redesign of the logical database schema is necessary from the point of view of efficient implementation? Database Management Systems, R. Ramakrishnan and J. Gehrke 3 The Entity-Relationship Model Short: ER model Basic Components Entities Attributes Relationships Constraints Database Management Systems, R. Ramakrishnan and J. Gehrke 4

ER Model Basics Entity: Real-world object distinguishable from other objects. An entity is described (in DB) using a set of attributes. Entity Set: A collection of similar entities. E.g., all employees. Database Management Systems, R. Ramakrishnan and J. Gehrke 5 ER Model Basics (contd.) All entities in an entity set have the same set of attributes. (At least, for the moment!) Each entity set has a key, i.e. a minimal set of attributes to uniquely identify an entity of this set. Each attribute has a domain, i.e. a set of all possible attribute values. Database Management Systems, R. Ramakrishnan and J. Gehrke 6

ER Model Basics (Contd.) Relationship: Association among two or more entities. E.g., Attishoo works in Pharmacy department. Relationship Set: Collection of similar relationships among two or more entity sets. d Works_In Database Management Systems, R. Ramakrishnan and J. Gehrke 7 ER Model Basics (Contd.) An n-ary relationship set R relates n entity sets E1... En. Each relationship in R involves entities e1 E1,..., en En. Same entity set could participate in different relationship sets, or in different roles in same set. subordinate supervisor Reports_To Database Management Systems, R. Ramakrishnan and J. Gehrke 8

Cardinalities of Relationships An employee can work in many departments; a dept can have many employees. Works_In d Each dept has at most one manager, who may manage several (many) departments. Manages d Database Management Systems, R. Ramakrishnan and J. Gehrke 9 Cardinalities of Relationships The different types of relationships, from a cardinalities point of view: 1 to 1 1 to many Many to 1 Many to many 1-to-1 1-to Many Many-to-1 Many-to-Many Database Management Systems, R. Ramakrishnan and J. Gehrke 10

Key Constraints A key constraint on a relationship set specifies that the marked entity set participates in at most one relationship of this relationship set. d Manages Database Management Systems, R. Ramakrishnan and J. Gehrke 11 Participation Constraints A participation constraint on a relationship set specifies that the marked entity set participates in at least one relationship of this relationship set. The participation of in Manages is said to be total (vs. partial). d Manages Works_In Database Management Systems, R. Ramakrishnan and J. Gehrke 12

Weak Entities A weak entity exists only in the context of another (owner) entity. The weak entity can be identified uniquely only by considering the primary key of the owner and its own partial key. Owner entity set and weak entity set must participate in a one-tomany relationship set (one owner, many weak entities). Weak entity set must have total participation in this identifying relationship set. cost age Policy Dependents Database Management Systems, R. Ramakrishnan and J. Gehrke 13 ISA Hierarchies hourly_wages hours_worked ISA contractid Class (Entity set) hierarchies Hourly_Emps A ISA B: every A entity is also considered to be a B entity. A specializes B, B generalizes A. A is the subclass, B is the superclass. Contract_Emps A subclass inherits the attributes of a superclass, and may define additional attributes. Database Management Systems, R. Ramakrishnan and J. Gehrke 14

ISA Hierarchies (contd.) Overlap constraints: Can Joe be an Hourly_Emps as well as a Contract_Emps entity? (Hourly_Emps OVERLAPS Contract_Emps) Covering constraints: Does every entity have to be either an Hourly_Emps or a Contract_Emps entity? Hourly_Emps AND Contract_Emps COVER Database Management Systems, R. Ramakrishnan and J. Gehrke 15 ISA Hierarchies (contd.) Reasons for using ISA: Do not have to redefine all the attributes. To add descriptive attributes specific to a subclass. To identify entitities that participate in a relationship as precisely as possible. Database Management Systems, R. Ramakrishnan and J. Gehrke 16

Aggregation Used when we have to model a relationship involving relationships. pid Monitors until started_on d p Projects Sponsors Aggregation allows us to treat a relationship set as an entity set for purposes of participation in (other) relationships. Database Management Systems, R. Ramakrishnan and J. Gehrke 17 Aggregation (contd.) Monitors until Aggregation vs. ternary relationship pid started_on p Projects Sponsors d Monitors is a distinct relationship, with a descriptive attribute. Also, can say that each sponsorship is monitored by at most one employee. Database Management Systems, R. Ramakrishnan and J. Gehrke 18

Conceptual Design Using the ER Model Design choices Should a concept be modeled as an entity or an attribute? Should a concept be modeled as an entity or a relationship? Identifying relationships: Binary or ternary? Aggregation? Constraints A of data semantics can (and should) be captured. But some constraints cannot be captured in ER diagrams. Database Management Systems, R. Ramakrishnan and J. Gehrke 19 Entity vs. Attribute Should address be an attribute of or an entity (connected to by a relationship)? Depends upon the use we want to make of address information, and the semantics of the data: If we have several addresses per employee, address must be an entity ( attributes cannot be set-valued). If the structure (city, street, etc.) is important, e.g., we want to retrieve employees in a given city, address must be modeled as an entity ( attribute values are atomic). Database Management Systems, R. Ramakrishnan and J. Gehrke 20

Entity vs. Attribute (Contd.) Works_In2 does not allow an employee to work in the same department for two or more periods (why?). from to Works_In2 d We want to record several values of the descriptive attributes for each instance of this relationship. from Works_In3 Duration to d Database Management Systems, R. Ramakrishnan and J. Gehrke 21 Entity vs. Relationship d d Manages2 This ER diagram OK if a manager gets a separate discretionary for each dept. But what if a manager gets a discretionary that covers all managed depts? Redundancy of d, which is stored for each dept managed by the manager. Misleading: suggests d tied to managed dept. Database Management Systems, R. Ramakrishnan and J. Gehrke 22

Entity vs. Relationship (contd.) What about this diagram? d d Manages2 The following ER diagram is more appropriate and avoids the above problems! apptnum d Manages3 Mgr_Appts d Database Management Systems, R. Ramakrishnan and J. Gehrke 23 Binary vs. Ternary Relationships p age Covers Dependents Policies policyid cost If each policy is owned by just 1 employee: Key constraint on Policies would mean policy can only cover 1 dependent! Bad design! Database Management Systems, R. Ramakrishnan and J. Gehrke 24

Binary vs. Ternary Relationships (contd.) This diagram is a better design. What are the additional constraints in the 2nd diagram? Purchaser p age Dependents Beneficiary Policies policyid cost Database Management Systems, R. Ramakrishnan and J. Gehrke 25 Binary vs. Ternary Relationships (Contd.) Previous example illustrated a case when two binary relationships were better than one ternary relationship. An example in the other direction: a ternary relation Contracts relates entity sets Parts, and Suppliers, and has descriptive attribute qty. No combination of binary relationships is an adequate substitute: S can-supply P, D needs P, and D deals-with S does not imply that D has agreed to buy P from S. How do we record qty? Database Management Systems, R. Ramakrishnan and J. Gehrke 26

Summary Conceptual design follows requirements analysis, Yields a high-level description of data to be stored. ER model popular for conceptual design Constructs are expressive, close to the way people think about their applications. Basic constructs: entities, relationships, and attributes (of entities and relationships). Some additional constructs: weak entities, ISA hierarchies, and aggregation. Note: There are many variations on ER model. Database Management Systems, R. Ramakrishnan and J. Gehrke 27 Summary (contd.) Several kinds of integrity constraints can be expressed in the ER model: key constraints, participation constraints, and overlap/covering constraints for ISA hierarchies. Some foreign key constraints are also implicit in the definition of a relationship set. Some constraints (notably, functional dependencies) cannot be expressed in the ER model. Constraints play an important role in determining the best database design for an enterprise. Database Management Systems, R. Ramakrishnan and J. Gehrke 28

Summary (contd.) ER design is subjective. There are often many ways to model a given scenario! Analyzing alternatives can be tricky, especially for a large enterprise. ER diagrams are later mapped to schema of the chosen data model, e.g. relational model. Ensuring good database design: resulting relational schema should be analyzed and refined further. FD information and normalization techniques are especially useful. Database Management Systems, R. Ramakrishnan and J. Gehrke 29