This document discusses entity relationship modeling concepts including:
- Typical business relationships between entities like products, customers, suppliers, and orders
- Relationship complexities like unary, binary, and ternary relationships
- Characteristics of a good data model like being pictorial, rigorous, and minimizing redundancy
- Normalization forms like first, second, and third normal form and how they reduce data anomalies
- Keys and normal forms help structure relationships and attributes to eliminate updating problems.
3. Typical Business Relationships PRODUCTS CUSTOMERS are purchased by SUPPLIERS PRODUCTS supply ORDERS PRODUCTS contain ORDERS CUSTOMERS are placed by EMPLOYEES OFFICES are assigned to PRODUCTS STORES are sold in
4. Relationship Complexities (a) (b) (c) EMPLOYEE OFFICE EMPLOYEE DEPARTMENT STUDENT COURSE Each EMPLOYEE must be assigned to one and only one OFFICE . Each OFFICE may be assigned to one and only one EMPLOYEE. Each EMPLOYEE must be assigned to one and only one DEPARTMENT . Each DEPARTMENT may be in charge of zero or more EMPLOYEEs. Each STUDENT may be registered for zero, one, or many COURSEs . Each COURSE may be taken by zero, one, or many STUDENTs. assigned to assigned to assigned to in charge of registered for taken by
5. Unary Relationship PERSON COURSE EMPLOYEE married to is a prerequisite for has as a prerequisite managed by manage Each PERSON may be married to one and only one PERSON. Each COURSE may have zero, one, or many prerequisite COURSEs. Each COURSE may be a prerequisite for zero, one, or many COURSEs. Each EMPLOYEE must be managed by one and only one EMPLOYEE. Each EMPLOYEE may manage zero, one, or many EMPLOYEEs.
6. Binary Relationship EMPLOYEE STUDENT COURSE assigned to assigned to Each EMPLOYEE must be assigned to one and only one OFFICE. Each OFFICE may be assigned to one and only one EMPLOYEE. Each STUDENT may be registered for zero, one, or many COURSEs. Each COURSE may be taken by for zero, one, or many STUDENTs. Each CUSTOMER may place zero, one, or many ORDERs. Each ORDER must be placed by one and only one CUSTOMER. OFFICE CUSTOMER ORDER registered for taken by place placed by
7. Ternary Relationship STUDENT MAJOR ADVISOR Each STUDENT must have declared one or more MAJORs and be assigned to one or more ADVISORs. Each ADVISOR must be assigned to one or more STUDENTs and be responsible for one or more MAJORS. Each MAJOR must be declared by one or more STUDENTs and be assigned to one or more ADVISORs.
8. Associative Entity PASSENGER SCHEDULED FLIGHTS PASSENGER SCHEDULED FLIGHTS RESERVATION make reservation reserved by (a) (b)
9. Reading Relationships Each… entity1 relationship entity2 Each… CUSTOMER may be placing one or more ORDERS. ORDER must be placed by one and only one CUSTOMER must be or may be one or more or one and only one { } { }
10. Characteristics of a Good Data Model Characteristic Explanation Pictorial A good data model should be an accurate graphical depiction of the entities and their relationships Rigorous and Specific A good data model should be specific with regard to the identification of all entities and their relationships and rigorous in the identification and specification of the attributes associated with each entity. Top-down Decomposable A good data model should be decomposable in the sense that the level of detail for each entity and its associated attributes can be investigated at various levels of detail or aggregation. Provide Focus A good data model should be focused on the data associated with a single system and contained within a single system boundary. Minimally Redundant A good data model will display minimal redundancy with regard to repeated entity types, data redundancy, and many-to-many relationships. Transparent The actual data and the physical structure of the database should be discernable from looking at the graphical data model. Easily Navigated A good data model should be laid out in an organized fashion to allow for the relationships among the entities to be easily followed. Predicts the Final System A good data model should be an accurate prediction of the physical implementation of the system.
11. First Normal Form ORDER ORDER NUMBER ORDER DATE CUSTOMER NUMBER CUSTOMER NAME CUSTOMER STREET CUSTOMER CITY CUSTOMER STATE CUSTOMER ZIPCODE CUSTOMER PHONE ORDERED PRODUCT (repeats 1 – n times) PRODUCT ID QUANTITY DESCRIPTION UNIT PRICE EXTENDED PRICE ORDER SUBTOTAL SALES TAX SHIPPING ORDER TOTAL ORDER ORDER NUMBER ORDER DATE CUSTOMER NUMBER CUSTOMER NAME CUSTOMER STREET CUSTOMER CITY CUSTOMER STATE CUSTOMER ZIPCODE CUSTOMER PHONE ORDER SUBTOTAL SALES TAX SHIPPING ORDER TOTAL ORDERED PRODUCT PRODUCT ID + ORDER NUMBER QUANTITY DESCRIPTION UNIT PRICE EXTENDED PRICE (a) (b)
12. Second Normal Form ORDER ORDER NUMBER ORDER DATE CUSTOMER NUMBER CUSTOMER NAME CUSTOMER STREET CUSTOMER CITY CUSTOMER STATE CUSTOMER ZIPCODE CUSTOMER PHONE ORDER SUBTOTAL SALES TAX SHIPPING ORDER TOTAL ORDERED PRODUCT PRODUCT ID + ORDER NUMBER QUANTITY DESCRIPTION UNIT PRICE EXTENDED PRICE (a) (b) ORDER ORDER NUMBER ORDER DATE CUSTOMER NUMBER CUSTOMER NAME CUSTOMER STREET CUSTOMER CITY CUSTOMER STATE CUSTOMER ZIPCODE CUSTOMER PHONE ORDER SUBTOTAL SALES TAX SHIPPING ORDER TOTAL ORDERED PRODUCT PRODUCT ID + ORDER NUMBER QUANTITY UNIT PRICE EXTENDED PRICE PRODUCT PRODUCT ID DESCRIPTION
13. Third Normal Form (a) (b) ORDER ORDER NUMBER ORDER DATE CUSTOMER NUMBER CUSTOMER NAME CUSTOMER STREET CUSTOMER CITY CUSTOMER STATE CUSTOMER ZIPCODE CUSTOMER PHONE ORDER SUBTOTAL SALES TAX SHIPPING ORDER TOTAL ORDERED PRODUCT PRODUCT ID + ORDER NUMBER QUANTITY UNIT PRICE EXTENDED PRICE PRODUCT PRODUCT ID DESCRIPTION ORDER ORDER NUMBER ORDER DATE CUSTOMER NUMBER ORDER SUBTOTAL SALES TAX SHIPPING ORDER TOTAL ORDERED PRODUCT PRODUCT ID + ORDER NUMBER QUANTITY UNIT PRICE PRODUCT PRODUCT ID DESCRIPTION CUSTOMER CUSTOMER NUMBER CUSTOMER NAME CUSTOMER STREET CUSTOMER CITY CUSTOMER STATE CUSTOMER ZIPCODE CUSTOMER PHONE
14. Denormalization (a) (b) ORDER ORDER NUMBER ORDER DATE CUSTOMER NUMBER ORDER SUBTOTAL SALES TAX SHIPPING ORDER TOTAL ORDERED PRODUCT PRODUCT ID + ORDER NUMBER QUANTITY UNIT PRICE ORDER ORDER NUMBER ORDER DATE CUSTOMER NUMBER ORDER SUBTOTAL SALES TAX SHIPPING ORDER TOTAL ORDERED PRODUCT PRODUCT ID + ORDER NUMBER QUANTITY UNIT PRICE MTD SALES MONTH ID MONTHLY SALES
15. Fully Normalized ERD ORDER PRODUCT CUSTOMER ORDERED PRODUCT Customer Name Customer Street Customer City Customer State Customer Zipcode Customer Number Customer Phone Order Date Order Number Customer Number Sales Tax Order Subtotal Shipping Order Total Product ID + Order Number Quantity Unit Price Product ID Description
16. Selecting a Primary Key 99XXX99XX 123456789 Criteria for Selection Explanation Stability Choose a candidate key that will not likely change its value over time. EXAMPLE: UNSTABLE STABLE NAME+ADDRESS EMPLOYEE_ID Non-Null Choose a candidate key that is always guaranteed to have a non-null value. EXAMPLE: POSSIBLE NULL NON-NULL PHONE_NO SSN Non-Informational Do not create intelligent keys that attempt to convey information via their structure. EXAMPLE: INFORMATIONAL NON-INFORMATIONAL Location Color Shelf Class Code Code Code Code Simplicity Wherever feasible, consider using a single attribute primary key instead of a multi-attribute primary key. EXAMPLE: SINGLE ATTRIBUTE MULTI-ATTRIBUTE ITEM_NO+COLOR ITEM_CODE
17. Identifying Entities and Relationships Question Category Description Determine System Entities Find out what types of people, business units, things, places, events, materials, or other organizations are associated with, or interact with, the system and about which data must be maintained. Identify Entity Attributes Identify the characteristics by which each entity is associated or identified with. Determine Entity Keys Identify the most appropriate characteristic for each entity that uniquely distinguishes an instance of that entity from all other instances of the same entity. Determine Relationships and Degrees Identify the various events, transactions, or other business activities that infer an association between entities. Determine Cardinalities and Optionalities Identify the circumstances under which each of the relationships can occur. This requires an investigation into the various business rules under which the organization operates and the constraints imposed on the events which occur within the business environment.
18. Three Normal Forms Normal Form Description First Normal Form (1NF) A relation is in 1NF if it contains no repeating data elements. Second Normal Form (2NF) A relation is in 2NF if it is in 1NF and contains no partial functional dependencies. Third Normal Form (3NF) A relation is in 3NF if it is in 2NF and contains no transitive dependencies.