Download presentation
Presentation is loading. Please wait.
Published byPeregrine Mosley Modified over 9 years ago
1
Conceptual Modeling with ER Diagrams Peter Chen introduced ER Diagrams
2
E-R Modeling E-R Modeling is a design methodology for modeling the –Entities –Relationships using a diagram with specified shapes for entities, relationships, roles of entities in these relationships, and cardinality.
3
E-R Diagram Conventions Symbol Meaning Entity Type Weak Entity Type Relationship Identifying Relationship Attribute
4
ER-Diagram Conventions - CONTINUED Symbol Meaning Key Attribute Multivalued Attribute Composite Attribute
5
E-R Modeling – Entity Sets, Attributes, Relationships Racquet Club Example A Racquet Club has members with one year or two year contracts. Members pay contract amount up front, quarterly, or monthly. Members may reserve a court for the next day.
6
E-R Modeling – Entity Sets, Attributes, Relationships Racquet Club Example Continued Entity Sets –Members : Name, Start, Contract_Amount, Contract_Period, Initial_Balance, Member_ID –Payments : PayerID, Amount, Paid_Date, Payment_ID –Reservations : Member_ID, CourtNumber, Hour Relations : –Member - Makes – Payment –Member - Makes - Reservation
7
E-R diagrams for several relationship types
8
Data Modeling – Racquet Club Example
9
Keys, Cardinality Constraints and Participation Constraints A key of a relation is a minimal set of attributes and roles which uniquely determine each entity. A cardinality constraint m..n constrains the number of times a single entity can participate in a role of a relationship : m <= times <= n. A participation constraint ensures that an entity will particpate at least this many times.
10
ER-Diagram Cardinality Conventions Symbol Meaning Calculated Attribute Cardinality Constraints and Participation Constraints 0.. * 0.. 1 1.. * 1.. 1
11
Cardinality in the E-R model. 1.. 2 means that at least 1 d must participate in the A relation with C and that not more that 2 d’s can participate. If A is represented by a table, then there is at least one row and not more than 2 rows with a single c value.
12
Two ways to represent single- role key constraints. Cardinality 0..1 can be represented by 0..1 or by
13
Many-to-one, one-to-one, and many-to-many correspondences
14
Example of an E-R diagram with an I S A hierarchy.
15
Using IsA for data partitioning. New York CustomerPennsylvania Customer
16
Participation constraints.
17
Line-based representation vs. cardinality constraints.
18
Entities, Relationships and Attributes A entity is a object or event which needs to be tracked. A relationship relates entities in two or more entity sets. Attributes characterize entity sets and relationships. Employee Project Assigned Name Date
19
Relationship Types – Two Entity Set Relations Project Assigned To Employee Num-Hours Project Will Pay For Fixed-Cost Customer
20
Relationship Types – One & Three Entity Set Relations One Set : ReportsTo( SupID, SubID ) Three Sets : Sale( ProdID, CustID,SuppID;Date) Employee Reports_To subordinate supervisor Customer Product Supplier Sold Date Price
21
ER Diagrams for Payroll Payroll System Entity Sets & Relationships Customers : Name, Address,Phone,CustID Projects : Name,Description,ProjID,Total,CustID Employees : Name,SSNo,PayRate,EmpID TimeSheets : TSID,EmpID,Year,Month LaborCharges : TSID,ProjID,Description,Hours,Amount PayrollChecks : TSID,GrossPay,SSDeduction,WithHolding,NetPay CustomerInvoices : InvID,Year,Month,TotalCharge,SalesTax W2Statements : Year,EmpID,GrossPay,SSPayments,Withholding
22
ER Diagram Customers : Name, Address,Phone,CustID Projects : Name,Description,ProjID,Total,CustID
23
ER Diagrams for Payroll Customer Name Address Phone CustID Projects Name Description Total CustID ProjID Has
24
ER Diagram Employees : Name,SSNo,PayRate,EmpID TimeSheets : TSID,EmpID,Year,Month LaborCharges : TSID,ProjID,Description,Hours,Amount PayrollChecks : TSID,GrossPay,SSDeduction,WithHolding,NetPay
25
ER Diagrams for Payroll Employee Name SSNo PayRate EmpID TimeSheet Year Month EmpID TSID Has PayCheck Has Labor Charges Has TSID... NetPay TSID... Amount
26
The IS-A Relationship Employee Is-A Salaried Employee Hourly Employee disjoint Name SSNo Salary PayRate
27
Construct an ER Diagram Lawn Furniture Manufacturer Stores Information for Catalog of products and parts Stores Information for Manufacturing, including quantity on hand Identify product entities (picnic table and lawn chair) with attributes Identify relationships IsA and PartOf
28
The Part-Of Relationship Picnic_Table Lawn_Chair ProdNo Part_Of OutDoorProducts IsA TopBase Seats Quantity ProdNo Price
29
From ER Diagrams to Relational Database Schema Translating Entities Employee Name SSNo Type HireDate Termination Create Table Employee ( Name char(20), Type char(1), HireDate date, Termination date, SSNo char(9), Primary Key (SSNo) )
30
From ER Diagrams to Relational Database Schema Translating Relationships Customer Product Supplier Sold SaleDate Price Create Table Sold ( SaleDate Date, Price Currency, SaleID autonumber, Customer Integer, Supplier Integer, Product Integer, Primary Key (SaleID), Foreign Key ( Customer ) References Customers( CustID), Foreign Key ( Supplier ) References Suppliers( SuppID ), Foreign Key ( Product ) References Products ProdID ) ) SaleID
31
Translate into Schema Employee Is-A Salaried Employee Hourly Employee disjoint Name SSNo Salary PayRate
32
Translate Into Schema Picnic_Table Lawn_Chair ProdNo Part_Of OutDoorProducts IsA TopBase Seats Quantity ProdNo Price
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.