From: Ray Z. <rz...@co...> - 2004-02-16 22:05:23
|
On Feb 16, 2004, at 4:26 PM, Vsevolod (Simon) Ilyushchenko wrote: >> If I interpret correctly what it is that you want, you're looking >> for the ability to define a relationship that would automatically >> generate methods in your "software project" object to fetch the >> corresponding list of bugs, for example. > > And vice versa, I want to be able to fetch the project object that a > bug object belongs to. Right, these are the forward and reverse direction fetching methods I talk about. I'd have to dig back into the details again, but I think my design assumes you want one or the other, but not both. That could probably be added. > Chris actually sent me those links a while ago. This approach may be > more than I bargained for, but if that's the right solution, I could > take a stab at it, provided Chris agrees. Obviously, I'm biased :-), but I would rather see effort put into moving to this more general structure rather than adding onto the existing more limited one. > However, after reading your posts it seems to me that you only talk > about a many-to-many relationship: you always have X between A and B. > I really want to have a system that can handle simple cases of > one-to-one and one-to-many relationships with only two tables/objects, > as having three tables is inconvenient from the DBA's point of view > and should be avoided when possible. Actually, no. I used the three classes X, A and B just to define some minimal notation that I could use to talk about all of the above relationships. For simple one-to-one and one-to-many relationships, just look at X and A (pretend you don't have B). See the first 3 examples at the end of the first post. The proposed structure just attempts to handle all of the relationships using a single generalized has-a configuration: * one-to-one: X has-a A, X is the main object with a method to fetch it's corresponding A * one-to-many: X has-a A, A is the main object, with a method to fetch it's many X's * many-to-many: X has-a and X has-B, X is a linking object between A and B, and A has a method to fetch all of the linked B's (or vice versa). I hope this helps. Ray Zimmerman Director, Laboratory for Experimental Economics and Decision Research 428-B Phillips Hall, Cornell University, Ithaca, NY 14853 phone: (607) 255-9645 fax: (815) 377-3932 |