Data Modeling and Entity-Relationship Model I

Slides:



Advertisements
Similar presentations
Chapter # 4 BIS Database Systems
Advertisements

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.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 4 Entity Relationship (ER) Modeling.
IT420: Database Management and Organization
Data Modeling and the Entity-Relationship Model
Data Modeling and the Entity-Relationship Model
Data Modeling and Entity- Relationship Model II. IST2102 I want a database to maintain departments in my company. Store information about my employees,
Copyright © 2015 Pearson Education, Inc. Database Design Chapters 17 and
Modeling the Data: Conceptual and Logical Data Modeling
© 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke
Database Design Chapter 2. Goal of all Information Systems  To add value –Reduce costs –Increase sales or revenue –Provide a competitive advantage.
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Systems Analysis and Design in a Changing World, 6th Edition
Chapter 4 Entity Relationship (ER) Modeling
Database Systems: Design, Implementation, and Management Tenth Edition
Slide 1 Chapter 05 – Part 1 Data Modeling with the Entity-Relationship Model.
Data Modeling and Entity- Relationship Model I IST2101.
COURSE REGISTRATION SYSTEM Case study IST2101. Case Study: Course Registration (1) IST2102 You are helping Penn State create a course registration system.
Entity Relationship Modeling Objectives: To illustrate how relationships between entities are defined and refined. To know how relationships are incorporated.
Data Modeling and the Entity-Relationship Model Chapter Four DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Entity-Relationship Diagrams
1 © Prentice Hall, 2002 Chapter 3: Modeling Data in the Organization Modern Database Management 7th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R.
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.
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 7 Data Modeling with Entity Relationship Diagrams Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Database. Basic Definitions Database: A collection of related data. Database Management System (DBMS): A software package/ system to facilitate the creation.
Module Title? Data Base Design 30/6/2007 Entity Relationship Diagrams (ERDs)
Chapter 5 Entity–Relationship Modeling
1 ER Modeling BUAD/American University Entity Relationship (ER) Modeling.
DATABASE DESIGN I IST 210: Organization of Data IST210 1.
1 Relational Databases and SQL. Learning Objectives Understand techniques to model complex accounting phenomena in an E-R diagram Develop E-R diagrams.
© Pearson Education Limited, Chapter 7 Entity-Relationship modeling Transparencies.
Unit 3 Conceptual Data Modeling. Key Concepts Conceptual data modeling process Classes and objects Attributes Identifiers, candidate keys, and primary.
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 
Data Modeling IST210 Class Lecture.
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.
3 & 4 1 Chapters 3 and 4 Drawing ERDs October 16, 2006 Week 3.
Chapter 7 Data Modeling with Entity Relationship Diagrams
Msigwaemhttp//:msigwaem.ueuo.com/1 Database Management Systems (DBMS)  B. Computer Science and BSc IT Year 1.
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
Database Design I (In-Class Exercise Answer) IST 210: Organization of Data IST2101.
MIS2502: Data Analytics Relational Data Modeling
Chapter 3: Modeling Data in the Organization. Business Rules Statements that define or constrain some aspect of the business Assert business structure.
Entity Relationship Diagram (ERD). Objectives Define terms related to entity relationship modeling, including entity, entity instance, attribute, relationship.
Chapter 8 Entity-Relationship Modeling Pearson Education © 2009.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
Database Design I IST 210: Organization of Data IST2101.
ERD :: 19 / 1 / Entity-Relationship (ER) Modeling. ER Modeling is a top-down approach to database design. Entity Relationship (ER) Diagram –A.
DATA MODELING AND ENTITY-RELATIONSHIP MODEL II IST 210: Organization of Data IST210 1.
Copyright © 2014 Pearson Canada Inc. 5-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5a Database Design Part 2: Using Information Technology.
Database Design Chapters 17 and 18.
Entity Relationship Modeling
Data Modeling and the Entity-Relationship Model
Requirements Become the E-R Data Model
IST 210: Organization of Data
MIS2502: Data Analytics Relational Data Modeling
Data Modeling and the Entity-Relationship Model
Database Design Chapters 17 and 18.
MIS2502: Data Analytics Relational Data Modeling 2
Data Modeling and the Entity-Relationship Model
Presentation transcript:

Data Modeling and Entity-Relationship Model I IST210 Data Modeling and Entity-Relationship Model I IST 210: Organization of Data

