One of the most important aspects of understanding FileMaker Pro is understanding field types, how they're different from one another, and how to use them effectively.
Simply stated, field types identify what kind of information each field of your database is expected to hold. A person's name is text, the dollar amount for a transaction is a number, a birthday is a date, and so on. Generally it should be quite clear to you what each needs to be.
Field types determine what types of operations can be performed on a given field, what information a field can accept, and the rules by which a field is sorted. It's the combination of a proper identifying field name and a data type definition that gives a database its context and meaning.
Text
Text fields are the most free-form of the field types. Users can enter any range of information in them, including carriage returns, and there's no expectation of what form or sort of information a text field will hold. The only requirement is that it be character basedin other words, you can't place a picture in a text field. A text field can store up to 2GB of information, limited by RAM and hard drive space, of course, and indexes up to approximately 100 characters, depending on what language you're using. We'll cover indexing in more depth later in the chapter. For now, simply remember that each field type has different limits and approaches on indexing.
Number
Number fields can store values from 10-400 up to 10400, and negative values in the same range. FileMaker Pro indexes the first 400 significant digits (numbers, decimal points, or signs) of a number field, ignoring letters and other symbols. Number fields can accept text (although not carriage returns), but any text in a numeric field is ignored. FileMaker interprets 12ax3 as 123 if you enter it into a numeric field, for example.
Something to keep in mind with FileMaker Pro: A number field can be expressed as a Boolean. A Boolean value is either true or false, and is often used to test the condition of something. A zero or null value in a number field is treated as false in the Boolean sense; any other data is treated as true. You will often run across number fields being used to store Boolean values.
The primary distinction between a number field and a text field lies in how they're sorted: A text field sorts 1, 10, 2, 20, 3, 4, 5, whereas a number field sorts 1, 2, 3, 4, 5, 10, 20.
Date
Date fields accept Gregorian calendar dates only. FileMaker Pro honors whatever date formatting your country follows by taking the standard your operating system uses at the time a new file is created. Date formatsthe order of year, month, and dayare common for a given file. Although it's possible to change the way dates are displayed, it is this basic ordering that is fixed at the time of file creation.
Dates in FileMaker Pro are internally stored as the number of days since 01/01/0001. January 1, 2004, for instance, is 731581. If you need to compare dates or perform any functions on them, remember that behind the scenes they're really just numbers. This feature is actually quite handy. To switch a date to a week prior, all you need to do is subtract seven.
Date fields can store values from January 1, 0001, to December 31, 4000.
If your fields are sorting or displaying oddly, refer to "Mismatched Data Types" in the "Troubleshooting" section at the end of this chapter. |
Time
Time fields hold HH:MM:SS.ddd information. Notice that a decimal may be added to the end. Also useful: If a user enters 25:00, FileMaker Pro rightly interprets this as 1:00 a.m. 99:30 becomes 3:30 a.m. The clock simply keeps rolling over. This behavior is useful when you need to add, say, 30 hours to a time, and don't want to be bothered with calculating what hour that becomes. Likewise, if you are doing data entry in a time-tracking system and don't want to create two entries for a case in which you worked from 2:00 p.m. until 2:00 a.m. on Monday (really Tuesday), entering 26:00 for the ending time in your system rightly calculates to 12 hours.
As in dates, FileMaker Pro stores time internally as the number of seconds from 12:00:00 on the current day. 1 is 12:00:01, and 43200 is 12:00 p.m. As with date formats, your time format is established during the creation of the file, based on system operating system settings.
The maximum time value you can store in a FileMaker Pro time field is 2,147,483,647. That's a lot of time.
Timestamp
The timestamp data type combines date and time information. It appears as a field with both date and time values, separated by a space: 1/1/2004 12:00:00. As in date and time formats, timestamps are also stored as numbers: the count of seconds from 1/1/0001 00:00:00. Be prepared to work with large numbers when using this field type. Timestamps are an important aid to interoperability with other databases (such as those powered by the SQL language), which often store date and time information in a single timestamp field.
The maximum value of a timestamp is 12/31/4000 11:59:59.999999 p.m. or 126,227,764,799.999999 seconds.
Tip
To extract just the date from timestamp data, simply use the GetAsDate() function. Likewise, use GetAsTime() to extract just the time.
Container
Container fields are different from the five already mentioned: They store binary information. Information is often inserted into container fields rather than being entered manually (you can copy and paste). You can place any sort of digital document in your database, limited again by the practical limits of your computer hardware, up to 4GB.
Container fields also support displaying/playing three native types of media: pictures, QuickTime movies, and sounds. Refer to the FileMaker help system for supported formats, but most common image formats are included...as well as some you won't expect. For example, by using QuickTime, it's possible to display and play a Macromedia Flash 5 .swf file.
Last, on Windows, a wide range of OLE objects are supported, including Microsoft Excel documents, PDF, and more.
There's one important thing to remember about using container fields: Either you can store the file or media in FileMaker itselfrequiring disk spaceor you can simply store a path reference to the file instead. If you choose to store just a reference to the file, FileMaker Pro, somewhat like a web browser, displays the image or file icon as necessary, but does not hold the actual document itself. A nice feature of storing references is that you can then double-click documents in your container fields to launch them in your operating system.
Caution
Keep in mind that if you move the source document, the FileMaker Pro reference remains but is no longer valid.
Calculation
Calculation fields evaluate formulas and display the requisite results. When you create a calculation field, the Specify Calculation dialog, shown in Figure 3.2, opens.
Figure 3.2. Calculations form an essential pillar of FileMaker Pro development.
Be sure to refer to FileMaker Pro's online help or our companion book, FileMaker 8 Scripts and Functions Desk Reference, for a complete list of functions. The book presents every function in FileMaker along with discussion and examples. |
The features of the Specify Calculation dialog box include the following:
The menu above enables you to filter your list by category to show the functions you need.
Examples of calculations include the following:
Calculations are fundamental to FileMaker programming, and it's worth your while to master them fully.
For more detail on calculations, see Chapter 8, "Getting Started with Calculations," p. 217, and Chapter 14, "Advanced Calculation Techniques," p. 391. |
If your calculation formula looks correct, but FileMaker is returning an odd result or ?, refer to "Mismatched Calculation Results" in the "Troubleshooting" section at the end of this chapter. |
Summary
Summary fields allow you to evaluate information across a found set of records. Sum, Average, Max, Min, and Count are among the summaries you can establish. Don't forget that they apply to found sets: Change your found set, and the result changes.
For example, say you have a table called Transaction, which contains Transaction_Date and Transaction_Amount fields. You can then define and place on a layout a summary field to total the Transaction_Amount field. The summary field adds the values of the Transaction_Amount field for whatever set of records is currently active. If you perform a find, by date, on 10/1/200610/31/2006, your found set will be all the transactions for the month of October, and the summary field will show just the aggregate monthly transaction amount. Perform a different find request and your total changes, reflecting the aggregate of the new found set.
Table 3.1 contains a list of summary field functions.
Function |
Summary Behavior |
---|---|
Total of |
Adds values from the specified field in your found set. Think of it as a subtotal or grand total from a column of numbers. |
You may also enable the option to display a running total for your recordset. This then shows a running tally of your total if you place the summary field in the body area of a list. |
|
Average of |
Averages the values from the specified field in your found set. The weighted average option enables you to specify a second field to act as a weight factor for calculating the average. |
The field you choose must be a number or a calculation with a number result. |
|
Count of |
Counts the number of records in your found set that have valid data in the specified field. For example, if 18 of the 20 current found records have data, your summary field will display 18. |
A running count functions similarly to a running total: It displays the incremented count of each record in your found set. |
|
Minimum |
Returns the lowest number, date, time, or timestamp in a given found set from the referenced field. |
Maximum |
Returns the highest number, date, time, or timestamp in a given found set from the referenced field. |
Standard Deviation of |
Determines how widely the values in the referenced field differ. Returns the standard deviation from the mean of the values in your found set. |
The standard deviation formula is n1 weighted, following the normal standard deviation. |
|
Standard deviation comes in two flavors; to perform a biased or n0 evaluation, select the By Population option. |
|
Fraction of Total of |
Returns the ratio of a total for which a given record (or set of records, when the field is placed in a subsummary part) is responsible. For example, you can track what percentage of sales are attributable to a given person. |
The subtotaled option enables you to specify a second field by which to group your data. |
When you create a summary field, the Options for Summary Field dialog opens, prompting you to choose the function you want to use and the field for which you want a summary (see Figure 3.3).
Figure 3.3. Summary fields are useful for performing functions across sets of records, but use them with care. They can increase the time it takes to load any given layout.
It's generally a good idea to place summary fields on their own layouts so that a user deliberately chooses to have them evaluate a found set.
In Browse mode a summary field will evaluate your found set and display a result when it is actually visible on a layout. For example, if a summary field is below the visible portion of a layout, it will display information only when the user scrolls to that portion of the window.
Summary fields will evaluate a found set for a given layout whenever you enter Preview mode.
Part I: Getting Started with FileMaker 8
FileMaker Overview
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
Implementing Security
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
FileMaker Mobile
Documenting Your FileMaker Solutions