Step 1d: Explicitly declare primary keys in your database

Primary keys in database tables indicate which fields are used to uniquely identify each record.  For example, a Customer table generally has a CustomerID primary key field that contains a unique customer ID value for each individual customer.  In order to produce code that can update or delete an individual record, Iron Speed Designer must know which field(s) to use as the primary key for selecting and accessing individual records.

An example web page built with Iron Speed Designer.  The application uses primary key relationships to retrieve the appropriate Order table record for editing.  The application uses foreign key relationships to retrieve the associated Customer and Order Detail table records for editing.

Make sure every database table has a primary key.  This is very important because it allows Iron Speed Designer to create Edit Record, Show Record and Edit Table pages for these tables as well as Workflow pages.  Without a primary key, it’s impossible to look up an individual record, making it impossible to create pages and code that fetches an individual record for display or editing.

Examples:

Orders.OrderID

Shipper.ShipperID

Composite primary keys

Frequently, a table will use several fields together to form a primary key.  These are called composite primary keys.  For example, a Customer table may use the combination of a phone number field and last name field to uniquely identify a customer record.  Iron Speed Designer determines composite key relationships by querying the system information in the connected database(s).  If multiple rows are returned for a given table, it means that the table has a composite primary key, i.e. a primary key consisting of multiple fields.

See Also

Step 1a: Create child tables for one-to-many relationships

Step 1b: Create separate lookup tables

Step 1c: Create database views to express multi-table joins and complex queries

Step 1d: Explicitly declare primary keys in your database

Step 1e: Explicitly declare foreign keys in your database

Step 1f: Declare virtual primary keys in Iron Speed Designer

Step 1g: Declare virtual foreign keys in Iron Speed Designer