FileMaker Pro 11 Essential Training
Illustration by Richard Downs

Defining primary and foreign keys


FileMaker Pro 11 Essential Training

with Cris Ippolite

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Video: Defining primary and foreign keys

Once we've gone through the process of determining which key fields we're going to need in our database in order to create our relationships, the next step is going to be to go in and define those fields inside of the FileMaker databases. So if we open up our Exercise File/04_ 04, we see that under File and Manage > Database, we've got our four different tables created. So let's start first with defining all the primary keys in the tables that are going to act as Parents, and if we look back at our list, we determine that the tables that are going to have primary keys are going to be Customers, Invoices, and Products.
Expand all | Collapse all
  1. 7m 22s
    1. Welcome
      1m 8s
    2. Understanding the FileMaker family
      2m 15s
    3. Using the FileMaker Quick Start screen
      2m 52s
    4. Using the exercise files
      1m 7s
  2. 21m 9s
    1. What is a database?
      2m 26s
    2. Flat vs. relational databases
      2m 29s
    3. How FileMaker works
      4m 48s
    4. Understanding the essential preferences
      3m 13s
    5. Touring the interface
      8m 13s
  3. 11m 44s
    1. Creating databases from templates
      2m 29s
    2. Creating new databases in the spreadsheet-like format
      5m 35s
    3. Importing tables
      3m 40s
  4. 9m 9s
    1. Determining which tables you will need
      5m 10s
    2. Creating tables in the Managing Tables window
      3m 59s
  5. 34m 47s
    1. Understanding relationship types
      6m 58s
    2. Diagramming relationships (with ER diagrams)
      8m 50s
    3. Determining which key fields you need
      5m 18s
    4. Defining primary and foreign keys
      7m 56s
    5. Creating relationships using the relationships graph and table occurrences
      5m 45s
  6. 50m 34s
    1. Deciding what fields you will need
      5m 34s
    2. Understanding field types
      7m 54s
    3. Defining fields
      9m 56s
    4. Using Auto Enter options in fields
      9m 33s
    5. Reviewing field validation options
      8m 16s
    6. Building with container fields
      9m 21s
  7. 14m 8s
    1. Creating and duplicating records
      5m 40s
    2. Editing and locking records
      4m 42s
    3. Deleting records and backing up files
      3m 46s
  8. 21m 6s
    1. Importing data
      9m 57s
    2. Importing records to refresh data
      7m 2s
    3. Exporting data
      4m 7s
  9. 18m 30s
    1. Understanding layouts
      4m 15s
    2. Using the Layout Assistant to create List views
      7m 59s
    3. Using the Layout Assistant to create labels and envelopes
      6m 16s
  10. 27m 11s
    1. Using the Layout Setup dialog box
      4m 54s
    2. Understanding layout parts
      4m 40s
    3. Understanding the new Inspector
      2m 26s
    4. Exploring the Status Area in Layout mode
      6m 46s
    5. Managing layouts and layout folders
      8m 25s
  11. 41m 9s
    1. Arranging, aligning, grouping, and locking layout objects
      11m 5s
    2. Placing and formatting objects, parts, and graphics
      4m 10s
    3. Formatting fields and applying field attributes
      8m 26s
    4. Setting field behaviors
      4m 4s
    5. Using the Tab Control feature
      9m 8s
    6. Setting tab order
      4m 16s
  12. 36m 48s
    1. Using the basic find functions
      7m 31s
    2. Reviewing new requests in the Find mode
      5m 54s
    3. Establishing search operators
      6m 43s
    4. Constraining or extending found sets
      3m 24s
    5. Finding records using date, time, or timestamp criteria
      5m 18s
    6. Using Fast Match and Quick Find
      4m 41s
    7. Working with saved finds
      3m 17s
  13. 17m 28s
    1. Sorting with one criterion
      6m 4s
    2. Sorting with related fields
      2m 18s
    3. Sorting with multiple criteria
      1m 36s
    4. Sorting using custom values
      3m 14s
    5. Sorting using buttons
      4m 16s
  14. 17m 14s
    1. Reviewing Field/Control styles
      5m 43s
    2. Creating and applying static value lists
      5m 20s
    3. Creating and applying dynamic value lists
      6m 11s
  15. 23m 52s
    1. Previewing pages and print options
      6m 20s
    2. Printing in different views
      2m 54s
    3. Sliding objects
      3m 26s
    4. Printing merge letters
      4m 53s
    5. Saving as a PDF or Excel file
      6m 19s
  16. 15m 1s
    1. Building simple reports with summary fields
      4m 36s
    2. Creating subsummary reports
      6m 51s
    3. Creating subsummary reports in Table view
      3m 34s
  17. 52m 19s
    1. Defining calculations
      2m 31s
    2. Exploring the Calculation dialog box
      5m 8s
    3. Using number functions
      12m 41s
    4. Using date and time functions
      4m 58s
    5. Using text functions
      11m 43s
    6. Using get functions
      4m 0s
    7. Using logic functions
      11m 18s
  18. 46m 56s
    1. Understanding scripts and script steps
      2m 23s
    2. Assigning script steps to buttons
      3m 54s
    3. Understanding the ScriptMaker dialog box
      8m 28s
    4. Creating multi-line scripts
      6m 44s
    5. Adding find criteria to a script
      4m 58s
    6. Understanding the If script step
      8m 36s
    7. Using script parameters
      4m 42s
    8. Reviewing the Send Mail option
      7m 11s
  19. 28m 0s
    1. Understanding script triggers
      2m 41s
    2. Using object-based triggers
      11m 58s
    3. Using layout-based triggers
      7m 51s
    4. Using file-based triggers (Open and Close scripts)
      5m 30s
  20. 56m 42s
    1. Using related fields
      7m 18s
    2. Creating portals and using portal filtering
      10m 38s
    3. Using related fields in calculations
      7m 6s
    4. Understanding multi-predicate relationships
      11m 11s
    5. Using the Go to Related Record script step
      7m 26s
    6. Creating a chart
      13m 3s
  21. 30s
    1. Goodbye

