Re: many-to-many with attributes?
Re: many-to-many with attributes?
- Subject: Re: many-to-many with attributes?
- From: Arturo PĂ©rez <email@hidden>
- Date: Wed, 27 Jul 2005 07:54:23 -0400
The flattening of relationships is an EOF feature intended to hide
something that usually isn't of any interest. But once a join-table
has attributes of its own then then it needs to be treated as an Entity
in its own right. I have yet to find, in my line of work, a join table
that doesn't have attributes so I have not used flattened
relationships.
I used to do #2 before I got the hang of how EOF handles many-to-many
relationships with attributes. I must admit it still seems worthwhile
in some cases. For example, I have one relationship that joins 4-5
entities. I keep wondering whether there's an Entity in there
struggling to get out that should have its own primary key.
-arturo
On Jul 26, 2005, at 8:30 PM, Ian Joyner wrote:
I use this a lot particularly when I need to put a 'role' into the
relation to express what the m-to-n relationship is about. What I
found was that it is best to just do this by hand and not use
EOModeler's Property:Join in Many-to-Many.
1) In particular, I found that the flattened relationships between the
two tables, across the join table gave problems at run time, like key
was not visible, or something like that.
2) Second problem is that EOModeler's join table used the two foreign
keys as its compound primary key, so the important thing was to give
this table its own primary key separate from the foreign keys. Mind
you, you probably want the foreign key combination to be unique,
unless a single user can have many different roles in the same group.
Perhaps the problems, I had with (1) are solved by (2), since I came
up with (2) later, but it is not hard to have to code the path
group.users.user.name instead of group.user.name, especially when you
want to get group.users.role.
This might or might not be non-optimal (if others have a better
solution), but it does what you want, and it works.
Ian
Sportstec
On 27/07/2005, at 3:34 AM, Jim Zajkowski wrote:
Hi there,
What's the best way to handle a many-to-many relationship that has an
attribute on the relation?
That is, let's say I have a table of users, and a table of groups. I
want a m-to-m relation between them, since clearly more than one user
can belong to a group, and I'd like to see what users are in a group.
But I also want to include some form of "access level" (e.g.,
moderator, administrator, regular user).
In DB land I'd model this by having an additional attribute on the
users-groups table. But when I've done that in EOModeler, it creates
a flattened relation, and so there isn't a way to see that attribute.
So, what's the best way to do it? Not flatten the relation and walk
the m-to-m by hand?
Thanks,
--Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden