Handling Datasets with Foreign Keys

This topic describes how to handle database tables which are related by Foreign Keys.

 

Where you have Datasets with Foreign Key relationships, Digitise Forms distinguishes between the following situations:

  • Single Foreign Key Relationships

    A Datasource contains one or more database tables which are linked by the same Foreign Key relationship to a single parent table in the same Datasource.

    Neither the child tables nor the parent have any other Foreign Key relationships with any other tables. The Primary Key and Foreign Key consist of only a single column.

  • Multiple Foreign Key Relationships

    A Datasource contains one or more child tables which have multiple Foreign Keys defined within them, a child Dataset has multiple parent Datasets in the Datasource and/or a Primary Key consists of multiple columns.

 

The presence of Foreign Key relationships between Datasets in a Datasource provides opportunities to handle the data in the related Datasets together, e.g. to download data in a child Dataset at the same time as the parent Dataset. Form Studio's default behaviour and the options available to you differ between the two types of Foreign Key Relationship above.

  • The situation with Foreign Key relationships also applies where you add one or more Recordset Elements to a form, define their Datasets as static columns and then use New Dataset from Form to create the Datasets (see Map Data to Elements). All Recordsets linked to the form Dataset in this way, constitute a Single Foreign Key relationship and will be treated as described below under Configure and use Automatic Data Management with Single Foreign Key Relationships.

 

  • The contents of this topic are not relevant where you are using an Imported Stored Procedure. In this scenario, you would need to handle any Foreign Key relationships within the Stored Procedure, if needed.