views:

26

answers:

2

if i have a table called projects and a project can have a dependency on one or many other projects, what is the best way to model this in db tables.

i have one table called Projects with columns: ID, Name

i was thinking of having a new column called Dependencies and just store the ID of another project but i just realized that there can be many project dependencies so i can store this as a comma delimited list of project IDs but i wanted to get opinions on any other way to model this in a relational db.

+1  A: 

Create a new table called Dependencies. It should have two ID fields (both are Foreign Keys): Project1ID and Project2ID. You can include whatever other columns in this table you feel are relevant.

Create one record in the new table for each dependency between one project and another.

Robert Harvey
+1  A: 

alt text

Damir Sudarevic