please wait ...
Watch the Online Video Course FileMaker Pro 11 Essential Training
9h 11m Beginner Jun 25, 2010

Viewers: in countries Watching now:

In FileMaker Pro 11 Essential Training, Cris Ippolite demonstrates the principal features and functions of this popular database software, including creating tables and relationships, managing fields and records, and working with layouts. The course shows FileMaker developers how to find, sort, and share data as well as how to create reports, calculations, and scripts. It also covers brand new features in FileMaker Pro 11 such as the Inspector tool, charting, and portal filtering. Exercise files accompany the course.

Topics include:
  • Creating databases from templates
  • Creating fields in spreadsheet format
  • Creating tables and relationships
  • Defining key fields
  • Adding validation and auto-enter values to fields
  • Managing records, including duplicating, locking, and deleting records
  • Creating and managing layouts
  • Formatting layout objects
  • Finding and sorting data
  • Creating calculation fields
  • Building reports
  • Printing and saving as PDF or Excel
  • Writing and triggering scripts
  • Using relationships throughout a database
FileMaker Pro
Cris Ippolite

Defining primary and foreign keys

Once we've gone through the process of determining which key fields we're going to need in our database in order to create our relationships, the next step is going to be to go in and define those fields inside of the FileMaker databases. So if we open up our Exercise File/04_ 04, we see that under File and Manage > Database, we've got our four different tables created. So let's start first with defining all the primary keys in the tables that are going to act as Parents, and if we look back at our list, we determine that the tables that are going to have primary keys are going to be Customers, Invoices, and Products.

So let's start with Customers. First, in your Manage Database window, you'll notice that under the Tables tab, if you select a Table and double-click on it, it's going to navigate you over to the Fields tab. And normally there will be a list of all the fields, but since we haven't defined any yet, we see that we've got a blank list. Our cursor is down in the Field Name, and like we would define any field inside of a FileMaker database, we are going to first start and define our Primary Key field. What we need to do is decide on a name that we're going to give our field, and for key fields it's usually a good idea to follow some kind of naming convention so that later you can easily go into your field list and quickly find a key field.

And there are various different types of naming conventions to use, and none of them are right or wrong. The convention that I like to use though is to add a prefix to the name of the field that indicates whether it's a key and what type of key it is. So in the case of primary keys ,I'd like to use pk, but I also like to have my key fields appear at the top of my field list. When we have a bunch of different fields here, they are going to be organized sometimes alphabetically, sometimes by creation order, as you see here, but traditionally when organized alphabetically, I want my key fields to show up on top.

So one way I can do that is to add underscores; here is a single underscore that I can add to the prefix of my Field Name, which will always make it show up on top and in alpha sort. But since it's a Primary Key, I wanted to show up even above any other type of key, like a Foreign Key, so I am going to give it two underscores. So basically here the naming convention in file name for a Primary Key is __pk, and pk stands for Primary Key. Finally, I'd like to end the key field with the name of the table, with the word ID after it.

So in this case CustomerID, and we'll keep it as text, and I'll hit Create. In the Comment field, I am going to say primary key, and I am going to hit Change and we see that that gets stored with the field. Comments don't have any change on functionality whatsoever. It doesn't make it a Primary Key. That's just a note to me as I'm flipping through fields in the future to help me identify which one of these serves as the Primary Key. We can leave this field as text, even though it's going to count up numbers for us, so it really won't matter either way, but one important thing that we are going to want to do is make sure that this field is unique and also make sure that it gets an unique number every time a new record is created, because remember the requirement for a Primary Key is that they are to be unique and not empty, and ideally, they shouldn't be modifiable.

