Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Primary Key as Text and/or Number

Featured Replies

If I have a field for my product number, for example, P001(text), and I like to set it as my primary key.  Is it necessary to create another primary id (number) for internal use?

KC

No, it is not "necessary" to have another field, as long as your product number is both unique and permanent.

There are some advantages to having a numeric matchfield (e.g. the index is smaller), but you have to balance that against adding another field to your schema. And your existing field is likely going to get indexed too anyway.

You generally want to keep your ID (primary key) to a number. If for nothing else, because if you want to use ExecuteSQL or ESS it will just bite you in the butt if you have a text ID.

Hey KC,

In addition to the considerations mentioned by comment and Agnes, there is one more thing you might consider if your table is (or is likely to grow to be) large.  JBante (who, I see, liked both of the above responses :thumbsup:) did some testing and found quite a difference in performance in record creation, finds, etc., between text and strictly numeric keys.  Probably relates to comment's observation re index size.  In many cases the difference will be academic, with little real-world impact, but it may make a palpable difference in some settings.  I've tended to use Jeremy's numeric UUID function, but that's just my preference, and I've always been a fan of surrogate (meaningless) keys anyway.  (BTW, if you need a multi-valued key, as in Selector-Connector for example, that can be a text field and still link to numeric pk fields.)

hth,

Mark

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.