Hi,

I'm making a site that's going to have a many-to-many relationship, and was wondering if anyone else had thoughts on how to implement this - both in terms of the database, and about how to input it.

What do I mean?

I'm using CCK to have node references in my node edit pages - so I have one node type of 'organisation' and another of 'project' - and so I can select multiple projects in any organisation I'm editing.

Which is great: but what I need is, for each project added, extra fields that relate to that project's connection to the organisation. I.e. When i add a project to an organisation, I need more fields to appear - in my case, I need "amount this organisation gives to this project" (in either a negative or positive amount to indicate giving or receiving funds from it.)

In relational database terms, this is a many-to-many relationship - one organisation can be involved in many projects / one project can involve many organisations - which relational databases can't do directly. I need to create a third 'linker' table, I think. An illustrative example (from my database textbook!) would be if you have 'students' and 'courses' -

  • one student can be enrolled on zero or many courses
  • one course can contain many students

So that's solved by making a third category - registration.

For registration, it's 'each registration involves one student and one course'.

So - anyone done anything like this? I think what I'll probably do is create a linker table, and then just shoe-horn in some code to write to it. But any other suggestions - including if there's ways of hiding the extra linker fields until I fill in a 'project' field, or how best to shoehorn in the code - would be gratefully received.

Cheers me deerz,

Dan

Comments

916Designs’s picture

Hey Dan,

I'm in your same boat. Im trying to implement relationships between People and Committees with attributes in the relationship (term length, start of term, etc.).

Did you get anywhere with this?

Thanks