Reputation: 57
I have two entities - Item and Tag. An Item can have one or more read-only (factory) tags that the user can't edit, and then one or more read-write (user) tags that the user can create at any time. I'm wondering how best to model this.
Of course I could just create UserTag and FactoryTag entities, but that would mean redundancy in maintaining two identical entities. I'd rather just have the single Tag entity.
If I use a single one-to-many relationship between Item and Tag, I'll have an NSSet that will contain both read-only and read-write tags. That's not ideal as I would then have to have an attribute on Tag that identifies whether it is read-only or read-write.
I'm wondering if there is a way to model this using multiple relationships between Item and Tag such that the two types of tags are kept separate from each, i.e. I would have an NSSet of userTags and an NSSet of factoryTags?
Thanks.
Upvotes: 0
Views: 232
Reputation: 154513
You can set up multiple relationships between the same entities. Control drag from Item to Tag and call that relationship factoryTags in Item and itemUsingAsFT in Tag. Make this one to many. Control drag from item to tag a second time and call this relationship userTags in Item and itemUsingAsUT inTag. Make this one to many as well. That way you keep the two separate using the same Tag entity.
Upvotes: 1