WebGUI's Thingy is a great tool for building relational databases. It has the ability to import data from external tables into individual Things, but the import capabilities are limited to the data in individual tables; there is no way to re-establish links between tables when importing data from an external relational database (at least as of WebGUI 7.9). This script can be used to re-establish these links within Thingy's internal linking system, allowing for legacy systems to be imported into WebGUI's Thingy asset.
The script works by identifying the key fields that linked data tables in the original database, using the old key values to lookup linked records, and then establishes new links between the records using WebGUI's internal ID fields. The original key fields are maintained for archival purposes, but can be deleted once the import process is complete. Once the historic data are imported, data managers can switch to WebGUI's regular Thingy interface for adding and editing data.
The script works on one link at a time, so if you have tables that link to more than one other table, you must repeat the script once for each link you need to establish. It is important to remember that when establishing links, one of the two tables is the "data table" and the other the "lookup table". During the execution of the script, the lookup table is not changed -- it simply holds values to which the data table will be linked. The data table holds one or more "foreign key fields" which are the values that link its records to individual records in the lookup table(s).
The basic steps for using this script are: