What is the best way to store additional data in a Drupal 6 site pertaining to CCK node reference fields?

Suppose that a content type has a repeating node reference. I would like to be able to describe and/or annotate the node reference and describe the relationship between a "Person" content type and a "School" content type (e.g. "person attended school," "person donated to school"), or just have a chunk of text to go along with the relationship.

If you have a repeatable noderef field, you get a table like

CREATE TABLE  `content_field_foo` (
  `vid` int(10) unsigned NOT NULL default '0',
  `nid` int(10) unsigned NOT NULL default '0',
  `delta` int(10) unsigned NOT NULL default '0',
  `field_foo_nid` int(10) unsigned default NULL,
  PRIMARY KEY  (`vid`,`delta`),
  KEY `nid` (`nid`),
  KEY `field_foo_nid` (`field_foo_nid`)

I could create a module that maintains a table like the following, which is used to store the metadata.

CREATE TABLE  `mymodule_noderef_metadata` (
  `vid` int(10) unsigned NOT NULL default '0',
  `delta` int(10) unsigned NOT NULL default '0',
  `metadata` longtext,
  PRIMARY KEY  (`vid`,`delta`)

The problem with this is that I would have to do a hook_nodeapi to update the table on both "nsert" and "update" to be able to handle revision rollbacks. In the particular implementation I am thinking of, there could be a pretty big performance impact of doing this.

Am I overthinking this? Is there a better way to do this?
I searched around for a module that does this, but didn't find anything.

1 Answer 1


Have you looked at CCK3 for Drupal 6? It's not stable yet, but the package does contain the Multigroup module which may be exactly what you need. A 'multi group' is a group of cck fields which can be repeated just like normal multi-value fields can. This means that you can group a node reference field with a text field and repeat that combination as many times as needed.

If you decide to give it a try, I recommend that you create a test site first to check if Multigroup and the rest of CCK3 is stable enough for your use case and to make sure that it doesn't interfere with other modules you need.

  • Thanks. How stable is it in your opinion? This is a site for a client, and we are always cautious about alpha modules.
    – mpdonadio
    Commented May 11, 2011 at 14:49
  • I have used the module in a production site only once, and I know of a colleague who did too. He and I didn't encounter any problems at all, but YMMV. Commented May 11, 2011 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.