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 Raymond Lukas <rl...@cadence.com> on 2002/12/03 21:27:11 UTC

To n:M map or not to n:M map, That is the question

But I don't know the answer...

 

 

I have a question about how to do a n:m mapping. I have the (Person.
Role, Project) examples working and understand them. They where pretty
helpful and worked great. Many thanks to the people that put them
together.... But I am not sure how to use OJB to solve my problem at
work. Can someone provide me some advice.. This is what I am trying to
do.

 

I have a user object (name and ID) and a document object (filename, doc
desc and id). I need to provide a method that, given a user ID, will
display all the documents I know about along with a boolean which
identifies which ones the user can access. In reverse order, given a
document ID show me all of the users in the system along with a Boolean
of which users have access that document. 

 

This will then be feed into a web page which allows you to change this
Boolean. 

 

 

This is what I did..

 

*                     I made a User Table, a Document Table and a third
table UserDocAccess.

*                     I made a UserPrivObject (holds a User object, and
the accessibility flag). A list of these will be returned for a given
document. 

*                     A DocPrivObject (holds a document Object and its
accessibility flag). A list of these will be returned for each User.

 

Given a user I will get a List of DocPrivObject each holding a document
and a YES/No type flag

Given a Document I will get a List of UserPrivObject each holding a User
object and a YES/No type flag.

 

I just can not seem to get my brain around this.. What is a good way to
solve this. Should I use the N:M mapping with these three tables or some
kind of cascade loading in an attempt to store an object net? I know
that people have done this. Can you give me a hand... Thanks  ray