High-Level Database Models (ii)

Similar documents
High Level Database Models

Database Design & Deployment

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

The Relational Model (ii)

The Entity-Relationship Model

Database Management Systems. Chapter 3 Part 2

The Entity-Relationship Model. Overview of Database Design

The Relational Model. Chapter 3

The Relational Model 2. Week 3

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

CONCEPTUAL DESIGN: ER TO RELATIONAL TO SQL

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

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

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

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

OVERVIEW OF DATABASE DEVELOPMENT

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

Introduction to Database Design

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

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

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

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

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

Database Systems ( 資料庫系統 )

Database Applications (15-415)

Introduction to Database Design

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

Introduction to Database Design

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

The Entity-Relationship Model

CSC 261/461 Database Systems Lecture 10

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

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

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

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

CIS 330: Applied Database Systems

ER to Relational Mapping. ER Model: Overview

Database Systems. Course Administration

The Entity-Relationship (ER) Model

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

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

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

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

Database Management Systems. Chapter 2 Part 2

Translating an ER Diagram to a Relational Schema

The Entity-Relationship (ER) Model 2

COMP Instructor: Dimitris Papadias WWW page:

Conceptual Design. The Entity-Relationship (ER) Model

CSIT5300: Advanced Database Systems

The Entity-Relationship Model. Steps in Database Design

Database Design CENG 351

Entity-Relationship Diagrams

Database Applications (15-415)

CSC 261/461 Database Systems Lecture 8. Spring 2018

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

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

Introduction to Databases

Conceptual Design. The Entity-Relationship (ER) Model

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

CSE 530A. ER Model. Washington University Fall 2013

MIS Database Systems Entity-Relationship Model.

Database Management Systems. Session 2. Instructor: Vinnie Costa

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

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

Integrity constraints, relationships. CS634 Lecture 2

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

CSC 261/461 Database Systems Lecture 8. Fall 2017

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

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

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

Database Applications (15-415)

ER Model. Objectives (2/2) Electricite Du Laos (EDL) Dr. Kanda Runapongsa Saikaew, Computer Engineering, KKU 1

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

Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa

The Relational Model

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

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

Database Applications (15-415)

COMP 244 DATABASE CONCEPTS & APPLICATIONS

ER Model. CSC 343 Winter 2018 MICHAEL LIUT

The Relational Model

CMPT 354 Database Systems I

Database Management Systems. Syllabus. Instructor: Vinnie Costa

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

SQL: Queries, Constraints, Triggers (iii)

The Relational Model

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

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

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

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

EGCI 321: Database Systems. Dr. Tanasanee Phienthrakul

The DBMS accepts requests for data from the application program and instructs the operating system to transfer the appropriate data.

DATABASE MANAGEMENT SYSTEMS

The Relational Model of Data (ii)

Database Design Process

The Entity-Relationship Model (ER Model) - Part 2

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

Review The Big Picture

Transcription:

ICS 321 Spring 2011 High-Level Database Models (ii) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 1

Logical DB Design: ER to Relational Entity sets to tables: ssn name Employees lot CREATE TABLE Employees (ssn CHAR(11), name CHAR(20), lot INTEGER, PRIMARY KEY (ssn)) 2

Relationship Sets to Tables Attributes of the relation must include: Keys for each participating entity set (as foreign keys). This set of attributes forms a superkey for the relation. All descriptive attributes. ssn name Employees CREATE TABLE Works_In( ssn CHAR(11), did INTEGER, since DATE, PRIMARY KEY (ssn, did), FOREIGN KEY (ssn) REFERENCES Employees, FOREIGN KEY (did) REFERENCES Departments) lot since Works_In did dname budget Departments 3

ssn Translating ER Diagrams with Key Constraints since Map relationship to a table: Note that did is the key now! Since each department has a unique manager, we could instead combine Manages and Departments. did Employees Manages Departments A B C D Emp. Manages (1:m) Depts CREATE TABLE Manages( ssn CHAR(11), did INTEGER, since DATE, PRIMARY KEY (did), FOREIGN KEY (ssn) REFERENCES Employees, FOREIGN KEY (did) REFERENCES Departments) CREATE TABLE Dept_Mgr( did INTEGER, dname CHAR(20), budget REAL, ssn CHAR(11), since DATE, PRIMARY KEY (did), FOREIGN KEY (ssn) REFERENCES Employees) 1 2 3 4

Participation Constraints in SQL We can capture participation constraints involving one entity set in a binary relationship, but little else (without resorting to CHECK constraints). CREATE TABLE Dept_Mgr( did INTEGER, dname CHAR(20), budget REAL, ssn CHAR(11) NOT NULL, since DATE, PRIMARY KEY (did), FOREIGN KEY (ssn) REFERENCES Employees, ON DELETE NO ACTION) 5

Review: 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-to-many relationship set (1 owner, many weak entities). Weak entity set must have total participation in this identifying relationship set. ssn name lot cost pname age Employees Policy Dependents 6

Translating Weak Entity Sets Weak entity set and identifying relationship set are translated into a single table. When the owner entity is deleted, all owned weak entities must also be deleted. CREATE TABLE Dep_Policy ( pname CHAR(20), age INTEGER, cost REAL, ssn CHAR(11) NOT NULL, PRIMARY KEY (pname, ssn), FOREIGN KEY (ssn) REFERENCES Employees, ON DELETE CASCADE) 7

ISA Hierarchies As in C++, or other PLs, attributes are inherited. If we declare A ISA B, every A entity is also considered to be a B entity. hourly_wages ssn hours_worked Hourly_Emps name lot Employees ISA contractid Contract_Emps Overlap constraints: Can Joe be an Hourly_Emps as well as a Contract_Emps entity? (Allowed/disallowed) Covering constraints: Does every Employees entity also have to be an Hourly_Emps or a Contract_Emps entity? (Yes/no) 8

Translating ISA Hierarchies to Relations General approach: 3 relations: Employees, Hourly_Emps and Contract_Emps. Hourly_Emps: Every employee is recorded in Employees. For hourly emps, extra info recorded in Hourly_Emps (hourly_wages, hours_worked, ssn); must delete Hourly_Emps tuple if referenced Employees tuple is deleted). Queries involving all employees easy, those involving just Hourly_Emps require a join to get some attributes. Alternative: Just Hourly_Emps and Contract_Emps. Hourly_Emps: ssn, name, lot, hourly_wages, hours_worked. Each employee must be in one of these two subclasses. 9

Unified Modeling Language Standardized general-purpose modeling language for software design Based on object-oriented model Class diagrams 10

UML Classes Class name length year title Movies genre Methods section typically not used in data modeling ER Entity Set UML Class 11

Associations Cardinality constraints : one instance of Stars can be connected to at least 0 instance of movies and at most inifinite instances of movies 12

Referential Integrity Aggregation: Must be 0..1 (includes 1..1) Composition : Must be 1..1 Every president runs exactly one studio Aggregation never named 13

Association Classes 14

Sub-Class Hierarchies 15

Modeling Tips Faithful to the semantics of the application Model only what is needed in the application Minimize redundancy (why?) Simple is good If the model is getting too complicated, take a step back and ask Am i conceptualizing the right entities? Am i thinking of the right relationships? Should some relationships become entities? Vice versa? Should some attributes become entities? Vice versa? 16