If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Help with database design.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-21-07, 18:22
nfn nfn is offline
Registered User
 
Join Date: Oct 2007
Posts: 4
Help with database design.

Hi,

I'm planning a site using cakephp and this site will be used to manage projects.

I need some ideas to design the database, especially the relations and teams that will be part of each project.

The vertical entities are:
- Director
- Zone Manager
- Local Manager
- Project Manager

The transversal entities will be:
- Consultant
- Assistant

Each project will be seen vertically by the Managers that have people in each team.
The Consultant A will part of project A and B and Consultant B will be part of project C and D, etc. The Assistants will work in a Pool, so like Consultants they will be part of a team assigned to a project.

Using the best practices what is the best way to associate entities to a team and to each project?

Thanks

NN
Reply With Quote
  #2 (permalink)  
Old 10-22-07, 03:33
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Moved to Database Concepts & Design topic.
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 10-22-07, 03:38
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Can Consultant A and Consultant B be part of project A?
If so you have a many-to-many relationship.

If you can only have one consultant per project then it is one-to-many.
__________________
George
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 10-22-07, 17:59
nfn nfn is offline
Registered User
 
Join Date: Oct 2007
Posts: 4
Quote:
Originally Posted by georgev
Can Consultant A and Consultant B be part of project A?
If so you have a many-to-many relationship.

If you can only have one consultant per project then it is one-to-many.
Hi,

Yes, we may have more than one Consultant in the same project.
I would like to design the table to be simple and logical.

Here is my idea with just some fields from the tables:

Project Table
|id|name|...|

Users Table:
|id|name|function|...|

Team Table (This is the table where relations are established) :
|proj_id|users_id|

Sample Team Fields:
|1|1,4,6|
|2|1,6,10,21|

My questions:

Is this a good practice?
I can place users_id inside an PHP array a search for the users in each project. Is this a good way to go?

How would I manage vertical relations so that Local or Zone Manager only have access projects?

Thanks

NN
Reply With Quote
  #5 (permalink)  
Old 10-22-07, 18:44
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
your Project and Users tables are correct

the Team table should have two integers only -- your example shows a comma-delimited list of users, and that's wrong, you want one row per project/user
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 10-23-07, 07:29
nfn nfn is offline
Registered User
 
Join Date: Oct 2007
Posts: 4
Hi r937,

That's a great suggestion.

Team Fields:

|proj_id|users_id|
|1 |1 |
|1 |5 |
|1 |7 |
|2 |1 |
|2 |10 |
....

Is this correct?

How about the hierarchic association?

Thanks

nfn
Reply With Quote
  #7 (permalink)  
Old 10-23-07, 07:49
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
yes, that's the way

as for the hierarchy, use the adjacency model

see Categories and Subcategories -- it's the same structure
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #8 (permalink)  
Old 10-23-07, 08:38
nfn nfn is offline
Registered User
 
Join Date: Oct 2007
Posts: 4
Thanks...

That's a good start.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On