Sorry, we don't support your browser.  Install a modern browser

Foreign key: use values from another SQL table#446

Advanced option to configure a relation to a non-wpDataTable.

This would give us exciting possibilities to efficiently & transparently link wpDataTables to many other platforms and custom solutions, that use an integer id for the items.

Example: I know that in the same SQL database, in a certain table, there are certain columns holding exactly the values I’ll be needing for the foreign key relation. No fancy select dialogs necessarily needed in this case, I could just manually fill in three fields with this information behind the Advanced button and click save.

Also, much related to this idea, it would be very convenient in some scenarios if the foreign key column could even be from the current wpDataTable.
The “see also” and “successor” use cases mentioned in #447 are examples of that.
Yes, I know it’s kind of against the idea of foreign keys (or maybe just expanding the concept a little), but depending on your technical implementation of foreign key columns it might still be possible… currently selecting from current table seems to be allowed but causes an internal server error when trying to save the settings.

24 days ago

It just occurred to me, that the things in this suggestion (even the current wpDataTable part) actually could most likely be achieved by creating a wpDataTable based on a custom SQL query, having only the two columns needed for the foreign key (the id and display value), then just configuring that table to be used in the foreign key relation settings of the main wpDataTable. That would be awesome..!

(I haven’t really been exploring the other table-creating options at all, since I chose the manual table route for my project.)

If you can confirm this indeed is true, this suggestion can be closed. I’ll be doing my own tests soon when I have the time.

24 days ago