In ioS 5, arc
The scenario that I’ve to implement in core data is that a product can be connected to several promotions, e.g. simple, multi buy etc. the type of the promotion determines the field values that are persisted eg. simple promotion needs to store the quantity, promoted price and the multi buy needs to store a description that says buy 2 at $6 but get 1 for $4 for eg. I need to persist these in core data.. what is the best design pattern to model these?
Thanks in advance for your help on this.
Figure out what data you need to describe a promotion. For example, you might need: 1) description, 2) discount, 3) start date, 4) end date. Create a Promotion entity that stores all that stuff.
Create a relationship between your Promotion entity and your Product entity. You’ll probably want a many-to-many relationship here, since a given promo can apply to several products, and a given product can have multiple promotions.
There is no step 3.