I'm an experienced programmer new to Drupal. Would like a pointer to any docs on the best way to handle a one-to-many relationship, e.g. a User has-many Tasks or a Company has-many Locations. It's looking like I do this with Views? The examples I've found seem to rely on tags, which seems like it might be relationally iffy, but I'm sure I'm just missing something.

Comments

Raphael Apard’s picture

I'm not sure to understand what you want exactly. I would say to use a node reference. See project references.

Raphael

tomcam’s picture

Thanks for answering!

What I'm looking for would work something like this.

A form has fields on it for Company. A Company must be unique in the database. It has a unique numeric identifier field and a text field for the Company name.

Once you add a Company, and only when you add a Company, you can add 0 or more Locations. A Location has a unique numeric identifier field, a text field for the Location name, and a numeric field that holds a value that's equal to one of the Company numeric fields. Therefore a Location belongs to a company.

If you delete a Company, all its Locations are deleted.

I'm sure this concept exists somewhere in Drupal but I'm still in the middle of an avalanche of documents!

Doren Berge’s picture

If I understand correctly, this seems like you are describing a taxonomy. A Vocabulary with associated terms = Companies with associated locations....

Enable and create a "taxonomy" for input of content (companies, ie. Vocabulary) and define content relationships (locations, ie. terms). Use Views for displaying those various content, relationships.

moehac’s picture

Hi tomcam,

Did you ever find the solution in Drupal for this? i come from a dbase/sql background and I understand your scenario perfectly, but am starting to learn Drupal now.

Thanks!

MoeHacDev