Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

EricBrian

macrumors 6502a
Original poster
Jul 30, 2005
657
8
So, in my quest to learn more about creating cocoa applications, I have a question about how I created the entities for an application I am trying to create as a learning exercise.

The attached image shows the 3 entities that I've created.

3 Questions:

1) So, what I am trying to do is allow a user to create a recipe that has one or more categories. And, the user also has to be able to add many ingredients to one recipe. Did I capture this correctly as shown below?

2) Now, the example I read on how to create a Core Data Application says that there should always be an inverse relationship for data integrity reasons. Is this the case?

3) And if so, I think I have satisfied that. Or?

Thanks. :)
 

Attachments

  • coredata_screencapture.jpg
    coredata_screencapture.jpg
    105.1 KB · Views: 109

MadDoc

macrumors 6502
Apr 25, 2005
329
5
UK
@EricBrian:

I'm new to Cocoa / ObjC programming AND keen to write a recipe management app too. What are the odds? :)

I'm just about at the stage of dabbling with Core Data (I figure it's the way to go) - in fact, I have the Apple CoreData.pdf open on my desktop as we speak!

One thing's for certain, REALbasic was a lot easier to pick up (although I appreciate it is lacking a lot compared to Cocoa).

MadDoc,
 

EricBrian

macrumors 6502a
Original poster
Jul 30, 2005
657
8
@EricBrian:

I'm new to Cocoa / ObjC programming AND keen to write a recipe management app too. What are the odds? :)

Yeah, funny that you should decide to do a recipe app, too. I am doing it because when I was wondering what to do, my mom asked me if I knew of a program that she could use. I told her that I will make it for her. :) In any case, my fav programming lang is Python, so have a guess at what lang I'll be using. :)


One thing's for certain, REALbasic was a lot easier to pick up (although I appreciate it is lacking a lot compared to Cocoa).

Yeah, VB.Net was a lot easier to pick up, too.
 

WeeBull

macrumors newbie
Aug 18, 2004
9
0
1) So, what I am trying to do is allow a user to create a recipe that has one or more categories. And, the user also has to be able to add many ingredients to one recipe. Did I capture this correctly as shown below?

Well...

You've got that a Recipe can have 1 or more categories, and that it can have 1 or more ingredients, but your inverse relationships are not "to-many" relationships so you can only have one recipe in a category, and and ingredient can only be used in one recipe.

I doubt this is what you want, so make sure all of your relationships are "to-many" (in this case)

2) Now, the example I read on how to create a Core Data Application says that there should always be an inverse relationship for data integrity reasons. Is this the case?

What a relationship allows you to say is "given A, what Bs are related?". So in your case you might say "Given a recipe, what categories are related?". The inverse of that is "Given a category, what recipes are related?" and that's also a useful question, so yes you want an inverse relationship.

There might be cases when the inverse isn't a useful question, but it's rare and I can't think of an example, so its normally good practice to have one.
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
There might be cases when the inverse isn't a useful question, but it's rare and I can't think of an example, so its normally good practice to have one.

It does happen, but when you are coding you always run into situations where you need them even if you didn't realise that at the design stage.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.