Skip to main content

Indices

Last updated 17/03/2026

Overview

When a query in Five is used as a data source for a form, the query must include a primary key so the platform can uniquely identify each record returned by the query.

A primary key is a field that uniquely identifies a single record in a table. When a form loads data from a query, Five relies on this key to determine exactly which record the form is displaying or editing. Without a primary key, the form cannot reliably distinguish one record from another.

This becomes especially important when the form performs actions such as updating, saving, or deleting data. When a user modifies a record in the form, Five uses the primary key value to map the form back to the correct database record.

For this reason, any query used as a form data source must include the table's primary key field in the

SELECT
statement. The key does not need to be displayed in the form. In fact, when using the Form Wizard, the wizard will exclude the primary key field from the form automatically, because it is not something users typically need to view or edit. The field still exists in the query result and is used internally by Five, but remains hidden from the user interface.

Add a Primary Key

Before you add your primary key, open or create your query in the SQL editor and ensure the query includes the field that will act as the primary key, typically the primary key from one of the underlying tables.


SQL
Figure 1 - SQL

1. Click the Indices tab.


Indices tab
Figure 2 - Indices tab

2. Click the Add Indices button.


Add Indices button
Figure 3 - Add Indices button

3. Give your index an ID and select Primary in the Key Type field.


Add index
Figure 4 - Add index

4. Click the Index Fields tab.


Index Fields tab
Figure 5 - Index Fields tab

5. Click the Add Index Fields button.


Add Index Fields button
Figure 6 - Add Index Fields button

6. Select the field required to be your primary key.


Add index field
Figure 7 - Add index field

7. Click the Save button in the form app bar.


Save button
Figure 8 - Save button

8. Click the Save buttons in the form app bars above the list.


Save buttons
Figure 9 - Save buttons