![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
modeling domain objects
I am not sure how to go about modeling my objects after a many-to-many situation such as this:
A user can belong to many roles and a role can contain many users. I have a table called Role and it contains: role_id role description next i have a table called users and it contains: user_id user_name password and in between this I have a table that address the many-to-many between the to. It is called belongs_to and it contains user_id role_id So right now I have a Role class and a User class. I am not sure if i should include a collection of users in the role class and an instance of role in the users class when I retrieve the data. So for instance role might be: public class User
{
private System.Int32 userId;
private System.String userName;
private System.String password;
private Role role;
}
public class Role
{
System.Int32 roleId;
System.String shortName;
System.String description;
System.Collections.ArrayList users;
}Is this the right way to do this? Throughout my domain objects I have a ton of member fields such as status_id, user_id, role_id and I was looking to go this way instead. So basically I would attempt to fill the above objects in the business layer with the correct data. Hopefully this makes some sense. Thanks |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|