290 likes | 299 Views
CSCI260 Database Applications. Data Modeling and the Entity-Relationship Model The Heather Sweeney Design Example. Chapter Four. About the business. Heather Sweeny is an interior decorator. Specializes in home kitchen design. Offers seminars at home shows and appliance stores.
E N D
CSCI260 Database Applications Data Modeling and theEntity-Relationship ModelThe Heather Sweeney Design Example Chapter Four
About the business • Heather Sweeny is an interior decorator. • Specializes in home kitchen design. • Offers seminars at home shows and appliance stores. • Seminars are free – used to build customer base, sell products and consulting services.
About the business • After someone attends seminar, Heather wants to sell that person a product or service. • Wants to develop database to keep track of customers, the seminars they have attended, and the purchases they have made.
The Seminar Customer List • Each seminar has a list of customers that attend it. • Includes basic data about seminar as well as the attendees.
The Seminar Customer List • Two potential entities: SEMINAR and CUSTOMER. • From list, it looks like a SEMINAR relates to many CUSTOMERs. • There are facts missing, but we can still create an initial E-R Diagram.
The Seminar Customer List • Customers can attend as many seminars as they wish. • Actually they do not need to attend seminar to get into database. • She never offers a seminar to fewer than 10 attendees. • Add more data to E-R Diagram…
The Seminar Customer List • Need to be able to add seminar to database, whether it has customers or not. • Need to assign identifiers. • SEMINAR – surrogate key (instead of really large composite key) • CUSTOMER – email address
Customer Form Letter • Heather sends a form letter to all attendees. • Several different letters… form letter 1, form letter 2, form letter 3, etc… • Wants to be able to send emails as well
Customer Form Letter • Create entity CONTACT • ContactNumber – which form letter. • ContactType – form letter or email. • Relates to both Customers and Seminars. • Seminar can result in many contacts. • Customer may receive many contacts. • Neither a customer nor a seminar need to generate a contact.
Customer Form Letter • Can a Contact exist without a seminar? yes. • Can a contact exist without a customer? No. • CONTACT is a weak entity depending on CUSTOMER. • ID-Dependant – the identifier of CONTACT includes the identifier of CUSTOMER.
Customer Form Letter • Heather never contacts a customer more than once in any particular day. • Date can be identifier for CONTACT. • Problem – form letter needs customer’s address, but it isn’t in the CUSTOMER entity. Must be added.
Sales Invoice • Used to sell books and videos. • Doesn’t record credit card numbers in database, just payment type.
Sales Invoice • INVOICE needs to be entity. • Should not contain Customer information – keep that in CUSTOMER entity. • Still data missing about some of the lines on the invoice form.
Sales Invoice • There are multiple line-items in the invoice – cannot store in INVOICE entity. • Create weak entity LINE-ITEM to store each line then relate back to INVOICE entity.
Sales Invoice • LINE-ITEM needs an identifier. LineNumber. • The products sold have standardized names and prices. Create PRODUCT entry and relate it to LINE-ITEM.
Sales Invoice • Note UnitPrice appears in both LINE-ITEM and PRODUCT. • Want to be able to update price of product without effecting past INVOICES. • When Invoice created, the UnitPrice is copied from the PRODUCT entity to the LINE-ITEM entity. Down the road, if price of product goes up, it won’t change the past INVOICES.