I'm trying to set up a Core Data model for an iPhone application (instead of using SQLite which was my first idea...), and I am having a hard time modelling the equivalent of something pretty common in standard entity-relation models.
When modelling a many-to-many relationship between two entities in Core Data I understand that each entity must have a relationship to the other (as a to-many relationship) with the inverse parameter set to the relationship on the other entity (and the destination of the relationship set to the other entity).
This part is ok and mechanical, but what I don't know how to model is attributes for these kind of relationships when the designer considers there are.
In entity-relation models, many-to-many relationships are modelled as a third entity whose primary key is the primary keys of each entity of the couple entities involved. And many times, this many-to-many relationship can have more attributes (besides the primary keys as foreign keys).
For instance, if I have the following, where bold is the name of the entity, and what's inside of the parenthesis are attributes, and those attributes underlined are primary keys:
order_id and product_id would be a relationship on each entity, product and order respectively with the parameters set like I described previously, but then... I don't know how I can model the quantity because it doesn't belong to an order neither a product as it belongs to the join result of both entities...
Any ideas? Thanks from a newbie in Core Data development
When modelling a many-to-many relationship between two entities in Core Data I understand that each entity must have a relationship to the other (as a to-many relationship) with the inverse parameter set to the relationship on the other entity (and the destination of the relationship set to the other entity).
This part is ok and mechanical, but what I don't know how to model is attributes for these kind of relationships when the designer considers there are.
In entity-relation models, many-to-many relationships are modelled as a third entity whose primary key is the primary keys of each entity of the couple entities involved. And many times, this many-to-many relationship can have more attributes (besides the primary keys as foreign keys).
For instance, if I have the following, where bold is the name of the entity, and what's inside of the parenthesis are attributes, and those attributes underlined are primary keys:
- Order(id, customer_id, date, confirmation, number)
- Product(id, name, price, description)
- OrderProduct(order_id, product_id, quantity)
order_id and product_id would be a relationship on each entity, product and order respectively with the parameters set like I described previously, but then... I don't know how I can model the quantity because it doesn't belong to an order neither a product as it belongs to the join result of both entities...
Any ideas? Thanks from a newbie in Core Data development