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

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

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

The Entity-Relationship Model

The Entity-Relationship Model

Database Management Systems. Chapter 2 Part 2

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

The Entity-Relationship (ER) Model

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

The Entity-Relationship Model. Overview of Database Design

Introduction to Database Design

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

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

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

The Entity-Relationship (ER) Model 2

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

Modeling Your Data. Chapter 2. cs542 1

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

Database Applications (15-415)

MIS Database Systems Entity-Relationship Model.

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

The Entity-Relationship Model

OVERVIEW OF DATABASE DEVELOPMENT

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

Database Management Systems. Chapter 3 Part 2

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

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

CIS 330: Applied Database Systems

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

Database Design CENG 351

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

Introduction to Database Design

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

Database Management Systems. Syllabus. Instructor: Vinnie Costa

The Entity-Relationship Model. Steps in Database Design

Introduction to Database Design

Introduction to Data Management. Lecture #2 (Big Picture, Cont.) Instructor: Chen Li

High Level Database Models

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

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

Database Applications (15-415)

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

Entity-Relationship Diagrams

Introduction to Data Management. Lecture #2 Intro II & Data Models I

High-Level Database Models (ii)

ER Model. CSC 343 Winter 2018 MICHAEL LIUT

ER to Relational Mapping. ER Model: Overview

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

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

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

The Relational Model (ii)

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

CSE 530A. ER Model. Washington University Fall 2013

The Relational Model 2. Week 3

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

The Relational Model. Chapter 3

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

COMP Instructor: Dimitris Papadias WWW page:

Conceptual Design. The Entity-Relationship (ER) Model

Database Applications (15-415)

Database Systems ( 資料庫系統 )

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

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

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

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

Database Systems. Course Administration

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

CSC 261/461 Database Systems Lecture 10

Conceptual Design. The Entity-Relationship (ER) Model

CSIT5300: Advanced Database Systems

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

Database Applications (15-415)

Database Design Process

Database Management Systems. Session 2. Instructor: Vinnie Costa

Introduction to Data Management. Lecture #2 (Big Picture, Cont.)

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

Database Design & Deployment

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

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

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

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

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

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

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

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

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

CSC 261/461 Database Systems Lecture 8. Spring 2018

Lecture #16 (Physical DB Design)

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

Introduction to Data Management. Lecture #7 (Relational Design Theory)

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

Review The Big Picture

Entity Relationship Data Model. Slides by: Shree Jaswal

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

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

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

Database Design Process. Requirements Collection & Analysis

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

Entity-Relationship Model. From Chapter 5, Kroenke book

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #5: Entity/Relational Models---Part 1

Introduction to Data Management. Lecture #17 (Physical DB Design!)

Transcription:

Introduction to Data Management Lecture #3 (Conceptual DB Design) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Announcements Today s plan: More about logical DB design! Basic ER concepts review and examples Advanced ER concepts Reminders: Sign up on Piazza! (Only 2/3 have done this.) HW #1 and Project Part 1 coming mid-week! First quiz in discussion section tomorrow! Any lingering Q s from last time? Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 2

ER Basics: Another Example fac_id pid Professor 1 Assigned 1 rank M 1 In Head N N dno d Dept main_office _num Parking Space space_num (Note that I m using the M:N notation, and not s, here.) Let s see if you can read/interpret the ER diagram above! (J ) What attributes are unique (i.e., identify their associated entity instances)? What are the rules about (the much coveted) parking passes? What are the rules (constraints) about professors being in departments? And, what are the rules about professors heading departments? Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 3 Another Example (Cont d.) Unique attributes: Professor.fac_id, Dept.dno, Parking Space.pid Faculty parking: 1 space/faculty, one faculty/space Some faculty can bike or walk (J ) Some parking spaces may be unused Faculty in departments: Faculty may have appointments in multiple departments Departments can have multiple faculty in them No empty departments, and no unaffiliated faculty Department management: One head per department (exactly) Not all faculty are department heads NOTE: These things are all rules of the universe that are just being modeled here! Q: Can a faculty member head a department that he or she isn t actually in? Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 4

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-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) premium d age 1 N Policy Dependents Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 5 Ternary Relationships (and beyond) Patient phone M Prescribe 1 docid Doctor specialty N Drug school drugcode descrip A prescription here is a 3-way relationship between a patient, a doctor, and a drug As modeled above, a given patient/drug combination will always be associated with one doctor (General) note: Relationship key = (entity keys) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 6

ISA ( is a ) Hierarchies As in C++ or other PLs ER attributes are inherited (including the key attribute). hourly_wages If we declare A ISA B, every A entity is also considered to be a B entity. Contract_Emps Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 7 hours_worked Hourly_Emps ISA contractid 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. Design: specialization (top-down), generalization (bottom-up) Aggregation Used when we have to model a relationship involving (entitity 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 budget Aggregation vs. ternary relationship: Monitors is a distinct relationship; even has its own descriptive attribute. Also, can say that each sponsorship is monitored by at most one employee. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 8 did until d Departments

Some Advanced ER Features Multi-valued (vs. single-valued) attributes phone Derived (vs. stored) attributes bdate age Composite (vs. atomic) attributes address snum street Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 9 city zip NOTE: Can model (two of) these using additional entity and relationship types. Conceptual Design Using the ER Model 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? Constraints in the ER Model: A of data semantics can (and should) be captured. But, not all constraints cannot be captured by ER diagrams. (Ex: Department heads from earlier!) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 10

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 (since 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! Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 11 Entity vs. Attribute (Cont d.) Works_In4 does not allow an employee to work in a department for two or more periods. from to Works_In4 did d budget Departments 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. Can be accomplished by introducing new entity set, Duration. from Works_In4 Duration did to d budget Departments Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 12

Entity vs. Relationship First ER diagram OK if a manager gets a separate discretionary budget for each dept. 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 Manages2 d budget Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 13 since since dbudget Manages2 dbudget did did Departments d budget Departments This fixes the problem! Binary vs. Ternary Relationships p age If each policy is owned by just 1 employee, and each dependent is tied to the covering policy, first diagram is inaccurate. Q: What are the additional constraints in the 2nd diagram? Bad design policyid Owner Better design Covers Policies Dependents policyid cost Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 14 cost p Beneficiary Policies age Dependents

Binary vs. Ternary Relationships (Cont d.) 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, Departments 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 3ed, R. Ramakrishnan and J. Gehrke 15 Datatase Design Process (Flow) Requirements Gathering (interviews) Conceptual Design (using ER) Platform Choice (which DBMS?) Logical Design (for target data model) Physical Design (for target DBMS, workload) Implement (and test, of course J ) (Expect backtracking, iteration, and also incremental adjustments!) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 16

Summary of Conceptual Design 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 (and many notations in use as well). Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 17 Summary of ER (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 3ed, R. Ramakrishnan and J. Gehrke 18

Summary of ER (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. Common choices include: Entity vs. attribute, entity vs. relationship, binary or n- ary relationship, whether or not to use ISA hierarchies, and whether or not to use aggregation. Ensuring good database design: resulting relational schema should be analyzed and refined further. FD information and normalization techniques are especially useful. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 19