1 Entity Relationship Approach u Top-down approach to data modeling u Uses diagrams u Normalization - confirms technical soundness u Entity Relationship.

Slides:



Advertisements
Similar presentations
Author: Graeme C. Simsion and Graham C. Witt Chapter 4 Subtypes & Supertypes.
Advertisements

Chapter 2.1 V3.1 Napier University Dr Gordon Russell
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module C Designing Databases and Entity-Relationship.
© McGraw-Hill Companies, Inc., McGraw-Hill/Irwin Extended Learning Module C Designing Databases and Entity-Relationship Diagramming.
ENTITY RELATIONSHIP MODELLING
1 Section 14 - Subtypes/Supertypes u Subtyping –allows our diagram to show several different options at the same time –is useful for concisely representing.
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
Concepts of Database Management Sixth Edition
Normalization of Database Tables
Concepts of Database Management Sixth Edition
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Developing Data Models for Business Databases.
Extended Learning Module C Designing Databases and Entity-Relationship Diagramming McGraw-Hill/Irwin Copyright © 2010 by the McGraw-Hill Companies, Inc.
Chapter 3: Modeling Data in the Organization
Chapter 5 Normalization of Database Tables
Concepts of Database Management Seventh Edition
Chapter 3 © 2005 by Prentice Hall 1 Objectives Definition of terms Definition of terms Importance of data modeling Importance of data modeling Write good.
Systems Analysis I Data Flow Diagrams
Logical Database Design Nazife Dimililer. II - Logical Database Design Two stages –Building and validating local logical model –Building and validating.
Page 1 ISMT E-120 Introduction to Microsoft Access & Relational Databases The Influence of Software and Hardware Technologies on Business Productivity.
Page 1 ISMT E-120 Desktop Applications for Managers Introduction to Microsoft Access.
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,
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred.
3.1 CSIS 3310 Chapter 3 The Entity-Relationship Model Conceptual Data Modeling.
File and Database Design SYS364. Today’s Agenda WHTSA DBMS, RDBMS, SQL A place for everything and everything in its place. Entity Relationship Diagrams.
Databases From A to Boyce Codd. What is a database? It depends on your point of view. For Manovich, a database is a means of structuring information in.
Week 6 Lecture Normalization
Database Systems Marcus Kaiser School of Computing Science Newcastle University.
Business Process Modeling
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
Chapter 7 Using Data Flow Diagrams
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
Data Modelling – ERD Entity Relationship Diagram’s Entity Relationship Diagrams and how to create them. 1.
Concepts and Terminology Introduction to Database.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Databases From A to Boyce Codd. What is a database? It depends on your point of view. For Manovich, a database is a means of structuring information in.
Chapter 2 Data Models Database Systems: Design, Implementation, and Management, Rob and Coronel Adapted for INFS-3200.
Database Systems: Design, Implementation, and Management Tenth Edition
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
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 Eighth Edition Chapter 6 Database Design 2: Design Method.
Concepts of Database Management Sixth Edition Chapter 6 Database Design 2: Design Method.
1 Entity-Relationship Diagram. 2 Components of ERD: –Entity –Relationship –Cardinality –Attributes.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
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.
1 IRU – database design part one Geoff Leese September 2009.
Lecture 4 Conceptual Data Modeling. Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship,
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Concepts of Database Management, Fifth Edition Chapter 6: Database Design 2: Design Methodology.
An Entity Relationship (ER) Diagram is a graphic that shows the interrelationship between entities in a database.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management
1 6 Concepts of Database Management, 5 th Edition, Pratt & Adamski Chapter 6 Database Design 2: Design Methodology Spring 2006.
Logical Database Design and the Relational Model.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
1 Database Design - Normalization u Normalization are a set of techniques for organizing data into tables in order to... –Eliminate most redundancy –Prevent.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Database Design Chapters 17 and 18.
Logical Database Design and the Rational Model
MIS2502: Data Analytics Relational Data Modeling
Database Design Chapters 17 and 18.
MIS2502: Data Analytics Relational Data Modeling 2
Presentation transcript:

