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

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

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

The Entity-Relationship Model

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

The Entity-Relationship Model

The Entity-Relationship (ER) Model

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

Database Management Systems. Chapter 2 Part 2

Introduction to Database Design

The Entity-Relationship Model. Overview of Database Design

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

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

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

The Entity-Relationship (ER) Model 2

Database Applications (15-415)

MIS Database Systems Entity-Relationship Model.

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

Modeling Your Data. Chapter 2. cs542 1

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

Introduction to Data Management. Lecture #4 E-R Model, Still Going

OVERVIEW OF DATABASE DEVELOPMENT

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.

Introduction to Database Design

Database Management Systems. Chapter 3 Part 2

CIS 330: Applied Database Systems

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

Introduction to Database Design

Database Design CENG 351

High Level Database Models

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

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

The Entity-Relationship Model. Steps in Database Design

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

Database Applications (15-415)

Database Management Systems. Syllabus. Instructor: Vinnie Costa

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

High-Level Database Models (ii)

Entity-Relationship Diagrams

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

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

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

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

The Relational Model (ii)

ER Model. CSC 343 Winter 2018 MICHAEL LIUT

The Relational Model. Chapter 3

ER to Relational Mapping. ER Model: Overview

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

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

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

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

The Relational Model 2. Week 3

CSE 530A. ER Model. Washington University Fall 2013

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

Database Systems. Course Administration

Database Applications (15-415)

Database Systems ( 資料庫系統 )

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

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

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

COMP Instructor: Dimitris Papadias WWW page:

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

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

CSC 261/461 Database Systems Lecture 10

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

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

Conceptual Design. The Entity-Relationship (ER) Model

Database Applications (15-415)

CSIT5300: Advanced Database Systems

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

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

Database Design & Deployment

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

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

Database Management Systems. Session 2. Instructor: Vinnie Costa

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

Database Design Process

Conceptual Design. The Entity-Relationship (ER) Model

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

Review The Big Picture

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

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

Intro to DB CHAPTER 6

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

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

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

Entity-Relationship Model. From Chapter 5, Kroenke book

CMPT 354 Database Systems I

COMP 244 DATABASE CONCEPTS & APPLICATIONS

CSC 261/461 Database Systems Lecture 8. Fall 2017

CSC 261/461 Database Systems Lecture 8. Spring 2018

A l Ain University Of Science and Technology

Chapter 2: Entity-Relationship Model

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

CS 146 Database Systems

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

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

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

Database Design Process. Requirements Collection & Analysis

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

Transcription:

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

Announcements v HW #1 is now available v Today s plan Conceptual DB design, cont. Advanced ER concepts 2

Weak Entities v 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-tomany relationship set (one owner, many weak entities). Weak entity set must have total participation in this identifying relationship set. Dependent identifier is unique only within owner context ( ), so its fully qualified key here is (, d) lot premium d age 1 N Policy Dependents 3

Ternary Relationships (and beyond) phone docid specialty Patient M Prescribe 1 Doctor N Drug school drugcode descrip v A prescription is a 3-way relationship between a patient, a doctor, and a drug; with the cardinality constraints above: A given patient+drug will be associated with one doctor (1) A given patient+doctor may be associated with several drugs (N) A given doctor+drug may be associated with several patients (M) v (General) note: Relationship key (entity keys) 4

ISA ( is a ) Hierarchies lot v As in C++ or other PLs ER attributes are inherited (including the key attribute). hourly_wages v If we declare A ISA B, every A entity is also considered to be a B entity. v v v hours_worked Hourly_Emps ISA contractid Contract_Emps Overlap constraints: Can Joe be an Hourly_Emps as well as a Contract_Emps entity? (Allowed or disallowed) Ex: Hourly_Emps OVERLAPS Contract_Emps (else pick 1 of the 3 types) Covering constraints: Does every entity also have to be either an Hourly_Emps or a Contract_Emps entity? (Yes or no) Ex: Hourly_Emps AND Contract_Emps COVER (pick 1 of 2 vs. 1 of 3) Reasons for using ISA: To add descriptive attributes specific to a subclass. To identify subclasses that participate in a relationship. v Design: specialization (top-down), generalization (bottom-up) 5

Aggregation lot v Used when we have to model a relationship involving (entity sets and) a relationship set. Aggregation allows us to treat a relationship set as an entity set for purposes of participating in (other) relationships. pid started_on Projects Monitors pbudget since Sponsors did until d Departments budget Aggregation vs. ternary relationship: v Monitors is a distinct relationship; even has its own attribute here. v Each sponsorship can monitored by zero or more employees (as above). 6

