Core Data Application Question

Discussion in 'Mac Programming' started by EricBrian, Nov 13, 2007.

  1. macrumors 6502a

    EricBrian

    Joined:
    Jul 30, 2005
    #1
    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. :)
     

    Attached Files:

  2. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
  3. thread starter macrumors 6502a

    EricBrian

    Joined:
    Jul 30, 2005
    #3
    Thanks Eraserhead for your quick reply. I edited the above post because I was trying to get 3 answers from my original post.
     
  4. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #4
    You seem to have satisfied 1) as well, I'm not sure I understand 3).
     
  5. macrumors 6502

    MadDoc

    Joined:
    Apr 25, 2005
    Location:
    UK
    #5
    @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,
     
  6. thread starter macrumors 6502a

    EricBrian

    Joined:
    Jul 30, 2005
    #6
    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. :)


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

    kainjow

    Joined:
    Jun 15, 2000
    #7
    Not so easy on the wallet though ;)
     
  8. macrumors newbie

    Joined:
    Aug 18, 2004
    #8
    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)

    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.
     
  9. macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #9
    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.
     

Share This Page