Core Data Lookup Table Method
Say I have a table to contain recipes. This table references another table for ingredients. However, I would like to maintain an editable list of -possible- ingredients that the user can choose from.
Any recommendations on how to model this?
I am thinking many-to-many but I have trouble conceptualizing it.
If I create a recipe for Chocolate Chip Cookies I could add the ingredients "Chips" and "Flour". However, I also want to store an attribute called "row" which provides ordering for table display.
So we have...
Chocolate Chip Cookies --> Chips (1) and Flour (2)
However, want to create another recipe called Double Chocolate Chip Cookies.
So we now have...
Chocolate Chip Cookies --> Chips (1) and Flour (2)
Double Chocolate Chip Cookies --> Flour (1) and Chips (2)
You can see I decided to display the order differently for the second one.
If I create a many-to-many relationship between recipes and ingredients are the ingredients added to each recipe -separate- somehow?
I also want to be able to edit the ingredients list independently. Perhaps I would add "Salt" as another possible ingredient that a user could choose from when creating a new recipe object. However, I want the metadata (row) for each ingredient to be independent.
Is this a many-to-many relationship? Or do I need a third table called PossibleIngredients which the Ingredients table would reference using the unique objectID.
And so basically I just need an independent lookup table that can be edited but also referenced by other objects. This is a VERY simple issue but difficult for me to explain without all of this text. I hope it is clear.
Another option I think is to simply use a plist and store the entire ingredient name within each recipe. However, this would increase the size of the database as recipes are added since the full text string for each ingredient is added to each recipe. However, the plist can then be edited for future ingredient options.
Any help is appreciated.
|