So in order to do that, we are going to hit the Options button to set these different properties inside of our Primary Key field. We'll talk about these options later in the Fields chapter, but specifically for the use of a Primary Key, we're going to go under the Auto-Enter tab and hit Serial number. And in general what's happening here is on the creation of a new record, a value will be placed inside of the FileMaker field, and the FileMaker application will ensure that it never gives the same number to more than one record inside any given table, therefore verifying the uniqueness of this field.

So we are going to choose Serial number, and we are going to leave next value and increment by 1. So now when we create the first record in our Customer table, it will automatically put a 1 in there, and the second record a 2, third record, 3 and so on. Thus this will ensure that these records are not empty and that they have a unique value, all in one setting. Now we also don't want any users changing these because then a user could go in and change it to a value and thus either delete the value, which would make it empty, or enter in a duplicate value, which would of course make it non-unique.

So we are going to click this button down on the bottom here called Prohibit modification of value during data entry. Now our Primary Key value cannot be changed by a user, and it'll be unique and not empty. So let's hit OK, and now we see all this information show up inside of our Primary Key field: Invoices and Products. So we can switch to different tables through this dropdown and go to Invoice, and let's just file the same convention. We'll do this one a little bit quicker.

So we see __pkID, call it primary key for invoices, hit Create, hit Options, Serial number, Prohibit. Now I did those steps a little bit quickly because we reviewed them in detail prior. We'll hit OK. So now we have two out of our three primary keys. But if you look in your products, since we imported this in already, you'll see that we already have an _ pkProductID with these values already set.

So really now we're done defining the primary keys inside of our database. So since every relationship needs to have a Primary Key on the Parent side, and then it has to have a Foreign Key on the Child's side, that means that we have to define some foreign keys in to our tables here as well. So on our List we see that there are only two tables that are acting as a Child in the relationship: Invoice and Invoice line item. So we see that Invoice needs one Foreign Key, and Invoice line items needs two. So back in our Database, we'll go to Invoice, and we're going to define a Foreign Key, this time underscore, and we're going to use fk, but which one do we need? Well, if we look back at our relationship, Invoice acts as the Child in the Customer and Invoice relationship.

So that means it needs to have a Foreign Key that matches the Customer. So what we do to make this easier for us to follow is we will use the customer name inside the definition of the Foreign Key. So we are going to call it fkCustomerID. We'll just leave that as text as well and hit Create. As you'll see now because we used a single and double underscore, if we sort by the Field Name, we see that our Primary Key shows up on top and then our Foreign Key on the bottom. We don't have to have set any settings because if you remember the rule for a Foreign Key is it doesn't have to be unique, and it can contain duplicate values.

So we don't have any field options here, but we can enter fk for Customer. And again, comments don't affect any of the functionality. It's just there for us to be able to see if we click on Options or Comments, we can see what the role of these different fields are. Now we go into Invoice line items, and we know that we need two different foreign keys. Invoice line item acts as a Child in the Invoices to Invoice line item relationship and the Products to Invoice line item. So if we need two different keys and we need to name them after the Parent, that means that we need a Invoice ID Foreign Key and a Product ID Foreign Key.

So let's define those. Create a new one. We'll say fk for Product Invoice ID. Now we have all our key fields set up, and we can hit the OK button to close the window. Now our next step is to create links between these tables now that we have the hooks, otherwise known as keys, already in place inside of our tables.

Find answers to the most frequently asked questions about FileMaker Pro 11 Essential Training .

Expand all | Collapse all
please wait ...
Q: In the Chapter 16 tutorial, “Using Text Functions,” the instructor discusses how to calculate the First Name and Last Name from the Full Name. However, the method does not account for names ending with  “Jr.” or “Sr.” or “III,” etc.  How can I account for added suffixes in names?
A: For cases like this, you can create a third "Suffix" field. Then change the FullName calculation to:

NameFirst&" "&NameLast&" "&Suffix 

This way, nothing will appear if the Suffix has no value, but if it does have a value the suffix will appear.
Q: What information is actually on the “Invoice Line Item” table in the examples, and how does it actually connect to the tables that it comes from?
A: The information in each line item is native to the "Invoice Line Item" table. The fields are defined in that table and each record represents "A Product appearing on an Invoice."
Each time a product is used on an invoice, a record in the line item table is created. Many of the fields, for example "Quantity," are native to that table because those values only exists when a Product is used in an Invoice, and not as attributes of a Product itself.
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed FileMaker Pro 11 Essential Training.

Return to your organization's learning portal to continue training, or close this page.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.