Hi all,
I've been really excited to be using Table Wizard to add a reporting feature to a site i've been working on. I've imported a bunch of tables into my drupal 6 site and have been able to use Table Wizard to manage those tables so they can be exposed to views.
I've now been playing with relationships and can't figure out if it is possible for me to string together relationships to span multiple tables.
Here is a basic example
Table 1.
Primary Key: table1_id
Display field: display1
Table 2
Primary Key: table2_id
Foreign Key: table1_id
Table 3
Primary Key: table3_id
Foreign Key: table2_id
Display Field: display3
So i'd like to build a view that starts with Table 3, and has a relationship that goes to Table 2, then uses another relationship from Table 2 to Table 1, so that my resulting view has these columns: display1 and display3.
Since for every record in Table 1 there are multiple rows in Table 2, and for every record in Table 2 there are multiple rows in Table 3, i cannot just start with Table 2 and join to both Table 1 and Table 3. And there might be even a Table 4 or Table 5 in the mix ;)
Is there any easy way to do this out of the box with Views 2 and Table Wizard? If not, is there a relatively easy way to write this functionality by extending Views Relationships or something of the sort? Or am i just forced to import my tables in a non normalized format because I am only allowed to join tables one table wizard relationship away?
Comments
Comment #1
mikeryanThis is supposed to work out of the box (and it definitely used to), it seems to be broken at the moment.
Comment #2
mikeryanComment #3
mikeryanOK, it didn't work for me with the Views patch at #576694: Enable views to handle external tables properly, allowing for joins across tables in different mysql databases, so the feature in progress at #610128: Can't add external and internal tables' columns to the same view needs some work. I find if I remove that Views patch, I can easily build such a view using manual relationships (from table3.table2_id to table2.table2_id, and from table2.table1_id to table1.table1_id) - did you try that?
Comment #4
mikeryanComment #5
mikeryanOK, this definitely works with my commits today, with or without the Views patch in play.
Comment #7
mdost@sharpdotinc.com commentedHi,
I am trying to use table wizard to connect to an external Drupal database and pull in that databases users and list it as a staff directory. I have the following problems and was not sure if it was how I set things up or what.
First off, Table wizard seems to see the external drupal database fine but the view it created for the external users uses the default database instead of the external database. I created a custom module and set the base_database for this view to be the external database, so now the view pulls from the external users database.
The issue I have now, which seemed similar to the issue that was resolved here is:
How to get the profile_values and profile_fields into the view. I tried using table relations but only get an option for the profile_values.fid, profile_values.uid, and profile_values.value. What I wanted was the profile_field that would display the related profile_value.value.
This is how i set up my relations.
My external drupal database is called staff_directory
1. staff_directory.users.uid -> staff_directory.profile_values.uid
2. staff_directory.profile_values.fid -> staff_directory.profile_fields.fid
I have the incorperate related table into views automaticly set to "automaitc"
Have I missed something?
Thanks in advanced for any help, and for the Table Wizard Module.
Comment #8
mikeryanPlease do not reopen old issues, especially with questions that are not direct instances of the original issue. A new issue should be opened in such cases.