CS3200 Database Design Spring 2018 Derbinsky. Entity-Relationship (ER) Diagrams. Lecture 7

Similar documents
DATABASE DESIGN PROCESS

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

CS 338 The Enhanced Entity-Relationship (EER) Model

Conceptual Data Models for Database Design

Lecture3: Data Modeling Using the Entity-Relationship Model.

Entity Relationship Data Model. Slides by: Shree Jaswal

Data Modeling with the Entity Relationship Model. CS157A Chris Pollett Sept. 7, 2005.

Data Modeling Using the Entity-Relationship (ER) Model

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

Conceptual modeling is a very important phase in

LECTURE 3: ENTITY-RELATIONSHIP MODELING

CS 405G: Introduction to Database Systems

Data Modeling Using the Entity- Relationship Model Design & Analysis of Database Systems

course 3 Levels of Database Design CSCI 403 Database Management Mines Courses ERD Attributes Entities title 9/26/2018

Copyright 2016 Ramez Elmasr and Shamkant B. Navathei

Overview of Database Design Process. Data Modeling Using the Entity- Relationship (ER) Model. Two main activities:

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

A l Ain University Of Science and Technology

DATABASE DESIGN I - 1DL300

Data Modeling Using the Entity-Relationship Model

Database Management System (15ECSC208) UNIT I: Chapter 1: Introduction to DBMS and ER-Model

Represent entities and relations with diagrams

Chapter (4) Enhanced Entity-Relationship and Object Modeling

Sahaj Computer Solutions. Data Modeling using the Entity Relationship Model

CSE 880:Database Systems. ER Model and Relation Schemas

Enhanced Entity- Relationship Models (EER)

Database Systems ER Model. A.R. Hurson 323 CS Building

A l Ain University Of Science and Technology

Advance Database Management System

Chapter Outline. Note 1. Overview of Database Design Process Example Database Application (COMPANY) ER Model Concepts

DATABASE DESIGN I - 1DL300

Entity-Relationship Model

Chapter 4. In this chapter, you will learn:

EECS 647: Introduction to Database Systems

2004 John Mylopoulos. The Entity-Relationship Model John Mylopoulos. The Entity-Relationship Model John Mylopoulos

DATABASE SYSTEMS. Chapter 5 Entity Relationship (ER) Modelling DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT

Chapter 4 Entity Relationship Modeling In this chapter, you will learn:

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

DATABASTEKNIK - 1DL116

ER-to-Relational Mapping

Ch 9: Mapping EER to Relational. Follow a seven-step algorithm to convert the basic ER model constructs into relations steps 1-7

Non-overlappingoverlapping. Final outcome of the worked example On pages R&C pages R&C page 157 Fig 3.52

Unit 2 - Data Modeling. Pratian Technologies (India) Pvt. Ltd.

Advanced Databases (SE487) Prince Sultan University College of Computer and Information Sciences

E-R Diagram. Bagian I Entity Concept

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

Database Design Process

MTAT Introduction to Databases

Database Design Process. Requirements Collection & Analysis

Relational Model (cont d) & Entity Relational Model. Lecture 2

Elements of the E-R Model

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

IS 263 Database Concepts

More on the Chen Notation

XV. The Entity-Relationship Model

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 4 Entity Relationship (ER) Modeling

Chapter 7: Entity-Relationship Model

ER modeling. Lecture 4

Chapter 2: Entity-Relationship Model

Chapter 2 ENTITY RELATIONSHIP MODEL

Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition. Chapter 7 Data Modeling with Entity Relationship Diagrams

COMP Instructor: Dimitris Papadias WWW page:

Conceptual Modeling in ER and UML

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

Entity-Relationship Models

Relational DB Design by ER- and EER-to-Relational Mapping Design & Analysis of Database Systems

MIS Database Systems Entity-Relationship Model.

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

DATABASDESIGN FÖR INGENJÖRER F

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

Phases of Database Design

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 4 Entity Relationship (ER) Modeling

CMP-3440 Database Systems

The En'ty Rela'onship Model

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

Chapter 8 The Enhanced Entity- Relationship (EER) Model

Chapter 6: Entity-Relationship Model


E-R Model. Hi! Here in this lecture we are going to discuss about the E-R Model.

Chapter 2 Conceptual Modeling. Objectives

Database Systems. Overview - important points. Lecture 5. Some introductory information ERD diagrams Normalization Other stuff 08/03/2015

Enhanced Entity-Relationship (EER) Modeling

