FileMaker 7 and 8 differ greatly from previous versions in their capability to work with many database tables in a single physical file. But there's a bit of a price to be paid for this power. Many, if not most, actions in FileMaker assume that some particular table is somehow the "active" table. Say you reach up to the Records menu and select Delete Record. Which table does that command affect? It affects the current tablebut how does FileMaker decide which table is current? The answer is that FileMaker determines this from what's called the table context.
Table context, it turns out, is determined by the currently active layout. Let's continue to refer to the Town-TownOfficer example. The steps to add the new table were simple, but there's some complexity underneath. After you're back in the Town database, you're still probably looking at the town entry layout, the one where you can view basic town information. But FileMaker has silently added another layout to the database.
In Layout mode, make sure that the status area is showing, and click on the layout pop-up list near the top of the status bar. There are now two layouts: one called Town, the other called TownOfficer. The new layout is named for the second table you added. You've already learned how the displays in the Status Area work. Add a few records while you're on the Town layout, and you'll see the total number of records, as listed in the Status Area, grow. More towns, more recordsno big surprise there.
But if you use the layout pop-up list to switch to the TownOfficer layout, a surprise is in store: The record total drops back to zero. Why?
The answer is that each layout is showing something different. The Town layout shows records from the Town table, and the TownOfficer layout shows records from the TownOfficer table. These tables can, and probably will, have different numbers of records. To make the concept still clearer, go ahead and add a bunch of records while you're on the TownOfficer layout. For TownID, pick some of the IDs of towns you've already createdthey'll probably be low numbers such as 15. You may want to choose View, View as Table to see the list in its entirety as it grows. Now switch back and forth between the two layouts to see the record totals shift.
In FileMaker 8, each layout represents a view into a particular database table. If you think back to the analogy of a database table as a card file, you can think of each table as a file containing a different kind of card. In the Town card file, each card holds information about one particular town. In the TownOfficer card file, each card holds information about a town officer in one of those towns. When you move from one layout to another in FileMaker, it's as though you're closing one card file and opening up another. Each new card file you open may have a different number of cards, with different information on each card.
FileMaker keeps track of all this by storing a table context with each layout. To see this, drop into Layout mode on the Town layout and choose Layouts, Layout Setup. Notice the menu that says Show Records From (you can see it in Figure 6.8). If you click on that menu, it lists all the tables for this database and shows that the layout is currently linked to the Town table.
Figure 6.8. This is the Layout Setup dialog, showing the table context for the TownOfficer layout.
In practice, you're unlikely to need to change the table context of a layout after it's been established. When you create a new table in a database, FileMaker adds the new table to the Relationships Graph, and also adds a new layout based on the table. You may, though, want to create additional layouts that refer to the same underlying table. In that case, you need to set the table context for the layout in the course of creating the layout. Again, you're unlikely to need to change this after it's been set. If you have a working layout that's displaying data from a particular table, you're likely to discover odd consequences if you change the table context.
There's some simplification in that last paragraph. Here's a more accurate rendition of the second sentence: "When you create a new table in a database, FileMaker adds a table occurrence for the new table to the Relationships Graph, and also adds a layout based on that table occurrence." The full importance of the distinction is made clear in the next chapter.
For a discussion of table occurrences, see "Adding a Table Occurrence to the Relationships Graph," p. 187.
Working with Related Data
Part I: Getting Started with FileMaker 8
Using FileMaker Pro
Defining and Working with Fields
Working with Layouts
Part II: Developing Solutions with FileMaker
Relational Database Design
Working with Multiple Tables
Working with Relationships
Getting Started with Calculations
Getting Started with Scripting
Getting Started with Reporting
Part III: Developer Techniques
Developing for Multiuser Deployment
Advanced Interface Techniques
Advanced Calculation Techniques
Advanced Scripting Techniques
Advanced Portal Techniques
Debugging and Troubleshooting
Converting Systems from Previous Versions of FileMaker Pro
Part IV: Data Integration and Publishing
Importing Data into FileMaker Pro
Exporting Data from FileMaker
Instant Web Publishing
FileMaker and Web Services
Custom Web Publishing
Part V: Deploying a FileMaker Solution
Deploying and Extending FileMaker
FileMaker Server and Server Advanced
Documenting Your FileMaker Solutions