|
February 2003
In this Issue
To have a look at the last issue, click here now
Main feature
So which fields go where?
What's Next
Back to top
Back to top
Back to top
Back to top
Details on QuickToolKit
The best way to explore the tool without any of the marketing hype is to download a special in-depth presentation written in FileMaker for the Developer Conference in August 2002. This requires FileMaker 5.x or 6. Click here to download now:
Mac | Win
|
Back to top
Back to top
Back to top
Back to top
Download sample files:
Mac | Win
|
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Back to top
Details on QuickToolKit
The best way to explore the tool without all the marketing hype is to download a special in-depth presentation written in FileMaker for the Developer Conference in August 2002. This requires FileMaker 5.x or 6. Click here to download now:
Mac | Win
To order follow this link which will allow you to get the special reduced pricing. Click here now to order QuickToolKit Fast&Easy from secure server. (and yes you get about 30% off!)
|
Back to top
Back to top
Back to top
Back to top
|
|
|
Welcome to this issue of TheBetterFileMakerDeveloper. This is an article in a series of 17 where we explain the ins and outs of getting your FileMaker Pro development right from the very beginning, saving you lots of time and effort in your development.
In each issue you will find an article, usually with lots of illustrations and examples. In each issue you will also find a more technical article taking you through a specific subject. These technical articles are usually supported by example files downloadable from our web site.
Finally we present to you some special offers, for BetterFileMakerDeveloper subscribers only, which we have negotiated through our partners.
Best of all, we assume you will really be too busy to learn anything new. That's why we have introduced our concept of effortless. So join us on this learning journey of becoming a BetterFileMakerDeveloper.
If you're not already a subscriber click here now to get a trial subscription for 6 months - it's absolutely free.
To view back issues on the BFMD site, click here.
Talk the structure. Say the one person has many contact notes, one contact note belongs to one person only type of sentences. Do it with the end users . They will always be able to pick the holes in these structures.
Play out the processes. Try and talk through how each process (script) will work. Find out which file each will need to run from. Are the fields you need in that file?
Work through your reports. Many reports need to span data from several different files (entities). In some cases you must combine several entities into the one file in order to report on the data. In other cases the entities need to occupy different files for other reasons and you must work out if you can create a report that combines the data from the different files.
Formal 1Entity Combination. Check whether similar entities should be combined. You may have sales transaction lines and purchase transaction lines. But in reality they are all transaction lines, one is just debit, the other credit. You can create useful reports if the two are combined into the one file, but not if they are kept separate.
Formal 2Entity Splitting. Check whether entities containing dissimilar entities should be split. Check the placement of your fields. This sounds so trivial but is in fact so difficult we will cover that separately in the next article. Sometimes it is pretty obvious. Like does the persons name belong in the Org file or in the Person file. But what about interests? Is that a persons interest or is that interests as expressed by different people in the company over time?
Usability of Data Structure. OK, so this sounds obvious, youd say. Yes, but in real life it is not. In reality most system designs fail simply because the ensuing system is not usable.
Future-proof your system. Some people draw up their structure, and do it right. But they expect the world will never change. Only good file structures that are built so they can easily change will survive the changes of the modern enterprise. I will show you how to ensure your files are future-proofed.
So which fields go where?
|
That is a question that is often pondered by FileMaker developers like the question of the universe. Do I put the field in this file or in that?
Why is this so hard? Well, experience shows that getting field placement right is very often not intuitive at all, so it goes wrong. And more importantly it is often not considered all that important. Ill show you here why it is important and how it is easy to get it right every time.
So what are the rules? The rules are quite similar to what I presented in the last issuegetting your structure right. And then there are some differences.
For starters we will take fields type by type and then look at the specifics.
Entry fields: Text, Number, Date and Time and Container fields: These simply need to be in the file where they will be entered. It is important that they are created in the file where they naturally belong (see about Normalization in our previous chapter to find guidance on where that is).
Well cover more about that below.
Calculation fields: These are very often used for reports. Where this is the case they should, as a rule, be placed in the file where the report is constructed.
Remember as you create calculation fields that these can combine data from any number of files above, and, to some extent, from files below.
Remember that calculation (and other fields) can be referred to directly from a layout in another file (provided the fields are only one file away from the layout). This can often be used advantageously to create a set of calculation fields in a file above that is subsequently used by several files below it for different reports. This could save you a lot of time.
Summary fields: These are almost exclusively used on reports, and to be of any use must be created in the file you are creating the report layout in.
Summary Calculation fields: These are a great way to summarize data from one file to another. Be warned, though: Lots of summary calculation fields on a layout (or even a few with lots of data underneath) will slow down record display very dramatically. So, typically these are placed in the file above where the data exists that they summarize.
Global fields: This is a complex area as there are many uses for global fields:
Globals that hold fairly constant settings or preference values: These are best held in a Menu file containing only one record. To obtain truly global fields, create them as text/number/container/date/time fields in the Menu file (and not as globals!) That way all users will see the same value. To create user-specific globals create them as Global fields. Global fields acquire a separate value for each user in a networked system. In all cases it is preferable to keep these in the menu allowing different files in your system to access these settings or variables.
Processing variables: If a variable is needed while processing within a script it is a good idea to keep your variables in a Global field in the file in which youre processing. Remember that the global can hold a different value for each user.
Data Exchange Variables: In many cases a lot of variables are used to exchange data between one script and the next. Usually it is best to keep such variables as Global fields in the Menu file. That way all files can access the variables on equal footing.
So that was the type-based rules for field placement. Now, lets look at some of the other rule sets:
Given a hierarchy of files

Let us try to place the field Interest(s)
If we placed it in the Org file, what do we do when two different people belonging to the same Organization have different interests? Simply put we cannot store that information.
If we place it in the Activity file, we find that although this may work well logically as we only discover the interest when we do an activity with them (be that a phone call, a meeting or whatever) it still gives rise to some issues. What say you have 10 phone conversations (activities) with that person, all centered around the same interest? You would end up with a truckload of redundant data.
The end result is clear here: Place interests in the Person file. What may still be less clear is why?
The simple answer is to talk through the structure as we just did. You want a more scientific answer? Place the field where it will be able to accurately represent reality for the vast majority of your dataset and only create a minimum of or no redundancy of data when stored.
Fields in M2M Situations
In what situations, I hear you say? Hey, were just returning to the un-implementable Many-to-Many (M2M) relationship.

A new balance has to be struck here: You want as much as possible squeezed down into the M2M file, but at the same time you want to keep it as light as possible. Let me elaborate:
Order
OrderDate
Client Details
Order Number
Product
Product Code
Product Description
Price
OrderLine
This becomes the simple product of the two above. However, it will naturally acquire a few fields on its own:
Quantity
Now that was the easy part, lets look at some of those fields that are harder to place:
Line Total (=Quantity * Product Price LU). If we make the line total (as the name indicates) in the OrderLine file, we can summarize this field two ways:
- In Product: Sum(OrderLine::Line Total) will give us total sales of that product
- In Order: Sum(OrderLine::Line Total) will give us the total for any given order.
Field storage of data from other files.
Lets digress for a moment: Storage of field values. Did you notice that the Product Unit price is stored in the OrderLine file as a looked up value? Why not simply define a related calculation like Line Total = Quantity * Product file::Product Price? Well, what if the price changes? Would you like all your past orders to change? Most likely not!
It is important for every field that is transported from one file to another to ask yourself how that should be transferred and stored. There are essentially 3 choices:
- A lookup, which will transfer the value from one file to another and store it in the second file as well. The transfer of value(s) can be triggered by a relookup which will transfer fresh values, so be careful not to do this if you would like to preserve the old values.
- An auto-enter calculation. This will also transfer the value from one file to another but cannot be refreshed. Furthermore, the transfer is a once-off. If for instance in our example above you selected one product and that fetches the price and subsequently you changed your mind and changed the product, the Auto-Enter field would still retain the price of the first product. Not a convenient feature in this case.
- A related calculation field. This is simply a calculation of the type Line Total = Quantity * Product file::Product Price. Whenever the related value changes the field changes. This is great if the data must be current in both places. It is also good if it is simply a reference. However, as outlined above some data should be frozen in time, and in that case this solution does not work.
Storage footnote: Bear in mind that lookups and auto-enter calculations store the actual data in the file they exist in. However, a related calculation field will add no data to the file it is in, and this has impacts on search speeds and on the size of the file.
How fields can wreck your Structure
Shipping Date: If we assume that all lines of an Order will always be shipped at the same time the Shipping Date belongs on the Order. However, in real life part-deliveries, back-fills, back-orders and so on are commonplace. If you think that real-life situation may also occur for your system, the Shipping Date needs to be on the OrderLine!
But it gets worse: Consider that the consignment note that goes with each shipment and details what is in the shipment has a note field. The operator can enter any useful details about the order/shipment.
By most peoples logical reasoning this is a field on the Order, youd probably call it order notes. But as above, what if you need different notes on each physical part-shipment of that order?
This is where design-wise youd need to make an important choice: Should there really be an extra entity or file inserted in your system?

