Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS-39021 Outline: Data modeling using ER-model (Chapter 3 - 3rd, 4th, 5th ed.)

Slides:



Advertisements
Similar presentations
Relational Database Design : ER- Mapping
Advertisements

Data Modeling (CB 12) CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
1 Database Theoretic Basis Entity Relationship (E-R) Modeling Database Theoretic Basis Entity Relationship (E-R) Modeling.
Chapter 31 Chapter 3 Data Modeling Using the Entity-Relationship Model.
Mapping an ERD to a Relational Database To map an ERD to a relational database, five rules are defined to govern how tables are constructed. 1)Rule for.
Databases and Database Users Sept. 2012Yangjun Chen ACS Outline: Introduction (Chapter 1 – 3 rd, 4 th, 5 th, 6 th ed.) What is a database? The main.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Conceptual Models Agenda - Steps in the design of a DB - Need for conceptual models - The Entity-Relationship Model (ER-Model)
ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen1 ER-to-Relational Mapping Principles Specialization/Generalization -Superclass/Subclass Relationship.
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
Sept ER-to-Relational Mapping Principles ER-to-Relational Mapping And examples.
Data modeling using the entity-relationship model Winter 2006Ron McFadyen Entity-relationship model (ER model) P. 49: “This model and its variations.
Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – ER Model.
Mapping ERM to relational database
CS 405G Introduction to Database Systems
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
Data Modeling Using the Entity-Relationship Model
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.
1 DATABASE By Mr. Abdalla A. Shaame.  What is a database?  The main characters of a database system  The basic database design method  The entity-relationship.
Dr. Mohamed Osman Hegaz1 Conceptual data base design: The conceptual models: The Entity Relationship Model.
Entity-Relationship Model. 2 Outline  What is ER Model? And Why?  Overview of Database Design Process  Example COMPANY Database  ER Model Concepts.
Review: Application of Database Systems
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Data Modeling Using the Entity-Relationship
SQL Structured Query Language Programming Course.
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Data Modeling Using the Entity- Relationship (ER) Model.
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:
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
3 & 4 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel Keys Consists of one or more attributes that determine other.
Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Entity-Relationship Model Chapter 3 II COSC 457 Sungchul Hong.
Data Modeling Using the Entity-Relationship (ER) Data Model (Based on Chapter 3 in Fundamentals of Database Systems by Elmasri and Navathe, Ed. 3)
Data Modelling Using Entity-Relationship (ER) Model
advanced data modeling
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 3 Data Modeling Using Entity-Relationship Model.
Data Modeling Using the Entity-Relationship (ER) Data Model.
Data Modeling Using the Entity- Relationship (ER) Model.
Chapter 3: Data Modeling Using the Entity-Relationship (ER) Data Model
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Conceptual Modelling The Entity-Relationship (ER) Model The ER diagram Data Modelling.
Chapter 7 Data Modeling Using the Entity-Relationship (ER) Model
Database Designsemester Slide 1 Database Design Lecture 7 Entity-relationship modeling Text , 7.1.
ENTITY-RELATIONSHIP MODELLING. Objectives: How to use Entity–Relationship (ER) modelling in database design. Basic concepts associated with ER model.
Data Modeling Using the Entity- Relationship (ER) Model
Comp 1100 Entity-Relationship (ER) Model
Chapter 3 Data Modeling Using the Entity-Relationship Model
CS4222 Principles of Database System
Data Modeling Using the Entity- Relationship (ER) Model
Entity- Relationship (ER) Model
ER model Ashima Wadhwa.
Tables and Their Characteristics
Chapter -3- Data Modeling Using the Entity-Relationship Model
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Lecture3: Data Modeling Using the Entity-Relationship Model.
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
بسم الله الرحمن الرحيم.
Outline: Database Basics
Foreign key (FK) is defined as follows:
Initial Design of Entity Types: EMPLOYEE, DEPARTMENT, PROJECT, DEPENDENT Gender.
Conceptual Data Modeling Using Entities & Relationships
Mapping an ERD to a Relational Database
1. Explain the following concepts of the ER data model:
Entity Relation Model Tingting Zhang.
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
Mapping an ERD to a Relational Database
Relational Database Design by ER-to-Relational Mapping
Presentation transcript:

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Outline: Data modeling using ER-model (Chapter 3 - 3rd, 4th, 5th ed.) Data modeling Entity-relationship model -Entity types -strong entities -weak entities -Relationships among entities -Attributes - attribute classification -Constraints -cardinality constraints -participation constraints ER-to-Relation-mapping

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Entity-relationship model (ER model) P. 41-2: “This model and its variations are frequently used for the conceptual design of database applications, and many database design tools employ its concepts.” ER model: is used to create a conceptual data model that reflects all the user data requirements. It includes detailed descriptions of entity types, relationships, and constraints no implementation details so can be used for communication with non-technical users

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Example The company database keeps track of a company’s employees, departments, and projects: Requirements: concerning the department: 1.company is organized into departments 2.a department has a unique name, a unique number, and a specific employee is its’ manager 3.we track the start date for the manager function 4.a department may be in several locations 5.a department controls a number of projects concerning the project: 6.a project has a unique name, a unique number, and is in a single location

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS example continued concerning the employee: 7.each employee has a name, social insurance number, address, salary, sex, and birth date 8.an employee is assigned to one department but may work on several projects which are not necessarily controlled by the same department 9.we track the number of hours per week that an employee works on each project 10.we keep track of the direct supervisor of each employee 11.we track the dependents of each employee (for insurance purposes) concerning the dependent: 12.we record each dependent’s first name, sex, birth date, and relationship to the employee

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS The entities: employee department project dependent

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS The entities: bdate ssn name lname minit fname sex address salary birthdatenamesex relationship name numberlocation name numberlocation employee department project dependent

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS With relationships: employee department project dependent works for manages works on dependents of controls supervision 1 N N 1 NM 1 N 1 1 N 1 supervisor supervisee partial constraint total constraint

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS employee department project dependent With attributes, etc: works for manages works on dependents of controls supervision bdate ssn name lname minit fname sex address salary birthdatenamesex relationship name numberlocation name numberlocation number of employees startdate hours N supervisor supervisee Figure 3.2 P.46 M N 1 1 N N degree 1 N

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Let’s consider a university environment: At a high level, we need to: offer courses register students assign instructors to courses assign grades anything else?

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Concepts (you should understand) Attribute classification simple attribute multivalued attribute composite attribute complex (nested) attributes Attribute storage stored & derived attribute null values not applicable, unknown, missing key attribute domain

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Relationships degree of a relationship recursive relationship role names constraints cardinality: m-n, 1-n, 1-1 participation: partial, total (existence dependency) Concepts (you should understand)

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Entities entity type strong entity -key attribute -entity has a key attribute or a combination of attributes which can be used as a key. weak entity No key attributes. Entities belonging to a weak entity type are identified by being related to specific entities from another entity type in combination with some of their attribute values. - identifying owner - identifying relationship - partial key

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Instructors: let’s assume this classification includes instructors, professors, part-time people (at least for now). These people have SINs, employee numbers, names, addresses, offices, phones,... instructor SIN office address employee no name phonedegree

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor SIN office address employee no name phone Is there a key attribute? What are the domains? Can any attribute be null? Is any attribute composite, derived, complex, multivalued? Is this a weak entity or a strong entity? Should department be an attribute? degree

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Departments: obviously instructors are employed by the University and associated with a department A department has a name, number, office, chair,... department Dnumber chair phone name office

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS department Dnumber chair phone name office Should chair be an attribute, or is there a relationship between two entity types? Is there a key attribute? What are the domains? Can any attribute be null? Is any attribute composite, derived, complex, multivalued?

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS department Employs relationship: If we assume the relationship between department and instructor is 1:N then we only associate each department with a single instructor, but we associate any number of instructors with a single department instructor employs 1N 1:N is the cardinality of the relationship the relationship is of degree 2; it is a binary relationship Both entities are considered strong entities

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Consider some instances department employs instructor d1 d2 d3 e1 e2 e3 e4 e5 e6 e7

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS department Chair relationship: A department has a chair who has special responsibilities. One person (instructor) is designated as such. instructor chair 11 1:1 is the cardinality of the relationship the relationship is of degree 2; it is a binary relationship.

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Continuing the discussion on data modeling Weak entity again Data analysis (at entity instance level) Mapping ER to relational database schema ER model comparison

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Weak entity types a weak entity does not have a key of its own - may have a partial key the identifying relationship will have total participation for the weak entity e.g. consider courses and sections at UWinnipeg

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Consider courses and course sections In the fall and winter we have: /3-001 F Intro Computers staff MW 16:30-17:45 3C /3-002 W Intro Computers staff MW 16:30-17:45 3C /3-050 F Intro Computers staff T 18:00-21:00 3C /3-051 W Intro Computers staff T 18:00-21:00 3C13.. Section numbers are 001, 002, 050, 051, … Sections have a section number, a term, days and times, …

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Consider courses and course sections course 1N Offered-in Section no term meeting Section is a weak entity - it has a discriminator (partial key), section number. Section totally participates in the offered in relationship PK (primary key) of Section is … (offered_in is an identifying relationship) Is meeting multivalued? course no name credit hours description section

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Data analysis: instructorcourse textbook uses teaches m m n n Note that teaches and uses are both binary relationships: we expect situations where a specific Instructor teaches a specific Course, and where a specific Course uses a specific text

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Consider instances instructorcoursetextbook

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Jones and Smith are Instructors instructor course Courses offered are Intro to X, Intro to Y, Z, Advanced X, Advanced Y jones smith Intro to X Z Intro to Y Advanced X Advanced Y

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Consider instances of Instructor teaches Course

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y There is a relationship between Instructor Jones and Course Intro to X

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y This line connects the three dots

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Jones teaches Advanced X

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Jones teaches Advanced X Smith teaches Intro to Y

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Jones teaches Advanced X Smith teaches Intro to Y Smith teaches Advanced Y

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Jones teaches Advanced X Smith teaches Intro to Y Smith teaches Advanced Y Smith and Jones teach Z together There are two relationships: one between Jones and Z; the other between Smith and Z

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse usestextbook jones smith Intro to X Z Intro to Y Advanced X Advanced Y UML distilled The mythical man-month Now let us examine Course uses Textbook Suppose we have two textbooks: The mythical man-month, and UML distilled

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse usestextbook jones smith Intro to X Z Intro to Y Advanced X Advanced Y UML distilled The mythical man-month Intro to Y uses The mythical man-month

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS instructor teachescourse usestextbook jones smith Intro to X Z Intro to Y Advanced X Advanced Y UML distilled The mythical man-month Z uses both texts

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Let’s jump ahead to see what relations we eventually create Section 9.1: ER-to-Relational mapping 1. Create a relation for each strong entity type 2. Create a relation for each weak entity type include primary key of owner (an FK - foreign key) owner’s PK + partial key becomes PK 3. For each binary 1:1 relationship choose an entity and include the other’s PK in it as an FK. Include any attributes of the relationship 4. For each binary 1:n relationship, choose the n-side entity and include an FK w.r.t the other entity. Include any attributes of the relationship

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS For each binary M:N relationship, create a relation for the relationship include PKs of both participating entities and any attributes of the relationship PK is the concatenation of the participating entity PKs 6. For each multivalued attribute create a new relation include the PK attributes of the entity type PK is the PK of the entity type and the multivalued attribute 7. For each n-ary relationship, create a relation for the relationship include PKs of all participating entities and any attributes of the relationship PK may be the concatenation of the participating entity PKs

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS employee department project dependent works for manages works on dependents of controls supervision 1 N N 1 NM 1 N 1 1 N 1 supervisor supervisee

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS division group c composed of div composed of dep composed of department n n n Consider the following requirements (very typical situation) A company may be composed of Divisions, each of which may be composed of Departments, each of which may be composed of Groups. We could model this as follows: company

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS company division group c composed of div composed of dep composed of department n n n It fits the requirements, but it is not flexible it does not accommodate any new groupings it does not allow the company to grow/change it is very rigid => it is a static model

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Consider the following model it is flexible it does accommodate any new groupings it does allow the company to grow/change it is not rigid => it is a dynamic model but not all constraints are implied in the model => we would need supporting application code. What are these constraints? lower_level higher_level m n organization composed of higher_level

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Consider the following model it is flexible, it does accommodate any new groupings, it does allow the company to grow/change, it is a dynamic model again not all constraints are implied in the model => we would need supporting application code. What are these constraints? m n organization composed of organization type example of org composed of m n mn lower_level higher_ level higher_level lower_level Constraint-des

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS organization org-name Dell sell-division... Composed-of org Dell sub-org Sell-division... Production-division Example-of org Dell sell-division org-type company... division organization-type org-type company division... org-composed-of org-type company division... sub-org-type division department constraint 1:n

Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Other common situations: How would we model bill-of-materials? How would we model reporting relationships? How would we model geographical relationships? How would we model procedures and activities? How would we model purchase orders? How would we model documents? … with indexes? … with versions?