Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 24th, 2006, 10:59 PM   #1
hoffmandirt
Hobbyist Programmer
 
hoffmandirt's Avatar
 
Join Date: Jul 2005
Location: PA
Posts: 125
Rep Power: 4 hoffmandirt is on a distinguished road
Send a message via AIM to hoffmandirt
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
hoffmandirt is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:38 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC