Lecture 3 :Database Analysis and Design (II)

Slides:



Advertisements
Similar presentations
ER Model For a college DB
Advertisements

More Diagramming & Practice with Relationship Modeling
Database Design Lessons 2 & 3 Database Models, Entities, Relationships.
Information System Analysis Lab 7. ERD entity-relationship diagram is a data modeling technique that creates a graphical representation of the entities,
Chapter 2.1 V3.1 Napier University Dr Gordon Russell
ENTITY RELATIONSHIP MODELLING
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
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
System Analysis - Data Modeling
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Entity-Relationship Model and Diagrams (continued)
Ch5: Software Specification. 1 Descriptive specifications  Describe desired properties of system  Three types:
Database Design Concepts Lecture 7 Introduction to E:R Modelling Identifying Entities.
Chapter 2 Modeling Data in the Organization
Data Modeling 1 Yong Choi School of Business CSUB.
Entity Relationship Model Chapter 6. Basic Elements of E-R Model Entity Object of the real world that stores data. Eg. Customer, State, Project, Supplier,
Entity Relationship Modeling Objectives: To illustrate how relationships between entities are defined and refined. To know how relationships are incorporated.
DATA MODELING AND DATABASE DESIGN DATA MODELING AND DATABASE DESIGN Part 1.
Entity-Relationship Modeling I The cautious seldom err. Confucius.
IT 244 Database Management System Data Modeling 1 Ref: A First Course in Database System Jeffrey D Ullman & Jennifer Widom.
Module 2: Conceptual Data Modeling with ERD
DeSiamorewww.desiamore.com/ifm1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Data Modeling and Relational Database Design. Analyze and model the relationships between entities Draw an initial entity relationship diagram Read the.
Data Modeling ERM ERD.
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.
Entity Relationship Diagrams
Database Design Sections 6 & 7 Second Normal Form (2NF), Unique Identifiers (UID), Third Normal Form (3NF), Arcs, Hierarchies and Recursive relationships.
Entity Relationship Diagram (ERD) 22 February 2011.
IS 325 Notes for Wednesday September 4, Syllabus Change I eliminated quizzes I increased the points allocated to homework assignments.
Copyright Ó Oracle Corporation, All rights reserved. Normalization Use the student note section below for further explanation of the slide content.Use.
Database Design Sections 9 & 10 Modeling Historical Data, conditional nontranferability, time-related constraints 1.
Database Design Principles – Lecture 3
1.  An introduction to data modelling  The purpose of data modelling  Modelling data relationships 2.
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,
DeSiamorePowered by DeSiaMore1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
IT 21103/41103 System Analysis & Design. Chapter 04 Data Modeling.
ERD ( Conceptual data model From the statement of data requirements a conceptual data model is produced. This describes.
Copyright Ó Oracle Corporation, All rights reserved. Assign Unique Identifiers A Unique Identifier (UID) is any combination of attributes and/or.
Entity/Relationship Modelling. Entity Relationship Modelling In This Lecture Entity/Relationship models Entities and Attributes Relationships Attributes.
The Entity-Relationship Model, P. I R. Nakatsu. Data Modeling A data model is the relatively simple representation, usually graphic, of the structure.
Lecture 91 Introduction to Data Analysis and Logic Specification Objectives l Draw an entity-relationship diagram, and explain the types of entity relationships.
Entity Relationship Diagram (ERD). Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship.
EntityRelationshipDiagrams. Entity Relationship Models The E-R (entity-relationship) data model views the real world as a set of basic objects (entities)
CSE 412/598 DATABASE MANAGEMENT COURSE NOTES 3. ENTITY-RELATIONSHIP CONCEPTUAL MODELING Department of Computer Science & Engineering Arizona State University.
Lecture 5 Entity Relationship Modeling
1 CS 430 Database Theory Winter 2005 Lecture 3: A Fifty Minute Introduction to Data Modeling.
Department of Mathematics Computer and Information Science1 CS 351: Database Management Systems Christopher I. G. Lanclos Chapter 4.
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
Topic 3: ER – Entity Relationship Model (ERM) 6/12/
Entity Relationship Diagram ERD. Background Peter Chen developed ERDs in Charles Bachman and James Martin have added some slight refinements to.
ENTITY RELATIONSHIP DIAGRAM. Objectives Define terms related to entity relationship modeling, including entity, entity instances, attribute, relationship.
1 Database Design Sections 6 & 7 First Normal Form (1NF), Second Normal Form (2NF), Unique Identifiers (UID), Third Normal Form (3NF), Arcs, Hierarchies.
Database Design Chapters 17 and 18.
Entity Relationship Modeling
DATA MODELING AND DATABASE DESIGN
Entity/Relationship Modelling
Entity-Relationship Model
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
Entity-Relationship Model and Diagrams (continued)
MIS2502: Data Analytics Relational Data Modeling
Chapter 2 Modeling Data in the Organization
Entity-Relationship Diagram (ERD)
IT 244 Database Management System
Entity Relation Model Tingting Zhang.
DATA MODELING AND DATABASE DESIGN
Presentation transcript:

Lecture 3 :Database Analysis and Design (II) ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (II) ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Topics covering: Identify and Model Entities Relationships Entity definition Attribute definition ERD and ERM ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Entities Definition Entity An entity is something that can be identified in the user’s work environment; something that the users want to track. Example: Mary Doe, Peter Chen, etc (They are instructors at WTCC.) Entity Classes (also called entity) a collection of the same type of entities. Attribute Attributes, within an entity, describe the entity’s characteristics. E-RM / E-RD Entity-relational diagram is a set of concepts and graphical symbols that can be used to create database. The E-R model was first published by Peter Chen in 1976. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Identify and model entities from a set of interview notes. Examine the nouns. Are they things of significance? Name each entity. Is there information of interest about the entity that the business needs to hold? Is each instance of the entity uniquely identifiable? Which attribute or attributes could serve as its UID? Write a description of it. “An EMPLOYEE has significance as a paid worker at the company. For example, John Brown and Mary Smith are EMPLOYEEs”. Diagram each entity and all of its attributes. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Example: Identify the entities in the following set of information “I’m the manager of a training company that provides instructor-led courses in management techniques. We teach many courses, each of which has a code, a name, and a fee. Introduction to UNIX and C Programming are two of our more popular courses. Courses vary in length from one day to four days. An instructor can teach several courses. Paul Rogers and Maria Gonzales are two of our best teachers. We track each instructor’s name and phone number. Each course is taught by only one instructor. We create a course and then line up an instructor. The students can take several courses over time, and many of them do this. Jamie Brown from AT&T took every course we offer! We track each student’s name and phone number. Some of our students and instructors do not give us their phone numbers.” ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Example Result: “I’m the manager of a training company that provides instructor-led courses in management techniques. We teach many courses, each of which has a code, a name, and a fee. Introduction to UNIX and C Programming are two of our more popular courses. Courses vary in length from one day to four days. An instructor can teach several courses. Paul Rogers and Maria Gonzales are two of our best teachers. We track each instructor’s name and phone number. Each course is taught by only one instructor. We create a course and then line up an instructor. The students can take several courses over time, and many of them do this. Jamie Brown from AT&T took every course we offer! We track each student’s name and phone number. Some of our students and instructors do not give us their phone numbers.” ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Solution The following entities model the Training Company's information requirements. COURSE code name fee duration INSTRUCTOR (TEACHER) name phone number STUDENT name phone number ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Entity Descriptions A COURSE has significance as a training event offered by the Training Company. For Example, Introduction to UNIX and C Programming. A STUDENT has significance as a participant in one or more COURSEs. For example, Jamie Brown. An INSTRUCTOR has significance as a teacher of one or more COURSEs. For example, Paul Rogers and Maria Gonzales. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships A relationship is a two-directional, significant association between two entities, or between an entity and itself (e.g. employee & manager). Relationship Syntax: { } { } Must be or may be relationship name One or more or one and only one Each entity1 each entity2 ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Example: The relationship between INSTRUCTER and COURSE is: Each COURSE may be taught by one and only one INSTRUCTOR Each INSTRUCTOR may be assigned to one or more COURSEs. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Each direction of relationship has: a name – e.g. taught by or assigned to. an optionality – either must be or may be. a degree – either one and only one, or one or more. Quick Notes Cardinality is a synonym for the term degree. A degree of 0 is addressed by may be. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Diagramming Conventions A line between two entities Lower case relationship names Optionality - - - - - - - - - - Optional (may be) ___________ Mandatory (must be) Degree ___________ One and only one ___________ One or more ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Example: many one mandatory optional ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships First read a relationship in one direction, and then read the relationship in the other direction: Example: Read the relationship between EMPLOYEE and DEPARTMENT. assigned to EMPLOYEE DEPARTMENT responsible for Read this relationship first from left to right, and then from right to left. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Relationship from Left to Right (partial diagram) assigned to EMPLOYEE DEPARTMENT Each EMPLOYEE must be assigned to one and only one DEPARTMENT ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Relationship from Right to Left (partial diagram) EMPLOYEE DEPARTMENT responsible for Each DEPARTMENT may be responsible for one or more EMPLOYEEs. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships In class exercises: Exercise 1. Read the relationship between STUDENT and COURSE. enrolled in STUDENT COURSE taken by Write down the relationships. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships In class exercises: Exercise 1. Read the relationship between STUDENT and COURSE. enrolled in STUDENT COURSE taken by Each STUDENT must be enrolled in one or more COURSEs. Each COURSE may be taken by one or more STUDENTs. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships In class exercises: Exercise 2. Read the relationship between PAYCHECK and EMPLOYEE. for PAYCHECK EMPLOYEE the receiver of Write down the relationships. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships In class exercises: Exercise 2. Read the relationship between PAYCHECK and EMPLOYEE. for PAYCHECK EMPLOYEE the receiver of Each PAYCHECK must be for one and only one EMPLOYEE. Each EMPLOYEE may be the receiver of one or more PAYCHECKs. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships There are three types of relationships: Relationship Types Many to One Relationships Many to Many Relationships One to One Relationship All relationships should represent the information requirements and rules of the business. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships A Many to One Relationship (M to 1 or M:1) has a degree of one or more in one direction and a degree of one and only one in the other direction. Quick Notes - M:1 relationships are very common. - M:1 relationships that are mandatory in both directions are rare. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Example: visited by SALES REPRESENTATIVE CUSTOMER assigned to visit Each CUSTOMER must be visited by one and only one SALES REPRESENTATIVE. Each SALES REPRESENTATIVE may be assigned to visit one or more CUSTOMERs. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships A Many to Many Relationship (M to M or M:M) has a degree of one or more in both directions. Example 1: There is a M:M relationship between STUDENT and COURSE. enrolled in STUDENT COURSE taken by Each STUDENT must be enrolled in one or more COURSEs. Each COURSE may be taken by one or more STUDENTs. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Example 2: There is a M:M relationship between EMPLOYEE and JOB. assigned to EMLOYEE JOB Carried out by Each EMPLOYEE may be assigned to one or more JOBs. Each JOB may be carried out by one or more EMPLOYEEs. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships - M:M relationships are very common. - Many to Many relationships that are usually optional in both directions (e.g. EMPLOYEE vs JOB), (this implies that an instance of either entity can exist without an association with the other). - Many to Many Relationship may be optional in just one direction (e.g. STDUDENT vs COURSE). - Many to Many Relationships that are mandatory at both ends are very rare because each is fully dependent on the other for existence. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships A One to One Relationship (1 to 1 or 1:1) has a degree of one and only in both directions. Example: There is a 1:1 relationship between MICROCOMUTER and MOTHERBOARD. the host for MICROCOMPUTER MOTHERBOAD incorporated into Each MICROCOMPUTER must be the host for one and only one MOTHERBOARD. Each MOTHERBOARD may be incorporated into one and only one MICROCOMPUTER. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Quick Notes 1:1 relationships are rare (in the real world, you usually do not see an example, but think about one) Furthermore, A 1:1 Relationship that is mandatory in both directions is very rare (Think about an example) Entities which seem to have a 1:1 relationship may really be the same entity. HUSBAND vs WIFE COUPLE husband wife HUSBAND vs WIFE ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Another Example: There is a 1:1 relationship between INVOICE and ORDER. INVOICE ORDER INVOICE ORDER In this example, although the names order and invoice are different, the data contained in them is probably almost identical. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Relationships Answer: ORDER number type ITEM number description issued for in originated by stored in the originator of the repository for CUSTOMER first name last name WAREHOUSE id address ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming Follow a series of five steps to analyze and model relationships. Determine the existence of a relationship. Name each direction of the relationship. Determine the optionality of each direction of the relationship. Determine the degree of each direction of the relationship. Read the relationship aloud to validate it. ITN 170 - MySQL Database Programming

DETERMINE A RELATIONSHIP’S EXISTENCE Determine the existence of a relationship. Examine each pair of entities to determine if a relationship exists. Existence Name Optionality Degree Validate Ask About a Relationship’s Existence Does a significant relationship exist between ENTITY A and ENTITY B? ITN 170 - MySQL Database Programming

DETERMINE A RELATIONSHIP’S EXISTENCE Name Optionality Degree Validate Example 1 Consider the entities DEPARTMENT and EMPLOYEE. Is there a significant relationship between DEPARTMENT and EMPLOYEE? Yes, there is a significant relationship between DEPARTMENT and EMPLOYEE ITN 170 - MySQL Database Programming

DETERMINE A RELATIONSHIP’S EXISTENCE Name Optionality Degree Validate Example 2 Consider the entities DEPARTMENT and ACTIVITY. Is there a significant relationship between DEPARTMENT and ACTIVITY? No, there is NOT a significant relationship between DEPARTMENT and ACTIVITY. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming NAME THE RELATIONSHIP Existence Name Optionality Degree Validate It is a good working practice to name every relationship in your Entity Relationship Model. In some methodologies, it is optional; and in others, it is mandatory. However, since every relationship represents a business rule and the name reflects that rule, it is sensible to try to name all relationships. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming NAME THE RELATIONSHIP Existence Name Optionality Degree Validate The name that you give to the relationship is important since it reflects your understanding of the business rule that links the entities together. Without a name, a relationship may be misleading, and incorrect assumptions can easily be made. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming NAME THE RELATIONSHIP Existence Name Optionality Degree Validate Name each direction of a relationship. Ask a Relationship’s Name How is an ENTITY A related to ENTITY B? An ENTITY A is relationship name in ENTITY B. How is an ENTITY B related to an ENTITY A? An ENTITY B is relationship name an ENTITY A. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming NAME THE RELATIONSHIP Existence Name Optionality Degree Validate Example Consider the relationship between DEPARTMENT and EMPLOYEE. How is a DEPARTMENT related to an EMPLOYEE? Each DEPARTMENT is responsible for an EMPLOYEE. How is an EMPLOYEE related to a DEPARTMENT? Each EMPLOYEE is assigned to a DEPARTMENT. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming NAME THE RELATIONSHIP Use a list of relationship name pairs to assist in naming relationships. Existence Name Optionality Degree Validate Useful Relationship Name Pairs based on the basis for bought from supplier of description of for operated by the operator for represented by the representation of responsible for the responsibility of Oracle’s suggestion: Do not use related to or associated with as relationship name ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming NAME THE RELATIONSHIP Existence Name Optionality Degree Validate Quick Note: You must not use words such as related to or associated with. The presence of the relationship indicates an association. The name must convey the business rule causing the association. Choose a name that is meaningful within the business being modeled. ITN 170 - MySQL Database Programming

ITN 170 - MySQL Database Programming NAME THE RELATIONSHIP Use a list of relationship name pairs to assist in naming relationships. Existence Name Optionality Degree Validate Useful Relationship Name Pairs based on the basis for bought from supplier of description of for operated by the operator for represented by the representation of responsible for the responsibility of ITN 170 - MySQL Database Programming

DETERMINE THE RELATIONSHIP’S OPTIONALITY Determine the optionality of each direction of the relationship Existence Name Optionality Degree Validate Ask About a Relationship’s Optionality Must ENTITY A be relationship name ENTITY B? Must ENTITY B be relationship name ENTITY A? ITN 170 - MySQL Database Programming

DETERMINE THE RELATIONSHIP’S OPTIONALITY Existence Name Optionality Degree Validate Example Consider the relationship between DEPARTMENT and EMPLOYEE Must an EMPLOYEE be assigned to a DEPARTMENT? Always? Is there any situation in which an EMPLOYEE will not be assigned to a DEPARTMENT? No, an EMPLOYEE must always be assigned to a DEPARTMENT. Must a DEPARTMENT be responsible for an EMPLOYEE? No, a DEPARTMENT does not have to be responsible for an EMPLOYEE. ITN 170 - MySQL Database Programming

DETERMINE THE RELATIONSHIP’S DEGREE Determine the degree of the relationship in both directions Existence Name Optionality Degree Validate Ask about a Relationship’s Degree May ENTITY A be relationship name more than one ENTITY B? May ENTITY B be relationship name more than one ENTITY A? ITN 170 - MySQL Database Programming

DETERMINE THE RELATIONSHIP’S DEGREE Example Existence Name Optionality Degree Validate Consider the relationship between DEPARTMENT and EMPLOYEE May an EMPLOYEE be assigned to more than one DEPARTMENT? No, an EMPLOYEE must be assigned to only one DEPARTMENT. May a DEPARTMENT be responsible for more than one EMPLOYEE? Yes, a DEAPRTMENT may be responsible for one or more EMPLOYEEs. ITN 170 - MySQL Database Programming

DETERMINE THE RELATIONSHIP’S DEGREE Existence Name Optionality Degree Validate Add the relationship degrees to the E-R Diagram. assigned to EMPLOYEE DEPARTMENT responsible for ITN 170 - MySQL Database Programming

VALIDATE THE RELATIONSHIP Re-examine the E-R model and validate the relationship. Existence Name Optionality Degree Validate Read the Relationship Aloud Relationship must be readable and make business sense. assigned to EMPLOYEE DEPARTMENT responsible for Each EMPLOYEE must be assigned to one and only one DEPARTMENT Each DEPARTMENT may be responsible for one or more EMPLOYEEs. ITN 170 - MySQL Database Programming