CSCI 6442 Entity-Relation Data Modeling Copyright 2012, David C. Roberts, all rights reserved.

Slides:



Advertisements
Similar presentations
More Diagramming & Practice with Relationship Modeling
Advertisements

Entity Relationship (E-R) Modeling
Chapter 2.1 V3.1 Napier University Dr Gordon Russell
Entity Relationship (E-R) Modeling Hachim Haddouti
Entity Relationship (ER) Modeling
CSCI 6442 Entity-Relation Data Modeling Copyright 2012, David C. Roberts, all rights reserved.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Entity Relationship (ER) Modeling
Concepts of Database Management Seventh Edition Chapter 6 Database Design : ERD Model.
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Chapter 4 Entity Relationship (E-R) Modeling
Entity Relationship (ER) Modeling
Entity Relationship (ER) Modeling
Entity-Relationship Model
Systems Development Life Cycle
Data Modeling using the Entity-Relationship (ER) Model
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 6.
Entity Relationship (E-R) Modeling
Chapter Five Data Modeling with the Entity-Relationship Model.
Chapter 3: Modeling Data in the Organization
Information Resources Management January 30, 2001.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke’s Chapter Five: Data Modeling with the Entity-Relationship.
Database Systems: Design, Implementation, & Management, 5 th Edition, Rob & Coronel 1 Data Models: Degrees of Data Abstraction l Modified ANSI/SPARC Framework.
Entity-Relationship Model
Chapter 4 Entity Relationship (E-R) Modeling
Chapter Five Data Modeling with the Entity-Relationship Model.
CSCI 242 Relational Data Modeling Copyright 2011, David C. Roberts, all rights reserved.
Modern Systems Analysis and Design Third Edition
Chapter 3: The Enhanced E-R Model
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas.
Data Modeling Using the Entity-Relationship Model
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke’s Chapter Five: Data Modeling with the Entity-Relationship.
1 © Prentice Hall, 2002 CMIS564: E/R Modeling Dr. Bordoloi Based on Chapter 3; Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott,
3 Chapter 3 Entity Relationship (E-R) Modeling Database Systems: Design, Implementation, and Management, Fifth Edition, Rob and Coronel.
1 Web-Enabled Decision Support Systems Entity-Relationship Modeling Prof. Name Position (123) University Name.
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
CONCEPTS OF E-R MODEL. CONTENTS Entity Attributes Data Value Entity Types Types of Entity Types Relationships Relationship Constraints.
1. 2 Data Modeling 3 Process of creating a logical representation of the structure of the database The most important task in database development E-R.
Entities and Attributes
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Chapter 5 Entity–Relationship Modeling
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Chapter 2: Entity-Relationship Model Entity Sets Relationship Sets Design Issues Mapping.
Initial Design of Entity Types for the COMPANY Database Schema Based on the requirements, we can identify four initial entity types in the COMPANY database:
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Chapter 7 Data Modeling with Entity Relationship Diagrams
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
1 A Demo of Logical Database Design. 2 Aim of the demo To develop an understanding of the logical view of data and the importance of the relational model.
Entity Relationship Modeling
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
Dr Gordon Russell, Napier University Data Analysis 1 - V2.0 1 Data Analysis 1 Unit 2.1.
The Entity-Relationship Model, P. I R. Nakatsu. Data Modeling A data model is the relatively simple representation, usually graphic, of the structure.
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
CSCI 6442 Entity-Relation Data Modeling
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Five: Data Modeling with the Entity-Relationship.
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 2: MODELING DATA.
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
Entity Relationship (E-R) Model
ER model Ashima Wadhwa.
Entity Relationship (E-R) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 1: The Database Environment
Entity Relationship (ER) Modeling
Presentation transcript:

CSCI 6442 Entity-Relation Data Modeling Copyright 2012, David C. Roberts, all rights reserved

Relational Database Remember that a relational database is a collection of time-varying, independent relations Each relation models some entity type in the problem space (outside the computer) There is a close correspondence between entity types and relations 2

Data Modeling We can say that the relational database models the real-world problem So construction of a relational database becomes the selection of the entity types to put into the data model Sometimes entity type selection is simple; other times entity types are not apparent and selection can be difficult 3

Notation for Data Models Because a relational database is comprised of independent tables, how do you deal with relationships during design? Chen developed the entity-relation data model, which considered entity types and their relationships He expected that a new type of database system would evolve, directly implementing the E-R data model Instead, the E-R notation was found to be an excellent tool for relational database design and the relational approach has taken over Since then, popular automated tools have tended to change the notation for easier computer printing 4

Chen’s Notation We will use Chen’s notation today for two reasons: 1.It separates the notion of a relationship from the notion of an entity type 2.Conversion of the design into relational tables occurs at the end of the design process, so the difference between the data model and physical design is clear In your own work, once you are familiar with the concepts, you will be able to use the popular “crow’s foot” notation used by DBDesigner4 5

Entities Strong Entity—has independent existence Weak Entity—exists only when the entity it depends on exists 6 Employee Dependent

Examples of Entity Types EMPLOYEE CUSTOMER ORGANIZATION PART INGREDIENT PURCHASE ORDER CUSTOMER ORDER PRODUCT 7 Question: Which of these would likely be a weak entity type?