1 Entity Relationship Approach u Top-down approach to data modeling u Uses diagrams u Normalization - confirms technical soundness u Entity Relationship - reflects business requirements

2 Using Diagrams u Define a procedure for representing existing models u Develop diagrams directly from business requirements u Business-oriented terminology based on... –Entities (things of interest to business) –Relationships between entities

3 Hospital Example u Graphic 2-13 u Format does not encourage a quick appreciation of the main concepts and rules –e.g. Each operation can be performed by only one surgeon but this is not immediately apparent u This is a very simple model, as we progress to more complex models the problem of presentation becomes more serious

4 Data Model Diagram u Sometimes called data structure diagram, they are based on two symbols –A "box" represents a table (a rounded rectangle is usually used) –A line drawn between two boxes represents a foreign key pointing back to the table that has the primary key

5 Existing Tables u Simply draw a box for every table in the model with the name of it inside u Graphic 3-2

6 Existing Relationships u Draw a line between the two boxes and indicate the direction of the link by putting a "crows foot" at the foreign key end –Think of the crows foot as an arrow pointing back to the table with the primary key u Graphic 3-3

7 Interpreting the Diagram u The model specifies a Surgeon table (data about surgeons) u The model specifies an Operation table (data about operations) u Each Operation can be associated with only one surgeon u Each Surgeon can be associated with many Operations

8 Summarizing Relationships u This represents the relationship between tables (implied by the primary and foreign keys) without having to list any column names at all

9 Asking Questions u We could now ask the business specialist –Is it true that each operation is performed by one surgeon only? –Can we count on this in the future? u We can make changes now (in the model) while the cost is still low u Question: If more than one Surgeon is allowed, how would we handle it?

10 Another Solution u We could choose to track only the surgeon who managed the operation u Record decisions like this in the diagram –Avoids the question being revisited –Specifies precisely what data will be held u Cannot answer question - "In how many operations did surgeon number 12 at hospital number 18 participate?"

11 Annotated Relationship u Graphic 3-4 u As well as annotating the diagram, we should change the column name from Surgeon Number to Managing Surgeon Number

12 Optionality u What if there are no surgeons required for an operation? –e.g. a small cut with antibiotics given u Operation table may have a NULL value for Surgeon Number u To show the difference between optional or mandatory relationships use the convention shown in Graphic 3-5

13 Exercise u Draw the relationships for the rest of the model

14 First Pass u Graphic 3-6 u Checking the diagram will often reveal unsound assumptions and misunderstandings u Conversely, it may increase confidence in the model for both user and designer

15 Operation and Operation Type u Are we sure that each operation can be of only one type? u How would we represent a gall bladder removal and appendectomy operation? –1. Allow only "simple" operations - need a new table for repeating group –2. Allow complex operation types such as "Combined Gall Bladder removal and Appendectomy"

16 Both will Work u Option 2 will be easier to implement u Option 1 will be more elegant –Can ask "list all operations that involved appendectomies"

17 Redundant Lines u Note the Lines connecting Hospital, Operation, and Surgeon tables –line from Hospital to Surgeon –line from Surgeon to Operation –line from Operation to Hospital »Does this line add anything to our knowledge of the business rules?

18 Rules for Removing Lines u Graphic 3-7 u If A derives B and B derives C than an A derives C connecting line is not needed –If B is optional, than we cannot remove the A derives C line –If A derives C provides different information than A derives B we can not remove A derives C

19 Exercise u Remove the remaining Redundant lines from Graphic 3-7

20 Solution u Graphic 3-8

21 Top-Down Approach u Why Normalize at all? Why not just use this Top-down E-R approach? u In practice this is what is most often done, with Normalization being a final check u Using E-R first... –we can start with "What data do we need to keep information about –no need to start with a single overly complex table

