You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by "Morley, Liam " <lm...@WPI.EDU> on 2004/06/18 19:17:43 UTC

how to specify an attribute for a relationship?

Let's say I have an Employee table, a Project table, and a "WorksOn" relationship between those two. The relationship is m:n (one employee can work on multiple projects, and multiple employees can work on the same project), and has an attribute "hours" which tracks the number of hours an employee works on a given project.

How do I keep track of this with OJB? Would I use a ManageableHashMap? (where Employee.getHours(Project) would use the Project as the key and the hours as the associated value..) If so, how would I use it? Is this even something that OJB can handle? Are there other ways of doing something like this? Any advice would be much appreciated.

 
-- 
Liam Morley
lmorley@wpi.edu


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: how to specify an attribute for a relationship?

Posted by Thomas Dudziak <to...@first.fhg.de>.
Morley, Liam wrote:
> Let's say I have an Employee table, a Project table, and a "WorksOn" relationship between those two. The relationship is m:n (one employee can work on multiple projects, and multiple employees can work on the same project), and has an attribute "hours" which tracks the number of hours an employee works on a given project.
> 
> How do I keep track of this with OJB? Would I use a ManageableHashMap? (where Employee.getHours(Project) would use the Project as the key and the hours as the associated value..) If so, how would I use it? Is this even something that OJB can handle? Are there other ways of doing something like this? Any advice would be much appreciated.

You might decompose this into two 1:n relationships, e.g. employee <-> 
workinfo <-> project where the workinfo would make the indirection table 
that you currently have, explicit.

For info on how to do this with OJB see the "Basic technique" tutorial:

http://db.apache.org/ojb/docu/basic-technique.html#Manual+decomposition+into+two+1%3An+associations

Tom

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org