Would someone lend a few hints on how to relate a node to a data table, please? I think a View export, Data Table export and a CSV with mock data would suffice. If I can get it to go I will reply with some much needed documentation.

Thanks in advance.


#2 data_table_x.txt1.91 KBkbk
#2 data_table_x_view.txt3.71 KBkbk


kbk’s picture

If it is any help, the data_table_node table is perennially empty (I have done the admin/build/data > Edit Table > Relate to Node step.)

kbk’s picture

3.71 KB
1.91 KB

OK. Here is how I was able to get this working. I would be interested to hear comments from other, more experienced, Data module users. Especially with respect to #5, it seems very un-Drupal.

- The Data Module and its required modules are installed/enabled.
- Basic working knowledge of Data and Views
- Ability to do direct database insertions

1) Create new Table by going to admin/build/data/create
- An export of my table, data_table_x, is attached.
Note: I used phpMyAdmin to make my ID column auto-increment

2) Insert data into data_table_x
- I used phpMyAdmin to manually insert 3 rows :
id, variable_x, node_ref_id
1, 234, 8021
2, 253, 8021
3, 323, 8021

- The first two columns are arbitrary, node_ref_id column contains the NID of the node I want to reference.
- The Feeds module can be used to accomplish steps 1 and 2.

3) Relate to nodes. Go to admin/build/data/edit/data_table_x/node and specify the Content Type you want to relate to and the column with the NID of the node you want to relate to (node_ref_id, in this case.)

4) Browse to admin/content/data/view/data_table_x, you should see your data. If not, then back to the drawing board with you.

5) Manually populate data_table_node table.
- Again, through phpMyAdmin, I inserted 1 row:
nid, data_table_name, id
8021, data_table_x, 8021

- Note: Is it by design that you need to manually update this table? I do not know.

6) Modify view so the Node Title of the referenced node is visible.
- Edit data_table_x view: admin/build/views/edit/data_table_x
- Add a relationship: Data node: Data table
- Add another relationship: Data node: Node
- Add Node Title field (with mandatory relationship) > "Exclude from display" & "Link this field to its node"
- Modify Table > Style Options to group by Node Title.
- Save
- See export of this view attached.

- The relationship 'Data node: Node' is not available until relationship 'Data node: Data table' is added
- Node Title field cannot be added until relationships are specified

groovehunter’s picture

Many thanks for posting this example.
I have one obstacle, my data table does not have yet an auto-id col. Do you know if there's a way to add a list of unique ints indices ?

EDIT: Meanwhile i prepared my tables with autoid columns

TommyK’s picture

I thought I'd post in this thread because my question is exactly "how to relate nodes to data tables?".

I have a specific use case, but generally what I would like to do is use a Data table as a join/junction/link table to track many-to-many relationships between nodes.

What I'm doing is this: all data is coming into Drupal via Feeds because it lives in another system.
- I have Customer info going into CCK fields of a Customer content type.
- I have Product info going into CCK fields of a Product content type.

I need lists of Products purchased by one Customer and Customers who have purchased one Product. This data lives a separate Purchases table that contains a unique purchase id with a customer id and product id. A standard junction table.

Using Feeds and Data I've put this Purchases data into a Data table because there is no reason for it to be nodes.

Is it possible to use this Data table to relate the many nodes correctly? The IDs I want to match on are not Node IDs, but they are available in CCK fields.

Danny_Joris’s picture

Version: 6.x-1.0-alpha12 » 6.x-1.0-alpha14

I was stuck at step 5 as well. So I manually populated date_table_node. Now I'm stuck at step 6. In the table view I can't select any relationships at all.

When I use a node view I can add the Data node item count field. That correctly indicates that there is one reference between my table and the node.

In the node view the only data relationship I can add is Data node: node, which I can't do anything with.

Is there any place where I can find more info on this?

jonhattan’s picture

Version: 6.x-1.0-alpha14 » 6.x-1.x-dev

In case you're using feeds module and looking for a relation for feed_nid to its source node: #989778: Views relationship to source node for fast feeds

joachim’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Closing old support requests.