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



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

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

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 Entity-Relationship Model

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

Data Modeling. Database Systems: The Complete Book Ch ,

Lecture 6. SQL, Logical DB Design

2. Conceptual Modeling using the Entity-Relationship Model

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

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

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

The Entity-Relationship Model

The Entity-Relationship Model

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

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

Lecture 12: Entity Relationship Modelling

The Relational Data Model: Structure

Winter Winter

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

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

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

Databases and BigData

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

Entity Relationship Diagram

XV. The Entity-Relationship Model

Entity-Relationship Model

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

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

CSC 742 Database Management Systems

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

Data Modeling Basics

There are five fields or columns, with names and types as shown above.

Chapter 2: Entity-Relationship Model

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

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

IV. The (Extended) Entity-Relationship Model

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

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

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

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

Database Fundamentals: 1

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

Fundamentals of Database Design

Lesson 8: Introduction to Databases E-R Data Modeling

Databases What the Specification Says

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

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

Foundations of Information Management

Foundations of Information Management

Introduction to Computing. Lectured by: Dr. Pham Tran Vu

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

Relational Database Concepts

DATABASE MANAGEMENT SYSTEMS. Question Bank:

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

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

ER modelling, Weak Entities, Class Hierarchies, Aggregation

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

The core theory of relational databases. Bibliography

Designing a Database Schema

Lecture Notes INFORMATION RESOURCES


SQL NULL s, Constraints, Triggers

Entity/Relationship Modelling. Database Systems Lecture 4 Natasha Alechina

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

Information Systems Modelling Information Systems I: Databases

The Relational Model. Why Study the Relational Model?

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

Exercise 1: Relational Model

7.1 The Information system

DATABASE INTRODUCTION

IT2305 Database Systems I (Compulsory)

Designing Databases. Introduction

THE OPEN UNIVERSITY OF TANZANIA FACULTY OF SCIENCE TECHNOLOGY AND ENVIRONMENTAL STUDIES BACHELOR OF SIENCE IN DATA MANAGEMENT

Database Design and the E-R Model

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

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

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

Rose Data Modeler (logical)

three Entity-Relationship Modeling chapter OVERVIEW CHAPTER

Modern Systems Analysis and Design

Database Management Systems

Using Entity-Relationship Diagrams To Count Data Functions Ian Brown, CFPS Booz Allen Hamilton 8283 Greensboro Dr. McLean, VA USA

Database Design Process

Database Management Systems. Chapter 1

TIM 50 - Business Information Systems

ECS 165A: Introduction to Database Systems

Databases and DBMS. What is a Database?

Database Design Process

Course: CSC 222 Database Design and Management I (3 credits Compulsory)

The Relational Data Model and Relational Database Constraints

14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

Fundamentals of Database System

How To Write A Diagram

Data Modelling and E-R Diagrams

Transcription:

Database Design Overview Conceptual Design. The Entity-Relationship (ER) Model CS430/630 Lecture 12 Conceptual design The Entity-Relationship (ER) Model, UML High-level, close to human thinking Semantic model, intuitive, rich constructs Not directly implementable Logical Design The relational data model Machine-implementable, fewer and more basic constructs Logical design translates ER into relational model (SQL) Physical Design (not in this course) Storage and indexing details Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke 2 Conceptual Design ER Model What are the entities and relationships in a typical application? What information about these entities and relationships should we store in the database? What are the integrity constraints or business rules Key constraints Participation constraints Entities and Entity Sets Entity: represents a real-world object Characterized using set of attributes Each attribute has a domain similar to variable types Entity Set: represents collection of similar entities E.g., all employees in an organization All entities in an entity set share same set of attributes Representation through ER diagrams ER diagrams are then mapped into relational schemas Conversion is fairly mechanical 3 4 Keys Each entity set has a key Set of attributes that uniquely identify an entity Multiple canate keys may exist Entity Set Representation Primary key selected among them Representation Convention: - Entity sets: rectangles - Attributes: ovals, with key attributes underlined - Edges connect entity sets to attributes 5 6

