Entity-Relationship Models: Good Design and Constraints

Similar documents
CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #10: E/R Designs and Constraints

CMPT 354 Database Systems I

Database Design Using E/R Model

Conceptual Design with ER Model

ENTITY-RELATIONSHIP MODEL. CS 564- Spring 2018

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

High-Level Database Models. Spring 2011 Instructor: Hassan Khosravi

Introduction to Databases

OVERVIEW OF DATABASE DEVELOPMENT

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

Conceptual Design. The Entity-Relationship (ER) Model

MIS Database Systems Entity-Relationship Model.

Entity-Relationship Model. Purpose of E/R Model

CS54100: Database Systems

Entity-Relationship Model

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

Database Design. Goal: specification of database schema Methodology:

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

KEYS WEAK ENTITY SETS EXAMPLE: WEAK ENTITY SET EXAMPLE: WEAK ENTITY SET. Beers. Ales. Players. Teams ISA. and. Plays-on

High-Level Database Models (ii)

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

The Entity-Relationship Model. Steps in Database Design

High Level Database Models

Entity/Relationship Modelling

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

E/R Diagrams! Converting E/R Diagrams to Relations!

The Relational Model. Week 2

CSE 530A. ER Model. Washington University Fall 2013

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

Database Management Systems. Chapter 2 Part 2

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

ER Model. CSC 343 Winter 2018 MICHAEL LIUT

Database Design. Database Design I: The Entity-Relationship Model. Entity Type (con t) Representation in Relational Model.

Database Systems. Course Administration

Relational Database Design Part I. Announcement. Relational model: review. CPS 116 Introduction to Database Systems

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

Informatics 1: Data & Analysis

Database Applications (15-415)

Translating an ER Diagram to a Relational Schema

Entity-Relationship Modelling. Entities Attributes Relationships Mapping Cardinality Keys Reduction of an E-R Diagram to Tables

The Relational Model

COMP Instructor: Dimitris Papadias WWW page:

3. Advanced E/R Concepts

Introduction to Data Management CSE 344

The Relational Model 2. Week 3

Relational Database Design Part I. Announcements (September 5) Relational model: review. CPS 116 Introduction to Database Systems

A Deeper Look at Data Modeling. Shan-Hung Wu & DataLab CS, NTHU

Introduction to Data Management CSE 344

Chapter 2 Conceptual Modeling. Objectives

CS 146 Database Systems

Announcement. Relational Database Design Part I. Keys. Relational model: review. Schema vs. data. More examples of keys

Announcements. Database Design. Database Design. Database Design Process. Entity / Relationship Diagrams. Introduction to Data Management CSE 344

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

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

The Relational Model. Chapter 3

Lecture 2. Database design. The Entity-Relationship model

Agenda: Understanding Relationship Types Degree and Cardinality with Examples

LAB 2 Notes. Conceptual Design ER. Logical DB Design (relational) Schema Refinement. Physical DD

3. Advanced E/R Concepts

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

Modeling Your Data. Chapter 2. cs542 1

Steps in designing a database. Steps in picture. Entity-Relationship Model. Entity Set. Attributes. The Entity-Relationship Data Model

The Relational Model

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

Chapter 7: Entity-Relationship Model

The Entity-Relationship (ER) Model 2

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

Chapter 2: Entity-Relationship Model

CSIT5300: Advanced Database Systems

Entity-Relationship Models

Chapter 7: Entity-Relationship Model. Chapter 7: Entity-Relationship Model

Entity Relationship Data Model. Slides by: Shree Jaswal

Conceptual Modeling in ER and UML

Represent entities and relations with diagrams

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

Relational Database Design Part II. Announcements. E/R model: review. CPS 116 Introduction to Database Systems

Chapter 6: Entity-Relationship Model

Database Applications (15-415)

Administrivia. CS 235: Introduction to Databases. Examples. What is a DBMS? The DBMS Marketplace. Relational Model

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

The Entity-Relationship Model. Overview of Database Design

Informatics 1: Data & Analysis

CSC 261/461 Database Systems Lecture 10

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

CS 4604: Introduc0on to Database Management Systems. B. Aditya Prakash Lecture #7: En-ty/Rela-onal Model---Part 3

Where Are We? Next Few Lectures. Integrity Constraints Motivation. Constraints in E/R Diagrams. Keys in E/R Diagrams

Entity-Relationship Model &

Chapter 2. Database Design. Database Systems p. 25/540

