Entity Relationship Diagram Prepared by: Lobna Morsy (ERD) Prepared by: Lobna Morsy Suppliers #supplier_code supplier_name Products #product_id product_name product_price Customer_Orders_Products #order_line_id quantity Customer_Orders # order_id date_order_placed discount_rate Customers #customer_id first_name middle_name last_name Customer_Addresses #address_id street_address city state_province_county country Customers_Payment _Methods # card_number date_from date_to Product_Types #product_type_code product_type_name Payment_Methods #payment_ method_code payment_ method_name supply supplied by belongs to has places placed by ordered include includes included in chosen chooses belongs to owns owned
Agenda Database Components of ERD Practice Reading ERDs
What is a database? Database: Central source of data meant to be shared by many users for a variety of applications
Components on an ERD Entities (table) Relationships (business rules) Attributes (column) Entity Name verb Entity Name #attribute_1 attribute_2 attribute_3
Entities Entity Name Entity: Something about which someone chooses to collect data (table) Person Place Thing Event Unit of time Customers Cinemas Tickets Purchases Show times
Relationships verb Relationships: Associations between entities (business rules) Optionality Mandatory Optional verb One Many Cardinality
Relationships verb Cardinality One Many Optionality Optional Mandatory
Reading Relationships Employees Tasks belong to assigned to entity_name one and only one/many verb may/must entity_name Each Each entity_name may/must verb one and only one/many entity_name Each task must belong to one and only one employee Each employee may be assigned to many tasks
Examples of Relationships Each entity_name may/must verb one and only one/many entity_name Instructors Courses teach taught by Employees Offices assigned to assigned for Suppliers Products supply supplied by
Attributes Entity Name #attribute_1 attribute_2 attribute_3 Attribute: some characteristics of an entity (column) Primary key: used to uniquely identify a record. Suppliers #supplier_code supplier_name contact_person contact_person_phone
Customer_Orders_Products Suppliers #supplier_code supplier_name Products #product_id product_name product_price Customer_Orders_Products #order_line_id quantity Customer_Orders # order_id date_order_placed discount_rate Customers #customer_id first_name middle_name last_name Customer_Addresses #address_id street_address city state_province_county country Customers_Payment _Methods # card_number date_from date_to Product_Types #product_type_code product_type_name Payment_Methods #payment_ method_code payment_ method_name supply supplied by belongs to has places placed by ordered include includes included in chosen chooses belongs to owns owned
www.databaseanswers.com