22 Terminology u The Relational Models (used with Normalization) were built on three basic concepts: tables, columns, and keys u The E-R Models: Entities, Attributes, and Relationships u Easier to say, "The relationship between a hospital and surgeon", then "the existence of the primary key of Hospital as a foreign key in the Surgeon table"

23 Entities u An entity is the "real world" class of things that a table represents –entities: St. John's Hospital –entity type: Hospital u In practice: Entity means Entity type and Entity Instance (row) for Entity

24 Entities - continued u Some things will need to be represented by more than one entities –e.g. Invoices would be represented by two entities: Invoice Header and Invoice Item –e.g. Quarterly Profit would be derived from sales and expense figures from other entities

25 Multiple "Things" as One Entity u Example... –Preferred Customer –Corporate Customer –Becomes a Customer Type with a Customers Table

26 Entity Naming u The name of an entity must be in the singular. (Exactly the opposite of what it says in the SQL book!) –e.g. Account instead of Accounts u Three reasons: –Consistency - standards –Communication - an 'entity is something we need to keep information about –Compatibility with Relationship Name - (we'll look at this later)

27 Relationships u The lines between the boxes are the relationships between the entities u We name relationships in both directions –"Each company may issue one or more shares" –"Each share must be issued by one company" u Graphic 3-9 show notation were using u Graphic 3-10 shows alternative diagramming notations

28 Exercise u Draw the E-R model that would represent the relationship between a Manager and Departments within his company. A Manager may be in charge of more than one department

29 Solution and More Examples u Graphic 3-11 u Graphic 3-12

30 Suggested Diagramming Tips u Orient your diagram so that the Crows feet are nearer to the bottom of the page u Place Crow's feet on the right u Eliminate crossing lines where possible (but clarity is most important u Duplicate Entities to avoid long relationship lines –Can use a dotted-line to connect the same entity

31 Many-to-Many Relationships u Many-to-Many Relationships are frequently modeled u Graphic 3-13 u How would we implement the relationship using foreign keys?

32 We Can't u We can't hold the key to Qualification in the Employee table because an Employee could have several qualifications u Like wise the Qualification table would need to support multiple Employee Keys u A Normalized model cannot represent many-to-many relationships with foreign keys, yet such relationships certainly exist

33 Representing Many-to-Many u Can't use foreign keys u Can use a table

34 Normalized Many-to-Many u Graphic 3-16 u Whenever we encounter a many-to-many relationship between two entities we represent it with a new entity linked to the two original entities. u The Primary keys of each original table become together become the Primary Key of the new entity ("the resolution entity")

35 Choice of Representation u Conceptual vs. Physical Model u Conversion is not totally mechanical –New Non-key attributes in the resolution entity? –Different Name for the resolution entity? »e.g. instead of Employee-Qualification table we might use "Certifications" table

36 One-to-One Relationships u Should not automatically combine the entities into a single entity u When to split –distinct real-world concepts (e.g. Person- Passport) –Separating attribute groups (e.g. Detail vs. default) –Transferables (e.g. Part type -stored in-Bin)

37 Self-Referencing Relationships u Graphic 3-18 u Each employee may manage one or more employees u Each employee may be managed by one employee –carry the foreign key in the same table as the Primary key –e.g. Manager Id -> Employee Id

38 Attributes u Sometimes show a few attributes to clarify meaning (e.g. Primary, Foreign keys) u Don't show all the attributes, because we want the big picture u Keep in separate lists for each entity

39 More Normalization u If in the process of listing attributes, we find repeating groups or lookup tables –Normalize the design –Update the E-R model

40 Summary u Data models can be presented diagrammatically by using a box to represent each table and a line for each foreign key relationship u This provides a language for "top-down" data models; prior to developing attributes u Many-to-Many relationships are resolved with a "resolution entity"

41 Last Slide - Entity Relationship u Assignment #10 due next week