Consider the model in Figure 6-24 which describes purchases of a product by customers of a small mail order company selling toys. For simplicity, each purchase is for one or more of a single toy. Each transaction must have a customer so that he or she can be invoiced and the product delivered. The data will be used to prepare statistics about the different products sold, values of purchases, and the spending habits of customers.
Figure 6-24. Customers purchase products.
The company changes the way it does business to allow customers to walk in off the street and pay cash. No customer needs to be associated with a cash purchase. Discuss how effective the following changes to the data would be:
Change the optionality at the customer end of the relationship to 0 so not all purchases need a customer.
Leave the optionality as 1 but include a dummy customer object, with name CashCustomer.
Create subclasses of Customer: Cash_Customer and Account_Customer.
Create subclasses of Purchase: Cash_Purchase and Account_Purchase.
TESTING YOUR UNDERSTANDING
Exercise 6-1
Consider the model in Figure 6-24 which describes purchases of a product by customers of a small mail order company selling toys. For simplicity, each purchase is for one or more of a single toy. Each transaction must have a customer so that he or she can be invoiced and the product delivered. The data will be used to prepare statistics about the different products sold, values of purchases, and the spending habits of customers.
Customer Purchase name date address 1.1 0..n quantity 0.n Product name
Figure 6-24. Customers purchase products.
The company changes the way it does business to allow customers to walk in off the street and pay cash. The data would be:
Change the optionality at the customer end of the relationship to 0 so not all purchases need a customer.
Leave the optionality as 1 but include a dummy customer object, with name CashCustomer.
Create subclasses of Customer: Cash Customer and Account Customer.
Create subclasses of Purchase: Cash Purchase and Account Purchase