Question: Where do relations come from? IST210 Question: Where do relations come from? Suppose you are now designing database for a company, how should you systematically turn user requirements into actual relations?

YOUR JOB! User requirement A database IST210 I want a database to maintain departments in my company. Store information about my employees, their projects and assignments. I want …. User requirement $$$ YOUR JOB! A database

Use Normalization Process to Design a Database? IST210 Use Normalization Process to Design a Database? One Approach List all data attributes that will be involved DepartmentName, BudgetCode, OfficeNumber, DepartPhone, EmployeeNumber, EmployeeName, EmpPhone, Email, ProjectID, ProjectName, … Develop functional dependencies EmployeeNumber  (EmployeeName, EmpPhone, Email) Normalization process Problems of this approach Lack of a systematic approach to identify all relevant attributes

YOUR JOB! User requirement A database IST210 I want a database to maintain departments in my company. Store information about my employees, their projects and assignments. I want …. User requirement $$$ Data Modeling (Ch.4) YOUR JOB! Database Design (Ch.5) A database

IST210 Two-Step Approach Data Modeling (Ch.4) Database Design (Ch.5)

Two-Step Approach: Step 1 IST210 Two-Step Approach: Step 1 Data Modeling (Ch.4) Database Design (Ch.5) Input: User requirement; Output: E-R Diagram Use Entity-Relationship Diagram (E-R Diagram) to capture all user requirements

Two-Step Approach: Step 2 IST210 Two-Step Approach: Step 2 Data Modeling (Ch.4) Database Design (Ch.5) Input: E-R diagram; Output: A database Transferring a data model to a relational database Entities  Relations Relationships  Foreign keys and extra

Three Stages of Database Development IST210 Three Stages of Database Development Stage 1. Requirements Analysis E-R model is a prototype of actual database system The prototypes are used to obtain feedback from system users Why can’t we skip stage 2? Stage 2. Entity-Relationship Model * Logical Stage Stage 3. Database Design * Physical Stage

Three Stages of Database Development IST210 Three Stages of Database Development Requirements Analysis Stage Users are interviewed Obtain sample forms, reports, queries, … Component Design Stage Create a data model Data model: a presentation of the content, relationships, and constraints of the data needed to support the requirements Implementation Stage Data model transformed to database design Database design: tables, relationships, and constraints Database constructed and filled with data; queries, forms, and reports are created; application programs are written; and all these are tested Users trained, documentation written, system installed for use

The Requirements Stage IST210 The Requirements Stage Sources of requirements User Interviews Forms Reports Queries Business Rules Use Cases Stories/Scenarios

E-R Model Components E-R Models consist of Entities Relationships Attributes Identifiers Relationships

Entities An entity is something that users want to track IST210 Entities An entity is something that users want to track Customer, Order, Product An entity instance of a specific occurrence of an entity A customer John, an order 10021, a product A42300

Attributes Each attribute has a data type and properties IST210 Attributes An entity has attributes that describe the entity’s characteristics Customer entity Customer name, email address, phone, home address, … Each attribute has a data type and properties Data type: string, number, date, … Property: default value, value range, …

Identifiers Entity instances have identifiers IST210 Identifiers Entity instances have identifiers An identifier will identify a particular instance in the entity class StudentID EmployeeID DepartmentName Identifier can be considered as the primary key for a relation

IST210 Draw an Entity Entity Name  Identifier  Attributes 

In-Class Exercise A-1: Entity IST210 In-Class Exercise A-1: Entity I want a course registration database. Store information about my students, including their IDs, names, and emails. A course should have information about course ID, course name, and instructor name. How many entities do you need? Draw a diagram for each entity using the presentation in the previous slide

In-Class Exercise A-1: Entity IST210 In-Class Exercise A-1: Entity I want a course registration database. Store information about my students, including their IDs, names, and emails. A course should have information about course ID, course name, and instructor name. STUDENT COURSE StudentID CourseID StudentName Email CourseName Instructor

In-Class Exercise B-1: Entity IST210 In-Class Exercise B-1: Entity I am the manager for apartment rental office. I want a database to maintain all my apartments. Each apartment building will have a building name, address, city, state, and zip code. A building has many apartments. An apartment has an apartment number, number of bedrooms, number of bathrooms, and monthly rent cost. How many entities do you need? Draw a diagram for each entity