Lecture 4. Lecture 4: The E/R Model

Chapter 6: Entity-Relationship Model

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

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

Information Systems Engineering

Lecture 5. Lecture 5: The E/R Model

Information Systems Engineering. Entity Relationship Model

Database Systems CSE 414

Conceptual Database Design. COSC 304 Introduction to Database Systems. Entity-Relationship Modeling. Entity-Relationship Modeling

Database Systems ( 資料庫系統 )

DATABASE SCHEMA DESIGN ENTITY-RELATIONSHIP MODEL. CS121: Relational Databases Fall 2017 Lecture 14

Intro to DB CHAPTER 6

Transcription:

Entity-Relationship Models: Good Design and T. M. Murali September 29, 2010 T. M. Murali September 29, 2010 CS 4604: E/R Design and

Guidelines Be faithful to the specification of the application. Avoid redundancy. Keep the entities and relationship simple. Select the right relationships. Select the right type of element. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Be Faithful Do not use meaningless or unnecessary attributes. Define the multiplicity of a relationship appropriately. What is the multiplicity of the relationship Take between Students and Courses? What is the multiplicity of the relationship Teach between Professors and Courses? T. M. Murali September 29, 2010 CS 4604: E/R Design and

Avoid Redundancy Redundancy occurs when we express the same fact in two or more ways. Redundancy wastes space. Redundancy can lead to inconsistency if we change one instance but not the other. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Select the Right Relationships Do not add unnecessary relationships. It may be possible to deduce one relationship from another. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Select the Right Relationships Do not add unnecessary relationships. It may be possible to deduce one relationship from another. Do we need the relationship Instruct between Professors and Students? Students Take Courses Instruct Teach Professors T. M. Murali September 29, 2010 CS 4604: E/R Design and

Select the Right Relationships Do not add unnecessary relationships. It may be possible to deduce one relationship from another. Do we need the relationship Instruct between Professors and Students? No. We can deduce this relationship from Take and Teach. Students Take Courses Instruct Teach Professors T. M. Murali September 29, 2010 CS 4604: E/R Design and

Select the Right Relationships Do not add unnecessary relationships. It may be possible to deduce one relationship from another. Do we need the relationship Instruct between Professors and Students? No. We can deduce this relationship from Take and Teach. Do we need the relationships Take and Teach? Students Take Courses Evaluation Teach Professors T. M. Murali September 29, 2010 CS 4604: E/R Design and

Select the Right Relationships Do not add unnecessary relationships. It may be possible to deduce one relationship from another. Do we need the relationship Instruct between Professors and Students? No. We can deduce this relationship from Take and Teach. Do we need the relationships Take and Teach? Yes. Why? Students Take Courses Evaluation Teach Professors T. M. Murali September 29, 2010 CS 4604: E/R Design and

Select the Right Type of Element Attribute or Entity or Relationship? T. M. Murali September 29, 2010 CS 4604: E/R Design and

Select the Right Type of Element Attribute or Entity or Relationship? Can we make Professor an attribute of Courses and remove the relationship Teach? Address Classroom Students Take Courses Enrollment Teach Professors Age T. M. Murali September 29, 2010 CS 4604: E/R Design and

Select the Right Type of Element Attribute or Entity or Relationship? Can we make Professor an attribute of Courses and remove the relationship Teach? What if we add the relationship Evaluation? Address Classroom Students Take Courses Enrollment Evaluation Teach Professors Age T. M. Murali September 29, 2010 CS 4604: E/R Design and

Select the Right Type of Element Attribute or Entity or Relationship? Can we make Professor an attribute of Courses and remove the relationship Teach? What if we add the relationship Evaluation? What if we add the relationship Research signifying a research project the student is working on with a professor? Address Classroom PID Students Take Courses Dept Research Evaluation Teach Number PID Professors Age T. M. Murali September 29, 2010 CS 4604: E/R Design and