Entity-Relationship Model. From Chapter 5, Kroenke book

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

Chapter 6: Entity-Relationship Model. The Next Step: Designing DB Schema. Identifying Entities and their Attributes. The E-R Model.

Definition. 02. Data Modeling. Example ABC Company Database. Data Modeling Importance

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

COIS Databases

The Next Step: Designing DB Schema. Chapter 6: Entity-Relationship Model. The E-R Model. Identifying Entities and their Attributes.

Topic 5: Mapping of EER Diagrams to Relations

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

MIT Database Management Systems Lesson 03: Entity Relationship Diagrams

CMSC 424 Database design Lecture 3: Entity-Relationship Model. Book: Chap. 1 and 6. Mihai Pop

Lecture 10 - Chapter 7 Entity Relationship Model

Database Management Systems LECTURE NOTES 2

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

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

Database Design with Entity Relationship Model

PES Institute of Technology Bangalore South Campus (1 K.M before Electronic City,Bangalore ) Department of MCA. Solution Set - Test-II

Chapter 6: Entity-Relationship Model

Transcription:

Lecture 7

. Context Outline Design & Implementation Process 2. Goals of Conceptual Design 3. Entity-Relationship (ER) Model 4. One ER Diagrammatic otation 5. Requirements Elicitation 6. Approaches to Conceptual Design 2

Database Design and Implementation Process 3

Goal of Conceptual Design Description of data requirements that is Comprehensive Entity types, relationships, and constraints Sanity check of data & functional requirements Reference for [unit/integration] testing/analysis Concise/High-level Easy to understand technically Easy to communicate with non-technical users Facilitates focus on data (vs. storage/implementation details) Algorithmically Transformable Improves application development efficiency, reduces errors 4

Entity-Relationship (ER) Model Entity Thing in the real world Attribute Property of an entity Most of what we store in the database Relationship Association between sets of entities Possibly with attribute(s) 5

Graphical depiction of an ER model Many notations, this class ER Diagrams All cars have a year, age, make, model, registration (unique), vehicle number (vin; unique), some number of colors Specialization/Generalization 6

Entity Sets Set of entities that have the same attributes Make Year Model All cars have a year, make, and model. CAR 7

Composite Attributes Can be subdivided into smaller subparts Make Year Model All cars have a year, make, model, and registration. CAR Registration State umber 8

Multivalued Attributes Can take a [possibly specified] number of values. Make Year Model All cars have a year, make, model, registration, and some number of colors. Color State CAR Registration umber 9

Key Attributes The value uniquely identifies each entity Make Year Model All cars have a year, make, model, registration (unique), vehicle number (vin; unique), some number of colors. Color State CAR Registration VI umber 0

Potential Pitfall In relational schema, underlining multiple attributes indicates that for all rows, the combination is unique In ERDs, underlining multiple attributes indicates that each individually can uniquely identify an entity

Derived Attributes The value can be computed Make Year Age Model All cars have a year, age, make, model, registration (unique), vehicle number (vin; unique), some number of colors. Color State CAR Registration umber VI 2

Exercise Draw an ERD for the following description: Each department has a unique name, a unique number, and a particular employee who manages the department. We keep track of the start date when that employee began managing the department. A department may have several locations. 3

Answer ame umber Location DEPARTMET Manager Manager_ Start_Date 4

Exercise Draw an ERD for the following description: A department controls a number of projects, each of which has a unique name, a unique number, and a single location. 5

Answer ame umber Location PROJECT Controlling_ Department 6

Exercise Draw an ERD for the following description: We store each employee s name (first, last, MI), Social Security number (SS), street address, salary, sex (gender), and birth date. An employee is assigned to one department, but may work on several projects, which are not necessarily controlled by the same department. We keep track of the current number of hours per week that an employee works on each project. We also keep track of the direct supervisor of each employee (who is another employee). 7

Answer Salary SS Sex Department Supervisor EMPLOYEE Birthdate Address Fame ame Works_On Project MI Lame Hours 8

Exercise Draw an ERD for the following description: We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent s first name, sex, birth date, and relationship to the employee. 9

Answer Sex Employee DEPEDET DBirthdate Relationship Dame 20

Relationships Associates one or more sets of entities One = recursive (role is important) STUDET DEPT CHAIR_F All departments have a faculty member who serves as the chair. A faculty member can only chair one department. FACULTY 2