Relationships and Relationship Sets Visualizing Relationships and Rel. Sets Relationship: Association among two (or more) entities Gabriel works in CS department Can have descriptive attributes: e.g., 9/1/2011 But relationship must be fully determined by entities! Binary, ternary or multi-way (n-way) relationships Relationship Set: Collection of similar relationships A B C D 1 2 3 (A, 1) (B, 1) (B, 2) (D, 3) Contains n-tuples (e 1,, e n ), where e i belongs to entity set E i Instance: snapshot of relationship set at some point in time Edge = Relationship Set of Edges = Relationship Set 7 8 Relationship Set Representation A Special Case of Relationship d An entity set can participate in a relationship set with itself Entities in same set play different roles in the relationship Role indicators express the role Representation Convention: - Relationship sets: diamonds - Edges connect relationship sets to entity sets, and relationship sets to relationship set attributes supervisor subordinate Role indicator Reports_To Role indicator 9 10 Key Constraints Example 1 How many other entities can an entity have a relationship with? Also referred to as relationship multiplicity relationship: an employee can work in many departments; a dept can have many employees. many-to-many d 1-to-1 1-to-Many Many-to-1 Many-to-Many 11 12

Example 2 relationship: each dept has at most one manager one-to-many from to, or many-to-one from to d Participation Constraints Total vs Partial Participation Total: every department must have a manager entity set has total participation in relationship Represented as thickened line (there is a key constraint as well) Partial: not every employee is a manager entity set has partial participation d 13 14 Participation Constraints Partial Participation Total Participation Example Design a database for a bank, including information about customers and their accounts. Information about customers includes their, address, phone and SSN. Accounts have numbers, types (e.g., savings/checking) and balances. 1. Draw the E/R diagram for this database. 2. Modify the E/R diagram such that each customer must have at least one account. 3. Modify the E/R diagram further such that an account can have at most one customer. 15 16 Mapping ER to Relational Schemas Entity Sets to Tables For most part, process is mechanical Some special cases arise in the presence of constraints Translation from ER to SQL requires: Mapping entity sets to tables Mapping relationship sets to tables Capturing key constraints Capturing participation constraints CREATE TABLE ( CHAR(11), CHAR(20), INTEGER, PRIMARY KEY ()) 17 18

Relationship Sets to Tables No-constraints case follows simple rules Relationship set becomes a relation, attributes include: Keys for each participating entity set (as foreign keys pointing to respective entity table) All descriptive attributes for relationship Primary key of relationship set table is the concatenation of primary keys for the entity sets Relationship Sets to Tables CREATE TABLE ( CHAR(11), INTEGER, DATE, PRIMARY KEY (, ), FOREIGN KEY () REFERENCES, FOREIGN KEY () REFERENCES ) d 19 20 What if there are Key Constraints? Variant 1 d Map relationship to a table: Note that is the key now! Separate table for relationship. Each department has at most one manager, according to the key constraint on CREATE TABLE ( CHAR(11), INTEGER, DATE, PRIMARY KEY (), FOREIGN KEY () REFERENCES, FOREIGN KEY () REFERENCES ) 21 22 Variant 2 Since each department has a unique manager, we could instead combine and. CREATE TABLE Dept_Mgr( INTEGER, d CHAR(20), INTEGER, CHAR(11), DATE, PRIMARY KEY (), FOREIGN KEY () REFERENCES ) Review: Participation Constraints Does every department have a manager? If yes, the participation of in is total Every value in table must appear in a row of the table (with a non-null value!), but this cannot be controlled in SQL (unless we use complex constraints) Turns out that it is NOT possible to capture this with the two-tables mapping Foreign key mechanism does not allow to check if there is a reference to every tuple in the referenced table The Dept_Mgr variant is the only way! 23 24

Participation Constraints in SQL Participation Constraints Summary d General case Total participation cannot be enforced unless we use complex constraints CREATE TABLE Dept_Mgr( INTEGER, d CHAR(20), INTEGER, CHAR(11) NOT NULL, DATE, PRIMARY KEY (), FOREIGN KEY () REFERENCES ON DELETE NO ACTION) What if there is also a key constraint in place? If the entity set with total participation also has a key constraint, then it is possible to capture total participation But only if combined table construction is used! 25 26 Design Choices in the ER Model Entity vs. Attribute Should a concept be modeled as an entity or an attribute? address Should a concept be modeled as an entity or a relationship? Considers hierarchies and inheritance Outside the scope of this class Should address be an attribute of or an entity (connected to by a relationship)? 27 28 Entity vs. Attribute Sometimes address may have to be an entity: If we have several addresses per employee ( attributes cannot be set-valued) If the structure (city, street, etc.) is important, e.g., retrieve employees in a given city (attribute values are atomic!) city street zip Employee Lives At Address 29