Examples of Entity Instances An instance of an entity is a specific occurrence of an entity type: Bill Gates is an Employee of Microsoft Spam is a Product Greenpeace is an Organization Flour is an ingredient 8

Attributes Attributes are indicated inside ovals; identifier attributes are underlined. For complex diagrams, attributes are often omitted 9 Employee EMPNO JOB SALARY

Examples of Attributes An attribute is a characteristic of an entity type: EmployeeID Social Security Number First Name Last Name Street Address City State ZipCode Date Hired Health Benefits Plan 10

Multi-Valued Attribute A multi-valued attribute is shown as a double line 11 Employee EMPNO JOB SALARY TELEPHONE

Relationship A relationship is an association between two entity types, for example: ▫A CUSTOMER places a CUSTOMER ORDER ▫An EMPLOYEE takes a CUSTOMER ORDER ▫A STUDENT enrolls in a COURSE ▫A COURSE is taught by a FACULTY MEMBER Some say that entity types should be nouns and relationships should be verbs 12

Relationship 13 EMPLOYEE DEPARTMENT WORKS FOR

Categorizing Relationships Number of entity types participating: ▫Unary: one ▫Binary: two ▫Ternary: three Existence of related instances(a.k.a. optionality): ▫Mandatory ▫Optional Cardinality of the relationship: ▫One-many ▫Many-many ▫One-one 14

One-to-One Relationships Usually the only time a one-to-one relationship is used is for a dependent entity. Otherwise, usually if there is a one-to-one relationship, careful consideration will show that there is just one entity type. 15 EMPLOYEE SPOUSE HAS 1 1

Relationship And Cardinality A relationship is an association between two or more entity types, drawn as a diamond. Relationships may be one-to-many, many-to- many or one-to-one 16 DEPARTMENT EMPLOYEE HAS STUDENT COURSE GRADE EMPLOYEE COMPANY CAR HAS 1 N N N 1 1 1

Recursive Relationship Recursive relationship is how a repeated hierarchy is represented 17 Employee WORKS FOR Question: How else can this hierarchy be represented?

Relationship of Higher Degree A ternary relationship, also said to have degree STUDENT COURSE REG N N TEACHER N COURSENO GRADE

Optionality of Participation 19 EMPLOYEE HAS STUDENT COURSE GRADE EMPLOYEE COMPANY CAR HAS 1 N N N 1 1 DEPARTMENT

Supertypes It can be useful to consider a supertype that includes several entity types as subtypes Supertypes can be ▫Complete: every instance of the supertype is one of the subtypes ▫Distinct: no single entity type can be a member of two subtypes 20

Notation Chen’s notation for supertypes and subtypes is cumbersome, so let’s use “crow’s-foot” notation A supertype is shown as a box surrounding the boxes for all the subtypes Relationship lines end on the supertype or the subtype boundaries as appropriate 21

Subtypes Subtypes can be either mutually exclusive (disjoint) or overlapping (inclusive). ▫For a mutually exclusive category, an entity instance may be in only one subtype. ▫For an overlapping category, an entity instance may be in two or more subtypes. The completeness constraint: all instances of a subtype must be represented in the supertype. 22

Example Subtypes 23 PARTY EMPLOYEE APPLICANT PERSON ORGANIZATION SUPPLIER CUSTOMER Question: How would this be implemented as database tables? PARTY(PARTYID) PERSON(PARTYID,FNAME,MI,LNAME,DOB,POB) EMP(PARTYID,EMPID,DHIRED,SAL,JOB,DEPTNO) APP(PARTYID,DAPPLIED,STATUS) ORG(PARTYID,ORGNAME,ORGCITY,ORGSTATE,ORG ZIP) CUST(PARTYID,CUSTID,DOFO,DOLO,LYVOL) SUPP(PARTYID,SUPPID,DOFO,DOLO,LYVOL )

Why Use Subtypes and Supertypes Like This? Relationships are simplified ▫The relationship can take place at the highest possible level in the hierarchy ▫Fewer relationship tables are generally required Programming can be simplified ▫All subtypes can be processed in the same way ▫For example, write a check to an organization or a check to a supplier with the same code 24

Relationships 25 DEPT WORKS IN BELONGS TO

Converting an ERD to Relational Recall that when we did an ERD we were not designing tables, we were defining the problem in terms of entity types and relationships Now the design must be translated into relational tables 26 Question: What are the symbols on the ERD that will become tables in the relational database?

Converting to Relational Every entity type becomes a table For one-many relationships, put the identifier of the one with each of the many For one-one relationships, put the identifier of each with the other For many-many relationships, identify an entity type that connects them, and make it a table, using the primary key of both partners as a composite primary key 27

Conversion We see that every rectangle in the ERD will become a table in the relational database Some of the diamonds will become tables and some will not 28

Students and Courses 29 Course Number Location Credits Registration Grade StudentID Name Student Grad YR

What About Subtypes? Each subtype and supertype is a separate table Common attributes are stored with the highest level entity that shares them The root level supertype may have many attributes, or it may have only a key 30

OK, How Do I Do It? You will have your own ideas about how to proceed, but here’s an idea: 1.Enumerate things in the problem space to keep track of (these are entity types) 2.Enumerate what to keep track of about each thing (these are attributes) 3.Enumerate relationships to keep track of 4.Draw a draft ERD 5.Review it for possible simplifications and alternative approaches 31