Overview. Introduction to Database Design. ER Model. Database Design

Similar documents
Database Design. ER Model. Overview. Introduction to Database Design. UVic C SC 370. Database design can be divided in six major steps:

Introduction to Database Design

Introduction to Database Design

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

Database Management Systems. Chapter 3 Part 2

The Entity-Relationship (ER) Model

The Entity-Relationship Model

CSE 530A. ER Model. Washington University Fall 2013

Database Applications (15-415)

The Entity-Relationship Model. Overview of Database Design

The Entity-Relationship Model

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

MIS Database Systems Entity-Relationship Model.

CS/INFO 330 Entity-Relationship Modeling. Announcements. Goals of This Lecture. Mirek Riedewald

Database Management Systems. Chapter 2 Part 2

The Entity-Relationship Model. Steps in Database Design

Introduction to Database Design

CIS 330: Web-driven Web Applications. Lecture 2: Introduction to ER Modeling

The Entity-Relationship (ER) Model 2

The Entity-Relationship Model

OVERVIEW OF DATABASE DEVELOPMENT

SYLLABUS ADMIN DATABASE SYSTEMS I WEEK 2 THE ENTITY-RELATIONSHIP MODEL. Assignment #2 changed. A2Q1 moved to A3Q1

High Level Database Models

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

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

ER Model Overview. The Entity-Relationship Model. Database Design Process. ER Model Basics

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

High-Level Database Models (ii)

CSIT5300: Advanced Database Systems

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

ER to Relational Mapping. ER Model: Overview

The Relational Model 2. Week 3

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

Database Design CENG 351

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

Review The Big Picture

Introduction to Data Management. Lecture #3 (Conceptual DB Design)

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

Database Applications (15-415)

CSC 261/461 Database Systems Lecture 10

Modeling Your Data. Chapter 2. cs542 1

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

Introduction to Data Management. Lecture #3 (Conceptual DB Design)

Database Applications (15-415)

The Relational Model

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

ENTITY-RELATIONSHIP. The database design process can be divided into six steps. The ER model is most relevant to the first three steps:

COMP Instructor: Dimitris Papadias WWW page:

CIS 330: Applied Database Systems

Entity-Relationship Diagrams

The Relational Model (ii)

COMP 244. ER-Diagram Notations. Entity-Relationship Diagrams DATABASE CONCEPTS & APPLICATIONS. Database Concepts & Applications 1.

CSC 261/461 Database Systems Lecture 8. Fall 2017

CIS 330: Applied Database Systems. ER to Relational Relational Algebra

The Relational Model. Chapter 3

Database Systems. Course Administration

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

Introduction to Data Management. Lecture #5 (E-R Relational, Cont.)

COMP 244 DATABASE CONCEPTS & APPLICATIONS

The Relational Model

Database Management Systems. Syllabus. Instructor: Vinnie Costa

Introduction to Databases

Conceptual Design. The Entity-Relationship (ER) Model

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

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

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

Introduction to Data Management. Lecture #4 (E-R à Relational Design)

The Relational Model. Outline. Why Study the Relational Model? Faloutsos SCS object-relational model

Introduction to Data Management. Lecture #6 E-Rà Relational Mapping (Cont.)

The Relational Model. Roadmap. Relational Database: Definitions. Why Study the Relational Model? Relational database: a set of relations

ER Model. CSC 343 Winter 2018 MICHAEL LIUT

CS2 Current Technologies Lecture 5: Data Modelling and Design

Database Design & Deployment

Introduction to Data Management. Lecture #3 (E-R Design, Cont d.)

! Need to decide. " What are relations. " What are columns/attributes in relations. " What integrity constraints or business rules hold?

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

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

CSC 261/461 Database Systems Lecture 8. Spring 2018

Database Applications (15-415)

Relational Databases BORROWED WITH MINOR ADAPTATION FROM PROF. CHRISTOS FALOUTSOS, CMU /615

Database Systems ( 資料庫系統 )

Why Study the Relational Model? The Relational Model. Relational Database: Definitions. The SQL Query Language. Relational Query Languages

Conceptual Design. The Entity-Relationship (ER) Model

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

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( 霍娟 )

Database Management Systems. Session 2. Instructor: Vinnie Costa

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

Database Management System 6 ER Modeling...

CMPT 354 Database Systems I

