0

I've read the manual and saw some tutorial, but still, I do not understand this point.

If I use Core Data in my app, lets say I have an object that one of its properties (column in DB) is a type field. In SQL i would do another table with types and do a many-to-one connection between them.

Now, In the tutorials they say that core data is not SQLite and i should regard it as a representation of an OOP objects.

So, should I do it the same why I would in SQL? types table and a field in the object table that is a foreign key for the types table or should I create a parent entity and inherit from it, creating a new entity (class) for each of the types I need?

SQL DB, as we all know, is a representation of a OOP schema, so I don't understand the benefit of doing it the hard way with inheritance. It is much nicer in my eyes to do it with a types entity, if possible...

Am i wrong about this?

Thank you, Erez

1 Answer 1

1

In my opinion, these are the hard things. You'll always want to return to database designing. It can be better to use a separate 'table', but you can also use subclasses. Maybe you have an Item class, that can have different types. Then you can maybe create the subclasses CarItem, HouseItem... Each representing a certain type of the Item class.

2
  • Thank you Dries, this is exactly what i asked in the question, Why should I implement it this way if the only thing that seperate each class in the the type thing? Isn't it the other way around, when you have a parent class (lets say, Person) with just some abstract data, and many types of subclass that might be abstract or not, I would understand and would have done it the OOP way, make sense, but when all the items properties are the same all the way and there is just on that is deferment, why not do it the SQL way?, This is not a classic inheritance, That is why I don't know what to do...
    – Erez
    Aug 9, 2011 at 9:53
  • Well, after thinking about it some more, I think i got you point.... I should not look at core data as a representation of SQL, So the Item, and Item subclasses will work just fine. seem more work, but i get how to use it in the context after more easily. I see a problem implementing it for the android using the same stucture, as in the Android i will have to use SQL and not Core Data design, but what can i do? Thank you,
    – Erez
    Aug 9, 2011 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.