We are using CCK to build a custom content type. Each content type has some body-content, a title of course, and then needs access to a Parent ID, a Child ID, and a Grandchild ID, which are important for building pages. IMPORTANT: Some pages might share these IDs. They're not necessarily unique for every page. There are 10,000 content pages, and only 100 mixtures of these IDs, for example.

In the interest of database structure, we wanted to avoid redundant data. So rather than every content type having three individual values, we want ONE reference value that refers to another table.

In our current database (on a custom CMS we are replacing with drupal), a content page might have a category ID of 1. And that value of 1 corresponds to a category table, and the row with CatID 1 might have (parent ID, child ID, and grandchild ID) values of (4, 58, 2).

I couldn't see how to set up this relationship with CCK. Then I thought about using a node reference. I created a new content type called Category ID and gave it fields of Parent, Child, Grandchild IDs. Then I went to my original content type and added a node reference to this new CatID content type. Eureka! Now I have parent, child, grandchild in a seperate table (good) and a hook between the content types.

Except there's a problem. By creating another content type to store this category info, I'm essentially creating more nodes. Suddenly, I'm not referencing a category ID, but a node ID -- and those node IDs are being created by drupal. Since we've already loaded up some data into Drupal... I can't have a "category ID" (or node ID) of "1"... Instead, it's 291. Node 291 => Cat ID 1, Parent/Child/Grandchild of, say, 4, 58, and 2.

And suddenly, this node reference thing won't work... Because instead of Category ID of 1 = 4, 58, 2... I'm forced into Category ID of 291 -- which maps to completely different values.

Bare in mind we are importing our old CMS content... So I cannot change each page's category ID. It's expecting that 1 = 4, 58, 2... and not, in this example, 291 = 4, 58, and 2.

Node reference is close to what I need... But as you can see, it's creating some problems. Am I going about this wrong? Is there a more elegant solution? Do I need to contract a drupal developer to create something new?

Please let me know if you require additional information. We're dropping our entire CMS for Drupal. We've become believers.

Comments

bestknight’s picture

I would be very interested to know what solution you came up with, as it is very relevant to an issue with a webpage I am setting up. Thanks.

seanmclucas’s picture

Still looking for a solution here. I need a sibling-sibling relationship not really a top-down relationship.

I have a patient node type that might have multiple research study nodes associated with it. The patient also might have multiple status nodes associated with it. I need to be able to draw a relationship between one of the patient's studies and one of the patient's statuses. Just in case this isn't clear I'll give an example. Patient A is enrolled in a Diabetes Study and his status for that study is "qualified", while his status for an asthma study that he participated in last year was "disqualified".

I could create another intermediary node to manage the relationships but that just seems messy. Is there any way to easily build in these relationships with CCK or another module like Node Family?

Ideas?

jlevis’s picture

I'm interested in doing something similar.

I'm working on a Community Centre web site. Basically, I will have a "Program" content type (i.e. Basket Weaving, every Monday from 7-8) and a "Venue" content type (i.e. Classroom B). I would like to have it so that when a new Program is created, the creator will be able to select the Venue in which Program will be running. So, the Venue nodes would all be pre-entered and would consist of all the possible Community Centre rooms that could be used for a program.

I just started with Drupal a few months ago (started with v.6), so I'm still getting my head around all of the possibilities.

EDIT: I found a few references to posts with people talking about possible ways to do it, but I'm not sure if any of them work in D6:

http://drupal.org/node/73936
http://drupal.org/node/158287