Additional Advanced ER Features v Multi-valued (vs. single-valued) attributes phone v Derived (vs. base/stored) attributes bdate age v Composite (vs. atomic) attributes snum address street city zip NOTE: Can model (two of) these using additional entity and relationship types. 7

Conceptual Design Using the ER Model v Design choices: Should a given concept be modeled as an entity or an attribute? Should a given concept be modeled as an entity or a relationship? Characterizing relationships: Binary or ternary? Aggregation? v Constraints in the ER Model: A lot of data semantics can (and should) be captured. But, not all constraints cannot be captured by ER diagrams. (Ex: Department heads from earlier!) 8

Entity vs. Attribute v Should address be an attribute of or an entity (connected to by a relationship)? v Depends how we want to use address information, the data semantics, and also the model features: If we have several addresses per employee, address must be an entity if we stick to basic E-R concepts (as attributes cannot be set-valued w/o advanced modeling goodies). 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 (since attribute values are atomic w/o advanced modeling goodies). If the address itself is logically separate (e.g., the property that s located there) and refer-able, it s rightly an entity in any case! 9

Entity vs. Attribute (Cont d.) v Works_In4 does not allow an employee to work in a department for two or more periods. (Q: Why...?) lot from to Works_In4 did d budget Departments v Similar to the problem of wanting to record several addresses for an employee: We want to record several values of the descriptive attributes for each instance of this relationship. Could be accomplished by introducing a new entity set, Period. lot from Works_In4 Period did to d budget Departments 10

Entity vs. Relationship v First ER diagram OK if a manager gets a separate discretionary budget for each dept. v What if a manager gets a discretionary budget that covers all managed depts? Redundancy: dbudget stored for each dept managed by manager. Misleading: Suggests dbudget associated with department-mgr combination. ISA Managers lot lot since dbudget Manages2 since Manages2 dbudget did did d budget Departments d budget Departments Also note ISA and the relationship... 11

Binary vs. Ternary Relationships lot p age v v If each policy is owned by just 1 employee, with each dependent tied to their covering policy, first diagram is inaccurate. Q: What are the additional constraints in the 2nd diagram? (And what else was wrong with the 1 st diagram? J) Covers Dependents Bad design lot Policies policyid cost p age Dependents Owner Better design Beneficiary Policies policyid cost 12

Binary vs. Ternary Relationships (Cont d.) v Previous example illustrated a case when two binary relationships were better than one ternary relationship. v An example in the other direction: a ternary relation Contracts relates entity sets Parts, Departments and Suppliers, and has descriptive attribute qty. 13

Binary vs. Ternary Relationships (Cont d.) Bad design: S can-supply P, D needs P, and D deals-with S does not imply that D has agreed to buy P from S. And also, how we record qty? dno d phone sno s Departments Suppliers pno Parts p cost 14

Binary vs. Ternary Relationships (Cont d.) v An example in the other direction: a ternary relation Contracts relates entity sets Parts, Departments and Suppliers, and has descriptive attribute qty: dno d phone qty sno s Departments Contracts Suppliers Parts pno p cost 15

Database Design Process (Flow) v Requirements Gathering (interviews) v Conceptual Design (using ER) v Platform Choice (which DBMS?) v Logical Design (for target data model) v Physical Design (for target DBMS, workload) v Implement (and test, of course J) (Expect backtracking, iteration, and also incremental adjustments and, we will actually be giving you a bit of practice with that last one in the next few HW assignments...! J) 16

Summary of Conceptual Design v Conceptual design follows requirements analysis Yields a high-level description of data to be stored v ER model popular for conceptual design Constructs are expressive, close to the way people think about their applications. v Basic constructs: entities, relationships, and attributes (of entities and relationships). v Some additional constructs: weak entities, ISA hierarchies, and aggregation. v Note: There are many variations on ER model (and many notations in use as well) and also, UML... 17

Summary of ER (Contd.) v Several kinds of integrity constraints can be expressed in the ER model: cardinality constraints, participation constraints, and overlap/covering constraints for ISA hierarchies. Some foreign key constraints are also implicit in the definition of a relationship set (more about those will be coming soon). 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. 18

Summary of ER (Contd.) v ER design is subjective. There are often many ways to model a given scenario! Analyzing alternatives can be tricky, especially for a large enterprise. Common choices include: Entity vs. attribute, entity vs. relationship, binary or n- ary relationship, whether or not to use an ISA hierarchy, and whether or not to use aggregation. v Ensuring good database design à The resulting relational schema should be analyzed and refined further. FD information and normalization techniques are especially useful (coming soon). 19