Data Modeling for Database Design 2

Slides:



Advertisements
Similar presentations
Chapter # 4 BIS Database Systems
Advertisements

Entity-Relationship (ER) Modeling
Entity Relationship (ER) Modeling
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
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Entity Relationship (ER) Modeling
Entity Relationship (ER) Modeling
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
1 MIS 340: Data Modeling 2 Yong Choi School of Business CSUB.
Data Modeling Yong Choi School of Business CSUB. Part # 2 2 Database Collection of data in electronic format – A digital library of organization Managed.
Mapping from E-R Model to Relational Model Yong Choi School of Business CSUB.
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Introduction to Databases
Entity Relationship Modeling Objectives: To illustrate how relationships between entities are defined and refined. To know how relationships are incorporated.
Yong Choi School of Business CSUB
Entity-Relationship Modeling I The cautious seldom err. Confucius.
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.
Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model.
IS 325 Notes for Wednesday September 18, 2013.
Mapping from Data Model (ERD) to Relational Model Yong Choi School of Business CSUB.
1 Data Modeling 2 Yong Choi School of Business CSUB.
Chapter 5 Entity Relationship (ER) Modelling
BIS 360 – Lecture Six (Part 2) Conceptual Data Modeling (Chapter 10 and partial Chapter 12)
4 1 Chapter 4 Entity Relationship (ER) Modeling Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Concepts and Terminology Introduction to Database.
Mapping from Data Model (ERD) to Relational Model
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
Chapter 4 Entity Relationship (ER) Modeling.  ER model forms the basis of an ER diagram  ERD represents conceptual database as viewed by end user 
4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Relationship Degree Indicates number of entities or participants.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Data Modeling Using the Entity-Relationship (ER) Model.
Chapter 9: Logical Database Design and the Relational Model (ERD Mapping)
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 4 Entity Relationship (ER) Modeling.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 4 ENTITY RELATIONSHIP (ER) MODELING Instructor Ms. Arwa Binsaleh 1.
advanced data modeling
Data Modeling Yong Choi School of Business CSUB. Part # 2 2 Study Objectives Understand concepts of data modeling and its purpose Learn how relationships.
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
Entity Relationship (E-R) Model
Data Modeling Using the Entity- Relationship (ER) Model
Comp 1100 Entity-Relationship (ER) Model
Entity Relationship Modeling
Entity/Relationship Modelling
Databases (CS507) CHAPTER 7.
Logical Database Design and the Rational Model
TMC2034 Database Concept and Design
Tables and Their Characteristics
Database Design – Lecture 4
Data Modeling for Database Design 1
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
بسم الله الرحمن الرحيم.
Data Modelling Introduction
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Database Systems Instructor Name: Lecture-9.
Review of Week 1 Database DBMS File systems vs. database systems
Entities Things about which you need to store data. One entity for each different thing. At least two attributes At least two occurrences Not a property.
CHAPTER 2 - Database Requirements and ER Modeling
Chapter 4 Entity Relationship (ER) Modeling
Entity-Relationship Diagram (ERD)
Guide to Modeling Keys to E-R diagrams.
From conceptual to relational data model
Guide to Modeling Keys to E-R diagrams.
Entity Relationship (ER) Modeling
Chapter # 4 Entity Relationship (ER) Modeling.
Presentation transcript:

Data Modeling for Database Design 2 Yong Choi School of Business CSUB

Steps for creating an ERD 1 Identify entity: look for singular nouns (but avoid a noun w/o attributes) and also avoid proper nouns Identify attribute: look for a descriptor whose values are associated with individual entities of a specific entity type Identify relationship: typically, a relationship is indicated by a verb connecting two or more entities. Identify cardinality: look for the number of occurrences in one entity which are associated to the number of occurrences in another

Entities??? Using original Chen’s notation Made up for class practice…….ambiguous… Using original Chen’s notation ANG Laboratory has several chemists who work on one or more projects. Chemists also may use certain kinds of equipment on each project. The organization would like to store the chemist’s employee identification number, his/her name, up to three phone numbers, his/her project identification number and the date on which the project started. Every piece of equipment, the chemist uses, has a serial number and a cost.

Entities Project Chemist Equipment

Entities’ Attributes??? ANG Laboratory has several chemists who work on one or more projects. Chemists also may use certain kinds of equipment on each project. The organization would like to store the chemist’s employee identification number, his/her name, up to three phone numbers, his/her project identification number and the date on which the project started. Every piece of equipment, the chemist uses, has a serial number and a cost.

entities, attributes and identifiers Chemist Phone# Emp# Project Proj# Start-Date Equipment Serial# cost

Relationships ??? ANG Laboratory has several chemists who work on one or more projects. Chemists also may use certain kinds of equipment on each project. The organization would like to store the chemist’s employee identification number, his/her name, up to three phone numbers, his/her project identification number and the date on which the project started. Every piece of equipment, the chemist uses, has a serial number and a cost.

