Hi!
I have a following pretty trivial design problem.

There's three tables in database schema:

       +---------+-----------+----------+---------+---
User:  | userId  | username  | password | ....    | ..
       +---------+-----------+----------+---------+---

       +---------+-----------+----------+---------+---
Group: | groupId | groupname |  ....    | ....    | ..
       +---------+-----------+----------+---------+---

        +----------+----------+
Groups: | groupId  | userId   |
        +----------+----------+

"User" and "group" tables hold data for users and groups respectively and
"groups" table keeps track of the relation between these tables. "groups"
table is indexed by both fields so it is fast to find answer to questions:
"For which groups user X belongs to?" and "Who belongs to group X?".

On the application level I have two Entity Beans: UserEntity and
GroupEntity.

I suppose there's at least following ways to design the system utilizing
EJB 2.0 style Entity Beans and CMP:

1. define a many-to-many relationship between UserEntity and GroupEntity

2. add a dependent class: UserGroupMappingEntry
   This dependent class represents a row in "groups" table and both
   UserEntity and GroupEntity have one-to-many relationship with it.

3. add two dependent classes: GroupListEntry, UserListEntry
   Now UserEntity has a one-to-many relationship with GroupListEntry which
   holds the group ids where the user belongs to. Likewise GroupEntity has
   a one-to-many relationship with UserListEntry which holds the user ids
   who belongs to the group.

What are the pros and cons in these choices? Or is there better ways to
approach the problem?

Joni
[EMAIL PROTECTED]

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to