In-Class Exercise B-1: Entity IST210 In-Class Exercise B-1: Entity I am the manager for apartment rental office. I want a database to maintain all my apartments. Each apartment building will have a building name, address, city, state, and zip code. A building has many apartments. An apartment has an apartment number, number of bedrooms, number of bathrooms, and monthly rent cost. BuildingID Name Address City State Zip BUILDING BuildingID ApartmentID NumberOfBed NumberOfBath Rent APARTMENT

E-R Model Components E-R Models consist of Entities Relationships Attributes Identifiers Relationships

IST210 Relationships Entities can be associated with one another in relationships Relationship degree defines the number of entity classes participating in the relationship Degree 2 is a binary relationship A relationship connects two entities Most common relationship Our course will only use binary relationship Degree 3 is a ternary relationship Degree 1 is a recursive (unary) relationship

Degree 2 Relationship: Binary IST210 Degree 2 Relationship: Binary BUILDING STUDENT Have Register APARTMENT CLASS

Degree 3 and Degree 1 Relationship IST210 Degree 3 and Degree 1 Relationship USER Friending Our course will only use binary relationship (relationship between two entities)

Relationship Cardinality IST210 Relationship Cardinality Relationships are named and classified by their cardinality, which is a word that means count Maximum Cardinality One-One, One-Many, Many-Many Minimum Cardinality Optional, Mandatory

IST210 Maximum Cardinality Maximum cardinality is the maximum number of entity instances that may participate in a relationship instance — one, many or other some fixed number

One-to-One Relationship IST210 One-to-One Relationship 1:1 (one-to-one) A single entity instance in one entity class is related to a single entity instance in another entity class An employee may have no more than one locker A locker may only be accessible by one employee

One-to-Many Relationship IST210 One-to-Many Relationship 1:N (one-to-many) A single entity instance in one entity class is related to many entity instances in another entity class A video in YouTube is uploaded by one user A user may upload several videos UPLOAD 1:N USER VIDEO

Many-to-Many Relationship IST210 Many-to-Many Relationship N:M (many-to-many) Many entity instances in one entity class is related to many entity instances in another entity class A YouTube user may subscribe several channels A particular channel may be subscribed by several users SUBSCRIBE N:M USER CHANNEL

Maximum Cardinality: Crow’s Foot Notation IST210 Maximum Cardinality: Crow’s Foot Notation One Many (crow’s foot) An employee has (at most) one locker; a locker can belong to (at most) one employee EMPLOYEE LOCKER A user can upload many videos; a video can be uploaded by (at most) one user USER VIDEO Attention: do not misplace one and many notations A user can subscribe to many channels; a channel can be subscribed by many users USER CHANNEL

Maximum Cardinality: Exercise IST210 Maximum Cardinality: Exercise How to determine maximum cardinality? (1) user requirement; (2) common sense Which design is most suitable? upload (A) USER VIDEO (B) USER VIDEO USER VIDEO (C) USER VIDEO (D)

Maximum Cardinality: Exercise IST210 Maximum Cardinality: Exercise How to determine maximum cardinality? (1) user requirement; (2) common sense Which design is most suitable? subscribe (A) USER CHANNEL (B) USER CHANNEL USER CHANNEL (C) USER CHANNEL (D)

In-Class Exercise: Maximum Cardinality IST210 In-Class Exercise: Maximum Cardinality In-Class Exercise A-2 Draw a line between STUDENT and COURSE Draw the Maximum Cardinality on the line using Crow’s foot notation In-Class Exercise B-2 Draw a line between BUILDING and APARTMENT Draw the Maximum Cardinality on the line using Crow’s foot notation

In-Class Exercise: Maximum Cardinality IST210 In-Class Exercise: Maximum Cardinality In-Class Exercise A-2 Draw a line between STUDENT and COURSE Draw the Maximum Cardinality on the line using Crow’s foot notation STUDENT COURSE StudentID CourseID StudentName Email CourseName Instructor

In-Class Exercise: Maximum Cardinality IST210 In-Class Exercise: Maximum Cardinality In-Class Exercise B-2 Draw a line between BUILDING and APARTMENT Draw the Maximum Cardinality on the line using Crow’s foot notation BUILDING APARTMENT BuildingID BuildingID ApartmentID Name Address City State Zip NumberOfBed NumberOfBath Rent

IST210 Minimum Cardinality Minimum cardinality is the minimum number of entity instances that must participate in a relationship instance These values typically assume a value of zero (optional) or one (mandatory) Crow’s foot notation Mandatory Optional

