Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 19: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, 04:33
georgev georgev is offline
SQL Apprentice
 
Join Date: Jan 2007
Location: hiding
Posts: 8,145
Moved to Database Concepts & Design topic.
__________________
George
You only stop learning when you stop asking questions.
Reply With Quote
  #3 (permalink)  
Old 10-22-07, 04:38
georgev georgev is offline
SQL Apprentice
 
Join Date: Jan 2007
Location: hiding
Posts: 8,145
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
You only stop learning when you stop asking questions.
Reply With Quote
  #4 (permalink)  
Old 10-22-07, 18: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, 19:44
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
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

pre-order my book Simply SQL from Amazon
Reply With Quote
  #6 (permalink)  
Old 10-23-07, 08: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, 08:49
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 13,556
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

pre-order my book Simply SQL from Amazon
Reply With Quote
  #8 (permalink)  
Old 10-23-07, 09:38
nfn nfn is offline
Registered User
 
Join Date: Oct 2007
Posts: 4
Thanks...

That's a good start.
__________________
Portal das Viagens
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On