Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-24-2011, 05:04 PM   #1 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 2
PurposefulCoding is on a distinguished road
Default 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.
PurposefulCoding is offline   Reply With Quote
Old 04-24-2011, 05:11 PM   #2 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 2
PurposefulCoding is on a distinguished road
Default Problem restated...

Recipe Table --> IngredientsUsed Table

PossibleIngredients Table

I have three tables - one for recipes, one for ingredients used in the recipe and a third table which contains possible ingredients.

I need the IngredientsUsed table to reference the PossibleIngredients table so as to save space, but to also be updated should I ever delete an ingredient.

If I use this third table how do I reference it in the IngredientsUsed table? Should I simply copy the unique object ID and scan the PossibleIngredients in order to get the text string? Or should I simply copy the text string from the PossibleIngredients to the IngredientsUsed when the user creates the recipe, therefore removing any future dependency on the PossibleIngredients table?
PurposefulCoding is offline   Reply With Quote
Reply

Bookmarks

Tags
core, data, lookup, table

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 354
11 members and 343 guests
dansparrow, iOS.Lover, lorrettaui53, Nobbsy, oztemel, pbart, PlutoPrime, samdanielblr, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:51 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0