Minimum Cardinality Mandatory Optional IST210 Minimum Cardinality Mandatory Optional Minimum cardinality notation is closer to the middle An employee may have a locker; a locker must belong to an employee EMPLOYEE LOCKER Maximum cardinality notation is closer to entity

Minimum Cardinality: Crow’s Foot Notation IST210 Minimum Cardinality: Crow’s Foot Notation Mandatory Optional An employee must have a locker; a locker must belong to an employee EMPLOYEE LOCKER An employee must have a locker; a locker may belong to an employee EMPLOYEE LOCKER An employee may have a locker; a locker must belong to an employee EMPLOYEE LOCKER An employee may have a locker; a locker may belong to an employee EMPLOYEE LOCKER

Minimum Cardinality: Exercise IST210 Minimum Cardinality: Exercise Mandatory Optional USER VIDEO What does the cardinality mean? (A) A user must upload many videos; a video may belong to a user (B) A user may upload many videos; a video must belong to a user (C) A user may upload many videos; a video may belong to a user (D) A user must upload many videos; a video must belong to a user

Minimum Cardinality: Exercise IST210 Minimum Cardinality: Exercise How to determine Minimum cardinality? (1) user requirement; (2) common sense Which design is most suitable? upload (A) USER VIDEO (B) USER VIDEO USER VIDEO (C) USER VIDEO (D)

Minimum Cardinality: How to determine? IST210 Minimum Cardinality: How to determine? How to determine minimum cardinality? user requirement; common sense In most cases, the minimum cardinalities are optional, unless one entity is dependent on another entity Example: A video cannot be uploaded without a user; a user can exist without uploading a video

Minimum Cardinality: How to determine? (cont.) IST210 Minimum Cardinality: How to determine? (cont.) * We will never have mandatory – mandatory relationship. Why? An employee must have a locker; a locker must belong to an employee EMPLOYEE LOCKER This design looks fine.But it will cause problem when you insert data records! When you insert a new data record on employee A, he must already have an assigned locker B. But when you insert the locker B, it must already be assigned to employee A. So, one cannot be inserted without the other one already exists! Conflict!

Minimum Cardinality: Exercise IST210 Minimum Cardinality: Exercise How to determine minimum cardinality? (1) user requirement; (2) common sense Which design is most suitable? subscribe (A) USER CHANNEL (B) USER CHANNEL (C) USER CHANNEL (D) USER CHANNEL

In-Class Exercise: Minimum Cardinality IST210 In-Class Exercise: Minimum Cardinality In-Class Exercise A-3 Add Minimum Cardinality symbols on the line of the relationship STUDENT COURSE StudentID CourseID StudentName Email CourseName Instructor

In-Class Exercise: Minimum Cardinality IST210 In-Class Exercise: Minimum Cardinality In-Class Exercise B-3 Add Minimum Cardinality symbols on the line of the relationship BUILDING APARTMENT BuildingID BuildingID ApartmentID Name Address City State Zip NumberOfBed NumberOfBath Rent

Multiple Relationships between Entities IST210 Multiple Relationships between Entities STUDENT CLUB StudentID president ClubID Name Email ClubName Description member Sometimes, there could multiple relationships with different semantic meanings between two entities. In the above example, a club will have a student as the president. Students can also become the members of the club.

Multiple Relationships between Entities IST210 Multiple Relationships between Entities USER PRODUCT UserID Sell ProductID Name Email Name Description Buy A product must be sold by a user. A user could also buy many products.

Crow’s Foot Symbols: Summary IST210 Crow’s Foot Symbols: Summary In our course, we will use Crow’s foot notation to represent the maximum and minimum cardinalities of relationships Mandatory Optional Minimum cardinality USER VIDEO Maximum cardinality One Many

E-R Diagram E-R Diagram: Entity-Relationship Diagram IST210 E-R Diagram E-R Diagram: Entity-Relationship Diagram (1) entity; (2) identifier; (3) attributes; (4) relationship A complete E-R Diagram represented using Crow’s Foot notation In this E-R diagram, there are two entities and one relationship USER VIDEO UserID Video ID Name Address Email Title Description Length upload

Summary Entity Attributes Identifier Relationship IST210 Summary Entity Attributes Identifier Relationship Maximum cardinality One, many Minimum cardinality Optional, mandatory Know how to use Crow’s foot notations to draw an E-R diagram