Entity-Relationship (E-R) modeling: constructing a conceptual schema (Chapter 5) Due to course constraints I have to defer other modeling issues (normalization.

Slides:



Advertisements
Similar presentations
Designing tables from a data model (Chapter 6) One base table for each entity.
Advertisements

the Entity-Relationship (ER) Model
Entity-Relationship (ER) Modeling
Data Modeling and the Entity-Relationship Model
Data Modeling and the Entity-Relationship Model
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
IT420: Database Management and Organization
Entity-Relationship Model
Data Modeling and the Entity-Relationship Model
Data Modeling and the Entity-Relationship Model
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Systems Development Life Cycle
Text-Book Chapters (7 and 8) Entity-Relationship Model
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 3 The Entity- Relationship Model.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 6.
Fundamentals, Design, and Implementation, 9/e Chapter 3 Entity-Relationship Data Modeling: Process and Examples Instructor: Dragomir R. Radev Fall 2005.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 David M. Kroenke Database Processing Tenth Edition Chapter 5 Data.
Chapter Five Data Modeling with the Entity-Relationship Model.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 5-1 COS 346 Day 6.
Chapter 3: Modeling Data in the Organization
Fundamentals, Design, and Implementation, 9/e COS 346 Day 2.
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.
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Database Systems: Design, Implementation, and Management Tenth Edition
Entity-Relationship Model
Chapter Five Data Modeling with the Entity-Relationship Model.
CSCI 242 Relational Data Modeling Copyright 2011, David C. Roberts, all rights reserved.
Data Modeling and Entity- Relationship Model I IST2101.
 Keys are special fields that serve two main purposes: ◦ Primary keys are unique identifiers of the relation in question. Examples include employee numbers,
Ch5: ER Diagrams - Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
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.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Entity Relationship Diagrams (ERDs)
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.
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
Chapter 3: Modeling Data in the Organization
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.
Chapter 5 Entity–Relationship Modeling
Entity Relationship Diagrams Objectives s Learn the Elements of the E-R model (entities, attributes, and relationships) s Show how to apply the E-R model.
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. KroenkeChapter 2/1 Copyright © 2004 Please……. No Food Or Drink in the class.
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. KroenkeChapter 3/1 Copyright © 2004 Please……. No Food Or Drink in the class.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Concepts of Database Management Sixth Edition Chapter 6 Database Design 2: Design Method.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Data Modeling IST210 Class Lecture.
Chapter 12 Entity-Relationship Modeling Pearson Education © 2009.
Next Back A-1 Management Information Systems for the Information Age Second Canadian Edition Copyright 2004 The McGraw-Hill Companies, Inc. All rights.
C-1 Management Information Systems for the Information Age Copyright 2004 The McGraw-Hill Companies, Inc. All rights reserved Extended Learning Module.
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 4 Entity Relationship (ER) Modeling.
Computing & Information Sciences Kansas State University Friday, 26 Sep 2008CIS 560: Database System Concepts Lecture 13 of 42 Friday, 26 September 2008.
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.
David M. Kroenke and David J. Auer Database Processing Fundamentals, Design, and Implementation Chapter Five: Data Modeling with the Entity-Relationship.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 3: Modeling Data in the Organization Modern Database Management 9 th Edition Jeffrey.
Data Modeling and Entity-Relationship Model I
Requirements Become the E-R Data Model
Database Systems: Design, Implementation, and Management Tenth Edition
Database Systems Instructor Name: Lecture-9.
Database Processing: David M. Kroenke’s Chapter Five:
Presentation transcript:

Entity-Relationship (E-R) modeling: constructing a conceptual schema (Chapter 5) Due to course constraints I have to defer other modeling issues (normalization in chapters 3 and 4) until later in the semester.

Entity a thing you need to model. It is analogous to a class in object oriented design. Fields of an entity are called attributes. An entity instance is an occurrence of a particular entity. It is analogous to an object. However, there is no encapsulation in the OO sense.

One or more attributes is usually an identifier, which uniquely identifies an entity. It is also called a key, though the term identifier is used in the data model and key is used when creating tables. Semantics.

Design issue: Many designers like to keep each identifier and primary key dataless This means that it contains no information about the entity. This way, they never change. Ex. IDs, account numbers, etc.

Advantageous if there’s an index or hash function that uses the keys since a changing key would change the internal structure. Also useful since a key value sometimes exists in other records that are related to the entity with the given key. These would need to change also.

A relationship defines how two or more entities are connected according the rules in the reality you are modeling.

Some guidelines A relationship should be named and well- defined. Do not simply state there is a relationship between two entities. Articulate what the relationship represents.

Example: there is a relationship between a student entity and a course entity. So? Does it represent courses for which the student has registered? Does it represent courses dropped? Does it represent courses needed for a major? Does it represent courses on a transcript? Spell it out!!

Degree of a relationship is the number of entities involved. Most are degree 2 (binary relationships) but some are more. A ternary relationship involves 3 entities. Example: p Can you think of more?

Cardinality is the number of entity instances in a relationship. Maximum cardinality is the maximum number of instances in a relationship. For example, the relationship between a sports team and its players has a maximum cardinality defined by rules of the sport.

Three types of maximum cardinality 1-1 relationship between A and B For each instance of type A there is no more than one instance of type B, and vice-versa. Notation and example: p. 149

Some possible examples: Employee fleet vehicle Project employee (defined by who is project leader and assumes each employee leads no more than one project.) Employee computer 1:1

1-many relationship between A and B For each instance of type A there may be many instances of type B; however, for each instance of type B there is no more than one instance of type A. Notation and example: p. 149.

Other possible examples: Course sections Departments employees project employees (participation) Employee computer 1:N

May actually specify a maximum number. Example: Team-players. Number depends on the sport. Sometimes the term parent applies to the entity on the “one side” and child applies to the entity on the “many side”.

Many-many relationship between A and B For each instance of type A there may be many instances of type B, and vice-versa. Notation: p. 149 More examples follow

Students courses (could have several meanings) Authors books Movies actors; advisors students; artist songs Major courses N:M

These are sometimes called HAS-A relationships. A team has players; a student has courses; etc.

Minimum cardinality May specify a minimum number of instances. Can specify whether an instance is mandatory or optional. Examples: p Can you think of more?

A crow’s foot notation (page ) often used to provide a visual of the relationships. We’ll use this notation in subsequent diagrams

Weak entity Cannot exist unless another type of entity exists Employee  dependent (dependent is weak) building  room (room is weak) course  section (section is weak) book has more

ID-dependent entity special type of weak entity in which the ID contains the ID of another entity EX: Rooms on campus have an ID such as MAC 122 (Building ID and room number). Other examples on page 154 All ID-dependent entities are weak A weak entity may not be ID-dependent (example p.155)

Shown in diagram using solid lines (ex. P.154) If the parent entity is removed, so must all child entities. Dashed lines represent non-identifying relationships

Strong entity existence does not depend on another entity. Ex: Students, employees, departments, computer, building, etc.

Difference between strong and weak not always clear. Subject to variances in interpretation of the mode. Kroenke lists possible tests on page 156 and 160

Example: One-to-many relationship between a pharmaceutical company and a drug. One-to-many relationship between an employee and a dependent. Dependent does not exist w/o the employee. Drug does not exist w/o the pharmaceutical company Are drug and dependent both weak?

If the employee is removed the dependent disappears. If the pharmaceutical company disappears, the drug may be assigned to another company. Argues that the drug is strong.

Creating an E-R diagram using Visio: Open Microsoft Office Visio. Select Software and Database under template categories. Select Database Model Diagram as a template. Press the Create button. Drag and drop one or more entity images to your worksheet.

Double click on the icon and, through the properties pane below the worksheet, you can give it a name and define its fields. Drag and drop a relationship icon to the worksheet. Connect each end to an entity.

To get the “crow’s foot” format select Display Options in the database tab Select the Relationship tab check the Crow’s feet checkbox. Double click the relationship icon select miscellaneous under categories Select the appropriate cardinality.

NOTE: Visio does not allow the specification of a many-to-many relationship. Does a poor job as a modeling tool. However, we will see later that ALL many-to-many relationships can be implemented via two one-to-many relationships

Probably best to NOT use visio for true data modeling diagrams. But OK for defining relationships among tables and for this course.

Ternary relationships. Doctor – Patients – Drugs Relationship below does not convey all necessary information patient drug n:m doctor drug n:m prescription prescribes

A specific drug given to a patient must have been prescribed by a doctor. Would need doctor patient drugs

Building a data model: Interview the users of data. Find out how they operate!! Look at existing forms, reports, files, lists, etc. Determine entities. Look for key words such as order, appointment, product, customer, etc.

Specify relationships. Examine all combinations of entities or examine documents obtained from previous steps. Determine what attribute (identifier) uniquely determines an entity.

Determine attributes. Ask whether an attribute should be its own entity. Salesperson has a region: should region be just an attribute or a separate entity? Data models should reflect reality. Problem is one person’s reality may be different than another’s.

See book for examples.

In Class example: Design a data model for a university database.

Using Patterns to design relationships. Asking users what the maximum cardinality is won’t work they won’t know what you’re talking about. You can show them a prototype form or report to learn how many entity objects relate to another. Ex. Show a course form to a user that shows one instructor. The user will likely let you know if other instructors should be shown.

Figure 5-15a on p. 159 Suggests a 1-1 relationship between strong entities member and locker Data model in Figure 5-16

Figure 5-17 on p. 160 Suggests a one-to-many between company and department Figure 5-18 shows the model

Figures 5-19a and 5-19b on p. 161 The form and report suggest a many-to- many relationship between company and part Data model in Figure 5.20

Association pattern: Consider a n:m relationship connecting students and courses (transcript). Where is the grade stored? It is not part of the student entity It is not part of the course entity.

The data model should show a 3 rd entity (transcript?) containing the grade This is analogous to the example from figures 5.21 & 5.22 on p

Multivalued attribute pattern when is an attribute not an attribute Consider a customer entity. Is the phone number an attribute? If just one number, store as an attribute. If multiple numbers, might be a problem since arrays or lists can not be attribute types in a relation.

May create an ID-dependent entity, PHONE, connected to the customer. If just two numbers max, might create a primary and secondary phone number attribute of the customer.

Archetype/Instance pattern One entity represents an instance of another. Prints of a painting Copies of a book Sections of a course

Line Item Pattern Multiple instances of an entity used to describe another entity Ex: Line items to describe an order

Recursive relationships – may be 1:1, 1:n, or n:m A course and it’s prerequisites (n:m). A course may have multiple prerequisites and may be a prerequisite for multiple other courses. Manufacturing (Bill of Materials). Products consists of parts, some of which are composed of other parts. Parts may be included in other parts (p. 173)

Basic ER modeling Define strong and weak entities. Define relationships and categorize as 1:1, 1:n, or n:m The rest allows you to refine for better accuracy.

Subtype entities Similar to inheritance. A subtype entity isa special case of another entity (supertype). Ex. Distinction of male and female patients for medical tests. Ex. Distinction of different types of employees. Diagram notation on page 156 and 158.

Discriminator: supertype attribute that determines the subtype. Ex: patient gender or employee classification. May not always exist. Examples on page 156

An exclusive subtype means the supertype relates to at most one subtype. An inclusive subtype means the supertype can relate to more than one subtype. Ex. A patient is male or female, not both. An employee might be a team leader, programmer, analyst, or all.