Converting an Entity Set into an Attribute If an entity set E satisfies the following properties: 1. All relationships involving E have arrows entering E. 2. The attributes of E collectively identify an entity (i.e., no attribute depends on another). 3. No relationship involves E more than once then we can replace E as follows: 1. If there is a many-one relationship R from an entity set F to E, remove R and make the attributes of E be attributes of F. 2. If there is a multiway relationship R with an arrow to E, make E s attributes be new attributes of R and remove the arrow from R to E. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Types of Keys are attributes or sets of attributes that uniquely identify an entity within its entity set. Single-value constraints require that a value be unique in certain contexts. Referential integrity constrains require that a value referred to actually exists in the database. Domain constraints specify what set of values an attribute can take. Read the textbook. General constraints are arbitrary constraints that should hold in the database. are part of the schema of a database. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Keys in the E/R Model A key for an entity set E is a set K of one or more attributes such that given any two entities e 1 and e 2 in E, e 1 and e 2 cannot have identical values for all the attributes in K. E can have multiple keys. We designate one as the primary key. In an isa-hierarchy, the root entity set must have all the attributes needed for a key. In an E/R diagram, underline the attributes that form the primary key. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Examples of Keys Address Classroom PID Students Take Courses Dept Research Evaluation Teach Number PID Professors Age T. M. Murali September 29, 2010 CS 4604: E/R Design and

Examples of Keys Address Classroom PID Students Take Courses Dept Research Evaluation Teach Number PID Professors Age T. M. Murali September 29, 2010 CS 4604: E/R Design and

Single-Value There is at most one value in a given context. 1. Each attribute of an entity set has a single value. If the value is missing, we can invent a null value. E/R models cannot represent the requirement that an attribute cannot have a null value. 2. A many-one relationship implies a single value constraint. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Referential Integrity Constraint Asserts that exactly one value exists in a given context. Usually used in the context of relationships. Example: Many-one Advises relationship between Students and Professors. Many-one requirement says that no student may have more than one advising professor. Referential integrity constraint says that each student must have exactly one advising professor and that professor must be present in the database. If R is a (many-to-one or one-to-one) relationship from E to F, we use a rounded arrowhead pointing to F to indicate that we require that the entity in F related by R to an entity in E must exist. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Example of Referential Integrity Each department has at most one chairperson who is its head (there are times when a department may not have a chairperson). Each chairperson can be the head of at most one department and this department must exist in the database. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Example of Referential Integrity Each department has at most one chairperson who is its head (there are times when a department may not have a chairperson). Each chairperson can be the head of at most one department and this department must exist in the database. Where do we put the arrows? Departments Heads Chairpersons T. M. Murali September 29, 2010 CS 4604: E/R Design and

Example of Referential Integrity Each department has at most one chairperson who is its head (there are times when a department may not have a chairperson). Each chairperson can be the head of at most one department and this department must exist in the database. Where do we put the arrows? Departments Heads Chairpersons T. M. Murali September 29, 2010 CS 4604: E/R Design and

Enforcing Referential Integrity Professors Advises Students We forbid the deletion of a referenced entity (e.g., a professor) until the professor advises no students. We require that if we delete a referenced entity, we delete all entities that reference it. When we insert a (student, professor) pair into the Advises relationship, the professor must exist in the Professors entity set. T. M. Murali September 29, 2010 CS 4604: E/R Design and

Weak Entity Sets A weak entity set is an entity set whose key contains attributes from one or more other entity sets. It is possible that all attributes in a weak entity set s key come from other entity sets. Primary causes for weak entity sets: Hierarchy of entity sets (not caused by inheritance). Conversion of multiway into binary relationships. (Read Example 4.22 on page 153 of the textbook.) T. M. Murali September 29, 2010 CS 4604: E/R Design and

Example of Weak Entity Set Each department teaches multiple courses. Each course has a number. What is the key for the entity set Courses? Departments Address Offer Classroom Students Take Courses Enrollment Teach Number Professors Age Office T. M. Murali September 29, 2010 CS 4604: E/R Design and

Example of Weak Entity Set Each department teaches multiple courses. Each course has a number. What is the key for the entity set Courses? Departments Address Offer Classroom Students Take Courses Enrollment Teach Number Professors Age Office T. M. Murali September 29, 2010 CS 4604: E/R Design and

Finding the Key for a Weak Entity Set E is a weak entity set if its key consists of 1. Zero or more of its own attributes and 2. Key attributes from supporting relationships for E. A relationship R from a weak entity set E to F is supporting if 1. R is a binary, many-one relationship from E to F, 2. R has referential integrity from E to F. How does F help E? 1. F supplies its key attributes to define E s key. 2. If F is itself a weak entity set, some of its key attributes come from entity sets to which F is connected by supporting relationships. Representation in the E/R diagram. Weak entity set: rectangle with a double border. Supporting relationship: diamond with a double border. T. M. Murali September 29, 2010 CS 4604: E/R Design and