LAB 3 Notes. Codd proposed the relational model in 70 Main advantage of Relational Model : Simple representation (relationstables(row,

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

SQL DDL. CS3 Database Systems Weeks 4-5 SQL DDL Database design. Key Constraints. Inclusion Constraints

Problem. Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications

COMP102: Introduction to Databases, 9.1

MIT Database Management Systems Lesson 03: Entity Relationship Diagrams

The Relational Model

Carnegie Mellon Univ. Dept. of Computer Science /615 - DB Applications. Problem. Faloutsos - Pavlo CMU SCS /615

Database Design Process

Data Modeling Using the Entity-Relationship (ER) Model

Transcription:

Introduction to Database Design UVic C SC 370 Dr. Daniel M. German Department of Computer Science Overview What are the steps in designing a database? What is the entity-relationship (ER) model? How does UML related to the ER model? Chapter 2 of textbook May 5, 2004 Version: 1.1.1 2 1 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 2 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca ER Model Database Design The Entity-Relationship data model allows us to describe the data involved in a real-world system in terms of objects and their relationships It is widely used in database design Database design can be divided in six major steps: Requirements analysis Conceptual Database design (mostly done using the ER model) Logical Database design Schema refinement Physical Database Design Application and Security Design 2 3 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 4 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca

ER diagram Entities ER Diagram: an approximate description of the data, constructed through a subjective evaluation of the information, that was collected through the requirements analysis phase. Entity: is an object in the real world that is distinguishable from other objects Entity Set: collection of similar objects An entity is described using a set of attributes Each attribute has a domain of possible values. For each entity set, we should select a key A key is a minimal set of attributes that uniquely identify an entity in a set 2 5 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 6 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca Example of an Entity Relationships A relationship is an association among two or more entities A set of similar relationships is called a relationship set: {(e 1,...,e n ) e 1 E 1,...,e n E n } Each n-tuple denotes a relationship involving n entities (e 1,...,e n ) where e i is in the entity set E i A relationship can also include its own attributes (called descriptive attributes A relationship must be uniquely identified by its participating entities 2 7 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 8 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca

Example of a Relationship Example of a Ternary Relationship d d WorksIn WorksIn2 address Locations capacity 2 9 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 10 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca Role Indicators Key Constraints One-to-many: an entity is related to many other entities, but each of these entities can only be related to one entity Many-to-many: an entity is related to many other entities, and vice-versa supervisor subordinate ReportsTo 2 11 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 12 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca

Key Constraint on Manages Key Constraint on a Ternary Rel. d d Manages WorksIn3 address Locations capacity 2 13 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 14 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca Participation Constraints Total participation There are two types of participation constraints for an entity in a relationship: d Total: Every instance of the entity is present in the relationship (represent it by a thick line) Partial: Not every instance of the entity is present in the relationship represented Manages WorksIn 2 15 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 16 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca

Weak Entities A Weak Entity Set Sometimes the attributes associated with an entity set do not include a key cost A weak entity can be identified uniquely only by considering some of its attributes in conjunction with the primary key of another entity (called identifying owner entity) Policy p Dependents age The following restrictions must hold: The owner entity set is a one-to-many to the weak entity (identifying relationship set) The weak entity set should have total participation in the identifying relationship set. Represented by drawing the relation and the weak entity in thick lines 2 17 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 18 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca Class Hierarchies A Class Hierarchy Sometimes we need to define entities as derivations of others (ISA) That is, the attributes of an entity are those of another entity (its parent) plus other ones A class hierarchy can be seen in two different ways: Specialization: identify subsets of an entity that share some distinguishing characteristics Generalization: An entity is created that includes several characteristics common to different entity sets. hourlywages hoursworked ISA contractid HourlyEmps ContractEmps 2 19 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 20 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca

Class hierarchies... Aggregation Why do we subclass? We might want to include attributes that only make sense for the subclass (specialization) We might want to identify a set of entities that participate in a given relation (generalization) Sometimes a relationship needs to relate one relationship with a collection of entities or other relationships Aggregation allows us to indicate that a relationship set participates in another relationship set. Illustrated by drawing a dashed box around the set of related entities and relationships. 2 21 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 22 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca Aggregation... Conceptual Design with the ER Model Developing an ER diagram presents several choices: Should a concept be modelled as an entity or an attribute? Monitors until Should a concept be modelled as an entity or a relationship? What are the relationship sets and their participating entity sets? pid startedon p since d Should we use binary or ternary relationships? Should we use aggregation? Projects Sponsors 2 23 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 24 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca

Entity vs. Attribute Entity vs. Attribute... It is not always clear what should be an attribute of an entity and what should be moved to a new entity set from to d In general, an attribute should not be an entity unless: We need to record the same attribute(s) for more than one entity We want to capture the structure of this attribute in our ER-diagram WorksIn4 2 25 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 26 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca Entity vs. Attribute... Entity vs. Relationship WorksIn4 d The imprecise nature of ER modelling makes it difficult to recognize when to define an attribute as part of an entity or as part of a relationship The only solution (at this point) is to apply common sense: is the attribute part of the relation, or is it part of the entity? In general, a mistake in this stage will lead to wasted storage from Duration to We will fix this in the future (normalization) 2 27 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 28 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca

Entity vs. Relationship... Binary vs. Ternary Relationships In cases where we can use either a binary or ternary relationship, since d d the decision is usually determined by any restrictions (integrity constraints) on the relationship that we are trying to model and Manages2 if we can or cannot do it with a ternary relationship 2 29 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 30 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca Binary vs. Ternary... Binary vs. Ternary... p age p age Covers Dependents Purchaser Beneficiary Dependents Policies Policies policyid cost policyid cost A policy cannot be owned jointly by two or more employees Every policy must be owned by some employee Dependents is a weak entity (uniquely identified by policyid and p) 2 31 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 32 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca

Aggregation vs. Ternary Relationships Aggregation vs. Ternary... Again, the choice depends on integrity constraints startedon d pid p Project Sponsors2 2 33 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca 2 34 Introduction to Database Design (1.1.1) CSC 370 dmgerman@uvic.ca