My answer is probably yes if every single order has many shipments. Your system will quickly become centered around tracking shipments which obviously in this kind of business is important.
But what say the Order ever only has more than one shipment in 5% of cases? There is another solution!
Again, this is not a textbook solution but it is a practical FileMaker based one. After all, you do develop this in FileMaker Pro.
Changing structure to process
The solution is to simply split the order! If you look at the illustration below; the order originally had 5 order lines. After splitting the order (creating a 1st and a 2nd part of that same order number) the first order now has 3 order lines and the second has the remaining two lines.
All it takes to do is a bit of clever scripting and you can do it completely automatically. This is another example of keeping the data structure tight instead of compromising the structure for the sake of something that rarely occurs.

To reiterate the rule: Place the field where it will be able to accurately represent reality for the vast majority of your dataset and only create a minimum of or no redundancy of data when stored.
The simple Rules
There can be many more examples like this. Again, this is of course just one example. So whats the rule, you ask?
- Initially push a field up to either of the two files above it.
- Check that in real-life situations you can think of, the field can NEVER have different values within the same record (in the example above, within the same Order).
If it could possibly have different values in the record above push it down again, into the M2M file.
Avoiding fields in the Wrong Places and fixing it up when it happens
Back to reality: Fields do end up in the wrong places, so how to fix it up, you ask.
Nobodys perfect and field placement will inevitably be flawed from time to time. The requirements of the system change and suddenly you see the structure is inadequate.
Here is how to minimize the damage in the first place and how to fix it up if it happens:
- Always use a structured development approach like QuickToolKit. This allows for much easier and more flexible restructuring of your system.
- Ensure you create an entity-relationship or a file-structure diagram before you start.
- Ensure that whenever you make changes to the system that affects the structure (like adding a new file), update your diagram. Having the diagram to look at when youre faced with a difficult question like a restructure means it is usually resolved within minutes.
- Ensure you follow a logical naming protocol (more about that in a later chapter). One thing is finding and moving the data field in question. That is easy. Another thing entirely is finding the 12 fields that depend on that field in some way.
Wrapping up
So as you can see there are a number of considerations concerning field placements in files and ensuring you get the right field types:
- Move fields up or down to test whether data redundancy is reduced while retaining meaningfulness.
- Check data field types to make sure you select the right method of transfer (lookup, related, auto-enter).
- Remember that for data constructs that happen rarely you may be better off substituting structure with processes.
- Watch out for fields that may wreck your structure.
- Use a structured development environment (like QuickToolKit) to make it easier if eventually you have to make changes.
In the next issue we will focus on relationships in the context of putting together the overall structure of your solution. Relationships is an often misunderstood area in FileMaker which is why well devote some extra time to the area.
How to Subscribe
Subscribe today to take advantage of this special offer: Normally the article series is $97 per year but for the time being were offering you a 6-month subscription (web only) completely free.
As a special thank-you we will immediately send you a free copy of the DeveloperCompanion Lite for FileMaker Pro ($19.95 value)! This will allow you to completely plan your FileMaker development project and make it much easier and faster to make your system right the first time, regardless of what youre developing.
To subscribe to TheBetterFileMakerDeveloper simply follow this link: http://bfmd.net
This publication is copyright ©2003 Coretech System Inc. All rights reserved. This document may not be copied in part or full without express written permission from the publisher.
|
|
|
About the Author
The editor of TheBetter
FileMakerDeveloper is Michael Plener. Other highly recognized FileMaker authorities also contribute regularly to TheBetter
FileMakerDeveloper.
Michael has had a career in information management and consulting for over 15 years on 3 continents. He has worked with FileMaker since it was FileMaker II in 1993.
He has led training seminars and courses for users as well as for advanced developers.
Michael was one of the pioneers behind the development of the QuickToolKit, the leading fast-track development environment for FileMaker www.quicktoolkit.net
Through the development of this and other learning and development resources for FileMaker developers, he has gained a deep understanding of what makes the difference between an average FileMaker developer and one who develops solutions almost effortlessly at much higher velocity than the average person.
At the time of taking the FileMaker Developer knowledge test at the FileMaker Developer Conference, Michael achieved the highest recorded score ever.
|
So what is a Menu anyway?
You have already heard me refer to a Menu file on numerous occasions. So why is this so important?
First of all: You can call it whatever you want as long as it makes sense to you and those who use it. It can be a Start file, a Home file, a XXX Central file, etc. Lets go through the different uses:
Menu as navigation point: Most users prefer a central point to come back to from where they go to any part of your system. The Menu fulfils this role easily.
Menu as program control point: It is a lot easier to set up your system when one file controls everything else: Security access, reports, preferences, startup and opening of all files and so forth. The Menu file fills this role perfectly. QuickToolKit has some clear examples ready to use on how this is done.
Menu as variable control. Inevitably your Person file will want to exchange data with your Org file. Instead of letting each file talk to every other file when it comes to passing processing and control variables (which means you need to cover all the permutations of the number of files) you simply let each file communicate only with the Menu file. Easily and simply done. Easily extensible. Again QuickToolKit provides some solid ways of implementing this if youre not game to do this yourself.
However doing this sort of variable control saves you a lot of time and means that debugging becomes immensely easier as you can watch all your variables in one central location. |
Resolving the Many-to-Many
This is something you quickly become accustomed to if youre not already. Resolving M2M relationships is always done on paper as the relationship cannot be implemented in FileMaker Pro.
So what are the rules? Its pretty simple at its most basic. Each record in the M2M file need to contain the ID of either one of the files above, and is not complete until it does. In the example here the Order-Line file need to contain the Order ID and the Product ID. It is not uncommon that apart from these two fields the M2M may contain very few fields. In this example all it probably needs is the Quantity and any fields derived from this.
Importantly, M2M files seldom have a user interface as the data is usually entered through a portal. However, usually reports are run from the M2M file as reports are easily constructed for accurate results from the M2M file.
|
Fixing it up is really easy:
Create the new field. Let us follow the example we started with and say we need to recreate the Interest field in the Person file (was originally created in the Organization file)
Perform a replace from one file to another to transfer the data:
As per the example above:
- Find all Person records.
- Do a replace by clicking in the Interest field in the Person file and select Records->Replace Contents from the Menu. In the dialog that follows click on Replace with Calculated Result. This gives you a calculation dialog box.
- From the Relationships dialog top left select a relationship that points back up to the Organization file and once selected find the (old) Interest field in the Organization.
- Your calculation would now look something like: Organization on OrgID::Interest
Click the OK button which brings you back to the replace dialog box. Now click the Replace button.
This procedure gives each person the Interests that their respective Organizations have. This is usually the best starting point to let the new field inherit the values from the old field.
Find and change any calculation fields that were depending on the field youre about to remove. In our example with Interest there are not likely to be any. If you have a hard time figuring out which fields are dependent you can always try to delete the field youre trying to get rid of. FileMaker will actually tell you which field(s) is using it. Easy!
Delete the old field
Youre done. So that wasnt so hard after all was it? |
|
|