Primary key

What is a primary key in FileMaker?

A primary key is a field within a data table, with which a record (tuple) of a relation (related table) can be identified unambiguously. The primary key is the own key within a main table, which has the prefix “_pk_” in the FileMaker based gFM-Business-Framework, e.g. “_pk_Customer_ID”. Keys in gFM-Business are always marked with a leading underscore, so that they appear at the top of the table when sorted alphabetically.

The primary key is used to link other related tables using the unique value of the primary key. In a classic 1:n relationship, the primary key “_pk_xyz” is linked with the foreign key “_fk_xyz” of the related table.

1:n-relation in FileMaker

In this example, the primary key “_pk_Customers_ID” is used to link the main table “Customers” with the related tables “Customers_Contact Persons”, “Customers_Addresses” and “Customers_Documents”. All related tables each contain the foreign key “_fk_Customer_ID”, which indicates the affiliation to a specific customer record from the main table.

UUID to be used as primary key

A primary key is classically filled automatically with a consecutive number when a new data set is created. In the newer FileMaker versions it is possible to generate a unique ID in text form with the function Get ( UUID ) – since then primary keys in FileMaker are often filled with a UUID.

FileMaker field options for calculated value

The automatic generation of a UUID in a key field is done in the FileMaker field options, which can be accessed by clicking on [Options] in the database administration. The key field must be of the type [Text] and the option “Do not replace existing field value” must be activated to ensure that the unique UUID is retained when a record is modified. Under the button [Specify] you can now simply enter the function Get ( UUID ).

Number ranges and calculated primary keys

Primary keys can also be calculated in other ways. For example, some FileMaker databases offer number ranges that are calculated according to specific criteria. These keys are also unique and can be used as primary keys.

More questions about FileMaker? Faster is personal.

As part of our coaching and training services, we would also be happy to inform you personally about the functions in FileMaker that you need to develop your FileMaker solution. Of course, we are happy to address your individual wishes. The billing is individual and fair in steps of 15 minutes each. Pay comfortably by bank transfer or PayPal.

Related entries

Diesen Beitrag bewerten:

About Author

Markus Schall
Development of FileMaker databases since 1994, modification and extension of FileMaker solutions, conversion of FileMaker databases from .fm, .fp3, .fp5 (FileMaker 2-6) or .fp7 (FileMaker 7-11) to .fmp12 (FileMaker 12-17), interfaces to third-party systems such as online shops, CMS or other databases. Development of individual FileMaker database systems based on the gFM business framework with personal advice from Oldenburg. Operator of the online specialist portal goFileMaker.de, developer of the CRM and merchandise management system gFM-Business. Member of FileMaker Business Alliance, FileMaker Developers Subscription and FMM Expert. Winner of an FMM Award 2011, awarded by the FileMaker Magazine.