Reputation: 133
In my model I have: Product <<---> Order
Product Attributes: productName productPrice Product Relationships: order
Order Attributes: orderName salePerson Order Relationships: products
Imagine I have a Product (call it product1): productName: MacBook productPrice: 1200
The application in general used to sale products. So after add and done the sale. Automatically create an Order (call it currentOrder) which contain product1.
[currentOrder addProductsObject:product1];
Next I changed product1 price to: productPrice: 1000
After I recheck the product inside the currentOrder, I'll see the productPrice is UPDATED to: 1000 Which I need to not change and still be exactly like the previous (1200).
Basically I would to do something do NOT update the previous object.
Upvotes: 0
Views: 53
Reputation: 7241
Your business model is not suitable for your case. You need to have another entity 'Sale' or so. Your model should look like: Order <--->>Sale, Product <---> Sale. Product Attributes: productName. Order Attributes: orderName salePerson Order Relationships: sales. Save Attributes: productPrice Sale Relationships: order. So in this way you decouple price from product and will be able store different prices in different orders.
Upvotes: 3