Relationships Associates one or more sets of entities One = recursive (role is important) MAJOR_D STUDET DEPT CHAIR_F All students must have a department in which they major. FACULTY 22

Relationships Associates one or more sets of entities One = recursive (role is important) MAJOR_D STUDET DEPT MIOR_D CHAIR_F Students may have any number of departments in which they minor. FACULTY 23

Relationships Associates one or more sets of entities One = recursive (role is important) MAJOR_D STUDET DEPT Tutor Tutee MIOR_D TUTORS CHAIR_F Students can tutor other student(s). FACULTY 24

Cardinality Ratios Constrains the number of entities that can participate in each role of the relationship MAJOR_D STUDET DEPT Tutor Tutee MIOR_D TUTORS CHAIR_F All departments have a faculty member who serves as the chair. A faculty member can only chair one department. FACULTY 25

Cardinality Ratios Constrains the number of entities that can participate in each role of the relationship MAJOR_D STUDET DEPT Tutor Tutee MIOR_D TUTORS CHAIR_F All students must have a department in which they major. FACULTY 26

Cardinality Ratios Constrains the number of entities that can participate in each role of the relationship MAJOR_D Tutor STUDET Tutee MIOR_D M DEPT TUTORS CHAIR_F Students may have any number of departments in which they minor. FACULTY 27

Cardinality Ratios Constrains the number of entities that can participate in each role of the relationship MAJOR_D Tutor STUDET TUTORS Tutee M MIOR_D M DEPT CHAIR_F Students can tutor other student(s). FACULTY 28

Structural Constraints If an entity does not exist unless it appears with an entity in a relationship, the participation is total (existence dependency). Else, partial. MAJOR_D Tutor STUDET TUTORS Tutee M MIOR_D M DEPT CHAIR_F All departments have a faculty member who serves as the chair. A faculty member can only chair one department. FACULTY 29

Structural Constraints If an entity does not exist unless it appears with an entity in a relationship, the participation is total (existence dependency). Else, partial. MAJOR_D Tutor STUDET TUTORS Tutee M MIOR_D M DEPT CHAIR_F All students must have a department in which they major. FACULTY 30

Attributes of Relationships ->, can go to either entity ->, can go to () entity MAJOR_D Tutor STUDET TUTORS Tutee M MIOR_D Office M DEPT CHAIR_F Each department chair has an office. FACULTY 3

Attributes of Relationships ->, can go to either entity ->, can go to () entity MAJOR_D Done Tutor STUDET TUTORS Tutee M MIOR_D Office M DEPT CHAIR_F It is important to know whether or not a student has completed his/her major. FACULTY 32

Attributes of Relationships ->, can go to either entity ->, can go to () entity MAJOR_D Done Tutor STUDET TUTORS Tutee M MIOR_D Done Office M DEPT CHAIR_F It is important to know whether or not a student has completed each of his/her minor(s). FACULTY 33

Attributes of Relationships ->, can go to either entity ->, can go to () entity MAJOR_D Done Tutor STUDET TUTORS Tutee M MIOR_D Done Office M DEPT CHAIR_F Subject It is important to know the subject(s) in which a tutee is being tutored by each tutor. FACULTY 34

Weak Entities Entity types that do not have key attributes of their own are weak; instead identified by relation to specific entity of another type (the identifying type) Prof COURSE COURSE SEC SECTIO AME umber Book DEPT UM 35

Revise! We store each employee s name (first, last, MI), Social Security number (SS), street address, salary, sex (gender), and birth date. An employee is assigned to one department, but may work on several projects, which are not necessarily controlled by the same department. We keep track of the current number of hours per week that an employee works on each project. We also keep track of the direct supervisor of each employee (who is another employee). Fame) MI) Department) Supervisor) SS) ame) Lame) Salary) Sex) EMPLOYEE) Works_On) Hours) Birthdate) Address) Project) 36

Answer Salary SS Sex Department Supervision Supervisor Supervisee EMPLOYEE Birthdate Address Fame ame Works_On Project MI Lame Hours 37