Entities/Relationships & their Attributes Start-Date Proj# Works-On Project Phone# Emp# Date-Assigned Chemist Uses Serial# Equipment cost Assign-Date

More about Relationship Business rule of a relationship should be bidirectional. Operate in both directions A student has to be enrolled in many curriculums (student to Curr.). Each curriculum might be studied by many students (Curriculum to student).

Degree of Relationship Degree of a Relationship describes the number of entity participation Unary (Recursive) Relationship: One instance related to another of the same entity type Binary Relationship: Instances of two different entities related to each other Ternary Relationship: Instances of three different types related to each other 16

Degree of Relationship … 8

Unary (recursive) Relationship It is possible for an entity to have a relationship to itself—this is called a recursive relationship. Employee Is supervised by supervises

Binary Relationship

Ternary Relationship

Cardinality Notation 1-to-1 relationship 1-to-M relationship M-to-N relationship

Cardinality Notation

Exceptional Notation weak entity relationship recursive relationship Employee

Optionality The Optionality is a property of an attribute which specify if a value is mandatory or optional.  To identify optional relationship, look for auxiliary verb such as can or may

Cardinality The organization would like to store the date the chemist was assigned to the project and the date an equipment item was assigned to a particular chemist working on a particular project. A chemist must be assigned at least to one (or more) project and one (or more) equipment. Projects and equipments must be managed by only one chemist. A given project need not be assigned an equipment.

Complete ER Diagram 1 N Project Chemist 1 N Equipment Works-On Uses Start-Date Proj# Works-On 1 N Project Phone# Emp# Date-Assigned Chemist Uses Serial# 1 N Equipment cost Assign-Date

Weak Entity relationship A weak entity is an entity that cannot be uniquely identified and existed by itself alone. Thus, a weak entity is an entity that exists only if it is related to a set of uniquely determined entities (owners of the weak entity). More examples on the textbook Each employee might have none or multiple dependents. However, dependents must belong to at least one employee. EMP DEP weak entity notation

1:1 relationship A person must have one and only one DNA pattern and eac pattern must be applied to one and only one person. This is a 1:1 mandatory relationship and demonstrates a segmentation denormalization. This is difficult to implement in a database, since declarative referential integrity will get caught in a "Chicken and the Egg" situation. Basically, this is a single entity.

1:1 with optional relationship (OR) on one side A person might not or might be a programmer, but a programmer must be a person. This is a 1:0 relationship; optional only on one side. It is assumed that the mandatory side of the relationship is the dominant. Again, triggers or programs must be used to control the database.

1:M relationship Each department hires many employees, and each employee is hired by one department.

1:M with OR on many side A person might be or might not be a member, but could be found multiple times (if the member entity represents membership in multiple clubs, for instance). A member must have only a single person. This is a 1:M mandatory relationship, the most common one seen in databases. A member must be a person, no questions asked. The foreign key in the member table would be mandatory, or not-null.

1:M with OR on both side A person might have no phone, one phone or lots of phones, and that a phone might be un-owned or can only be owned by a person. This is a 0:M (zero to many) optional relationship. This is implemented in a database as a nullable foreign key column in the phone table that references the person table.

M:N relationship Each student takes many classes, and a class must be taken by many students. STUDENT CLASS IS_TAKEN_BY TAKE ** Many-to-many relationships cannot allowed in the data model because they cannot be represented by the relational model (see the next slide for the reason) **

Example M:N Relationship Table to represent Entity 3 to 3 30 to 30 300 to 300 3000 to 3000 30,000 to 30,000 300, 000 to 300, 000

Example of M:N Many-to-many relationships is a second sign of complex data. When x relates to many y's and y relates to many x's, it is a many-to-many relationship. In our example schema, a color swatch can relate to many types of sweaters and a type of sweater can have many color swatches. 

Transformation of M:N When transform to relational model, many redundancies can be generated. The relational operations become very complex and are likely to cause system efficiency errors and output errors. Break the M:N down into 1:N and N:1 relationships using bridge entity (weak entity). CLASS STUDENT ENROLL

Converting M:N Relationship to Two 1:M Relationships Bridge Entity

Bridge (Associative) Entity ENROLL entity becomes a weak entity of both STUDENT entity and CLASS entity MUST have a composite (unique) identifier STU_NUM (from STUDENT entity) and CLASS_CODE (from CLASS entity) Another MUST know M:N example on the textbook page 63 and 64

M:N with optionality on both side A person might or might not work for an employer, but could certainly moonlight for multiple companies. An employer might have no employees, but could have any number of them. This is a M:M (many to many) optional relationship. Conceptually, it means that Again, not hard to visualize, but hard to implement. Most solutions of this situation involve creating a third "Associative Entity" to resolve the M:M into two 0:M relationships. This might be an entity called employee because it does link the person to the employer the person works for. After broken down, optional relationship notation on both side of associative entity

Recursive relationship Each student is taught by a STA (student teaching assistant). Each STA can teach several students. A recursive relationship is an entity is associated with itself. Student teaches is taught by