Adding Foreign Key Table and Look Up Table Pages

It’s quite common to want a dropdown list in a web page that displays the values from another database table.  For example, it is desirable to display a dropdown list of products by the product name rather than by the underlying Product ID value which is typically a numeric value.

The Supplier and Category dropdown lists reference separate look up tables related to the Products table via foreign key relationships.

This is very easy to do in Iron Speed Designer using the 'Display As' database property.  Iron Speed Designer uses foreign key relationships in your database to automatically hook up lookup tables referenced by foreign keys and create these dropdown lists on your behalf.  In order for this to work, you must explicitly declare the foreign key relationship in your database between the parent table and the child table.  Iron Speed Designer detects these relationships in your database and uses them when building pages.  If you are not able to explicitly declare the foreign key relationship in your database, you can instruct Iron Speed Designer to treat certain fields as foreign key fields by using Iron Speed Designer's Virtual Foreign Key feature.

Step 1:  Declare the foreign key relationships, either explicitly in your database or via Virtual Foreign Keys in Iron Speed Designer (Databases, New Virtual Foreign Key...).

Step 2:  Scan your database schema for changes and accept those changes.  (Databases, Scan Database Schema for Changes and Databases, Accept All Changes).

Step 3:  Open the Application Wizard in Iron Speed Designer and select the tables you wish to use.  Be sure to select both the primary (parent) table as well as the lookup (child) table. 

Step 4:  Click ‘Finish’ in the Application Wizard.  Iron Speed Designer creates your application pages, including dropdown lists for any foreign key (lookup) tables.

Database views

It’s important to note that database views rarely have foreign key relationships defined in the database.  Iron Speed Designer cannot detect underlying relationships between a database view and their underlying tables.  Use Virtual Foreign Keys to define foreign key relationships between a database view and associated lookup table.

See Also

Adding New Web Pages to Your Application

Linking Add, Edit, Show Record, and Table Report Pages

Adding Foreign Key Table and Look Up Table Pages

Integrating Web Pages into Existing Applications

Incorporate Existing ASPX Pages into Iron Speed Designer Applications