Revise! We want to keep track of the dependents of each employee for insurance purposes. We keep each dependent s first name, sex, birth date, and relationship to the employee. Supervision) ) Supervisor) Supervisee) ) Fame) MI) Salary) SS) Sex) EMPLOYEE) ame) Works_On) Lame) Hours) Sex( Department) Birthdate) Address) Project) Employee( DEPEDET( DBirthdate( Rela7onship( Dame( 38

Answer Salary SS Sex Department Supervision Supervisor Supervisee EMPLOYEE Birthdate Address Fame ame Works_On Project Sex MI Lame Hours DEPEDET _OF DEPEDET DBirthdate Relationship Dame 39

Revise! A department controls a number of projects, each of which has a unique name, a unique number, and a single location. ame' Loca%on' ame' PROJECT' Controlling_' Department' umber' umber' Loca%on' DEPARTMET' Manager' Manager_' Start_Date' 40

Answer ame umber Location PROJECT ame umber COTROLS DEPARTMET Manager Location Manager_ Start_Date 4

Revise! Each department has a particular employee who manages the department. Loca%on' ame' PROJECT' ' umber' ame' umber' An employee is assigned to one department, but may work on several projects, which are not necessarily controlled by the same department. We keep track of the current number of hours per week that an employee works on each project. Supervision) ) Supervisor) Supervisee) ) Fame) MI) COTROLS' SS) ame) Lame) Salary) EMPLOYEE) ) DEPEDET _OF) Loca%on' Sex) Works_On) Hours) ' Birthdate) Address) DEPARTMET' Department) Project) Manager_' Start_Date' ) Sex) DEPEDET) Manager' DBirthdate) RelaIonship) Dame) 42

Answer Hours Supervisor Supervision Supervisee WORKS_O M EMPLOYEE SS ame Start _Date Location PROJECT Manages umber COTROLS DEPARTMET Works_For Location ame umber 43

All Together ow! 44

Specialization/Generalization Only a subset of entities within a type have certain attributes or participate in certain relationships ID STUDET U GRAD_STUDET Degrees 45

Multiple Subtypes: Disjointedness (o)verlap: may be more than one (d)isjoint: entities may only be one subtype SS A person can be an employee, an alumnus, and/or a student U PERSO o U U EMPLOYEE ALUMUS STUDET 46

Multiple Subtypes: Disjointedness (o)verlap: may be more than one (d)isjoint: entities may only be one subtype SS U PERSO d U U A person can be either an employee, an alumnus, or a student EMPLOYEE ALUMUS STUDET 47

Multiple Subtypes: Completeness Similar to relationships; can be total (must belong to subtypes) or partial (can belong) SS U PERSO d U U A person must be exactly one: an employee, an alumnus, or a student EMPLOYEE ALUMUS STUDET 48

Exercise The database keeps track of three types of persons: employees, alumni, and students. A person can belong to one, two, or all three of these types. Each person has a name, SS, sex, address, and birth date. Every employee has a salary, and there are three types of employees: faculty, staff, and student assistants. Each employee belongs to exactly one of these types. For each alumnus, a record of the degree or degrees that he or she earned at the university is kept, including the name of the degree, the year granted, and the major department. Each student has a major department. Each faculty has a rank, whereas each staff member has a staff position. Student assistants are classified further as either research assistants or teaching assistants, and the percent of time that they work is recorded in the database. Research assistants have their research project stored, whereas teaching assistants have the current course they work on. Students are further classified as either graduate or undergraduate, with the specific attributes degree program (M.S., Ph.D., M.B.A., and so on) for graduate students and class (freshman, sophomore, and so on) for under- graduates. 49

Answer 50

Alternative otation () Figure A. 5

Alternative otation (2) Figure A. 52

Requirements Elicitation The conceptual model should inform requirements elicitation questions: What are the main kinds of objects to be stored in the database (entity types)? For each object, what information should be stored (attributes, relationships)? What information distinguishes one object of a type from another (keys, weak entities)? Are there different kinds/categories of objects (specialization/generalization)? For each piece of information, what characterizes a valid value (composite/multi-valued, structural, etc.)? For related objects x and y, can x exist without y (participation)? How many x s can a y have, and vice-versa (cardinality)? 53

Approaches to Conceptual Design Centralized Single authority responsible for merging requirements into schema Reasonable for smaller applications View Integration Each stakeholder implements local view Individual views integrated into global schema Individual views can be reconstructed as external schemas after integration 54

View Integration (). Identify correspondences and conflicts Conflicts: names, types, domain, constraints 2. Modify views to conform 3. Merge 4. Restructure 55

View Integration (2) 56

Summary The goal of conceptual design is to develop a set of data requirements that are comprehensive, clear & easy to understand, and algorithmically transformable ER Diagrams (ERDs) are one such design model that visually represent the entities, attributes, and relationships of a system Requirements elicitation and conceptual design is an iterative process that is a necessary prerequisite to implementing a database 57