views:

31

answers:

2

I am quite new to core data I have read a couple of articles on Apples dev site & now am somewhat confortable with using it with one entity.

Now I am working on an app that recommends recipes to users.

The datadesign is somewhat like this I have these entities

Item

,

Pantry

&

Recipe

.

Relations are as follows:

Item to many Pantry

Item to many Recipe

The logic is to get items from pantry & compare them with values in recipe & then suggest user a recipe.

I am a little confused on how to go about it. Is my datadesign okay. How do I need to change it if in case ..? & will accessing pantry objects managed instance automatically fetch respective item from Items table ...? & likewise will pantry be fetched when I access recipe...?

comments, suggestions, pointers to coredata learning resources will be highly appreciated.

Thanks

+1  A: 

You can take a look at an example (iPhoneCoreDataRecipes) from the Apple site. They are also storing and referencing the recipe data in Core Data.

Jeroen de Leeuw
+1  A: 

Your data model should reflect the real-world object, events or conditions you are trying to simulate.

In this case it sounds like you are simulating a kitchen with a single pantry, numerous items in the pantry and then a book of recipes that uses the items. So, in pseudocode, your object model should look something like:

Item{
    pantry<<-->Pantry.items
    recipies<<-->>Recipie.items
}

Pantry{
    items<->>Item.pantry
}

Recipe{
    items<<-->>Recipie
}

Note that the items to recipe relationship is to-many and to-many because the same item can show up in many recipes and many different recipes can use the same items.

TechZen