Another way that business rules are more formally stated than most English sen- tences is their use offact types. A fact type characterizes the way noun concepts may be related. For an example, consider again the prohibition on personal checks inNo Checks.
No Checks:It is prohibited that a payment employ a personal check.
Implicit behind the rule is the idea that a personal check is the kind of thing that is conceivable to employ as a payment. Somewhere in the world there are restau- rants that accept personal checks as payments—just not the Mykonos restaurants.
By contrast consider the following statement that is not a rule at all:
Nonrule 2:It is prohibited that a payment employ autumn leaves.
Mykonos does not need to stateNonrule 2because no fact type relates payments and autumn leaves. There is no restaurant in the world that accepts autumn leaves as a payment for burgers and fries. Autumn leaves are not a kind of thing that is possible to employ as a payment for a restaurant meal.
BehindNo Checksis thefact-type diagramshown inFigure 6.11. A fact type diagram is a summary of what is expressible in rules. The sole fact type in Figure 6.11can be read aspayment employs personal check—that in princi- ple a payment can employ a personal check.
Figure 6.11is not a diagram ofNo Checksor in fact a diagram of any specific rule. InsteadFigure 6.11is a diagram of a single fact type that rules can build on.Fig- ure 6.11says that any rule that includes the noun conceptpaymentand the noun conceptpersonal checkcan relate those two noun concepts via the verbemploys.
payment personal check
employs
FIGURE 6.11 The single fact type on whichNo Checksis built
158 CHAPTER 6 Business Rule Models
In addition toNo Checks, the fact type ofFigure 6.11supports a huge variety of other potential rules. Some of these other potential rules are shown inTable 6.2.
Note that the fact type diagram ofFigure 6.11complements the business rule form diagrams shown inFigures 6.2 through 6.10. Each of the business rule form diagrams shows the structure of one of the business rule forms. For example, Figure 6.3 shows the structure of an obligation statement—that an obligation statement begins with the phrase “It is obligatory that,” continues with a manda- tory situation, then includes the word “if” and finishes with a condition. Fig- ure 6.11 shows a fact type that can be used in the mandatory situation or in the condition, or in both.
Multiple Fact Types
A business rule can be built on more than one fact type. Actually, a rule likeNo Checksthat is built on only a single fact type is an exception. Most business rules are built on multiple fact types. ConsiderVISA Only, the rule that restricts credit card acceptance to those that are backed by the VISA payment network.
VISA Only: It is permitted that a payment employ a credit card only if the credit card is backed by VISA.
VISA Onlyis built on two fact types:payment employs credit cardandcredit card is backed by payment network.Figure 6.12shows the two fact types and the way they relate to each other. The noun conceptpaymentis related to the noun concept credit card via the fact type payment employs credit card.
Table 6.2 Other Potential Rules That Use the Same Fact Type
Potential Rule Interpretation
It is obligatory that a payment employ a personal check.
For that odd restaurant that requires all payments be made in personal checks.
It is permitted that a payment employ a personal check only if the personal check is drawn on a local back.
A personal check is acceptable if another condition holds: the check is local.
It is obligatory that a customer be photographed if the customer makes a payment and the payment employs a personal check.
For the careful restaurant that wants to collect forensic evidence from customers who might bounce checks.
payment credit card
employs
payment network is backed by
FIGURE 6.12 The two fact types on whichVISA Onlyis built
The noun concept credit card is also related to the noun concept payment networkvia the fact typecredit card is backed by payment network.
There is some overlap betweenFigures 6.11 and 6.12. Both includepayment;
both include employs, and both use it in the same way. Figures 6.11 and 6.12 can be combined into a single diagram shown inFigure 6.13.Figure 6.13 shows the fact types that bothNo ChecksandVISA Onlybuild on.
Figure 6.13showspersonal checkas aspecialization ofmonetary instru- ment. The specialization association is expressed in the diagram by the arrow with the hollow arrowhead, and it is expressed in English as “personal check”
is a category of “monetary instrument.”The specialization means that a personal check is one kind of monetary instrument. Any associations that apply to mone- tary instruments also apply to personal checks. So we have a general fact type payment employs monetary instrument, and because of the specialization, we know that rules can be written about a payment using (or not using) personal checks. In the same way,credit cardis a specialization ofmonetary instrument, and rules can be written about payments using credit cards.
Note that the association is backed byis between payment network and credit card. Theemploysassociation is at the more general level betweenpay- mentandmonetary instrument, applicable to all monetary instruments, butis backed byonly applies to credit cards, not to other monetary instruments. With the fact types ofFigure 6.13, we can write a rule about credit cards being backed by VISA, but we cannot write a rule about personal checks being backed by VISA.
Fact Type Consistency
Figure 6.13combinesFigures 6.11 and 6.12into a single diagram. This combina- tion is important. The rules that guide an organization should use a single coher- ent set of fact types. Consider what would happen if they did not—if each rule used whatever fact types made sense for that single rule, without reference to the fact types used by other rules. Instead of the previous payment rules, Myko- nos might end up with these payment rules:
payment monetary
instrument employs
payment network is backed by
personal check credit card
FIGURE 6.13 Fact types for bothNo ChecksandVISA Only
160 CHAPTER 6 Business Rule Models
No Checks B:It is prohibited that a payment use a personal check.
Visa Only B:It is permitted that payment utilize a credit card only if the credit card is backed by VISA.
Greenbacks Only:It is obligatory that a cash payment employ US currency.
No Checks Bis more or less the same asNo Checksexcept that the underlying fact type ispayment uses personal checkinstead ofpayment employs per- sonal check. Similarly, Visa Only B is more or less the same as VISA Only except for the use ofutilizeinstead ofemploy.In practice a server could figure out when an event violated one of these rules.
But what if Mykonos now wants to proscribe the use of multiple monetary instruments for small debts? Suppose Mykonos wants to prohibit the use of both credit cards and cash, unless the amount is large enough to warrant the trouble.
A newOne Monetary Instrumentcould be written to ban that activity.
One Monetary Instrument:It is prohibited that a payment employ more than one monetary instrument if the amount of the payment is less than $50.
But doesOne Monetary Instrumentreally do what we want? If a customer is both utilizing a credit card (perVisa Only B) and using a personal check (per No Ohecks B), is she really employing more than one monetary instrument?
We are leaving much to the interpretation of individuals, and their interpreta- tions will vary. It is better to have all rules build off a single coherent set of fact types.
Fact types that are more or less the same—but not quite identical—introduce problems into the business rules that build on them. These problems are a mani- festation of a more general truth about business rules. Every business rule must conform to two different standards: It must be understandable to a business pro- fessional who reads it, and it must be written precisely, with each noun concept and each fact type defined consistently with the other business rules that use the same noun concepts and fact types. Only a business rule that is both understand- able and precisely defined is useful for shaping behavior.
Properties
Consider the fact types that One Monetary Instrument builds on. We have already seenpayment employs monetary instrument in other rules. But the other fact type is new:payment has payment amount. A payment has a pay- ment amount, some quantity of money, perhaps more than $50, perhaps less.
The fact typepayment has payment amountis treated a bit differently from other fact types we have seen.Payment amountis apropertyof a payment. A prop- erty means that one noun concept is dependent on the existence of the other. With- out a payment, there is no payment amount. There is no such dependency between payment and monetary instrument. The VISA card in your wallet exists on its own,
whether or not you use it today to make a payment. But if you don’t make a payment today, there is no payment amount. The existence of a payment amount is entirely dependent on the existence of a payment.
Figure 6.14shows the fact types thatOne Monetary Instrumentbuilds on.
Note that the fact typepayment has payment amountlooks different from the fact type payment employs monetary instrument. The property payment amount is drawn without a rectangle surrounding it. It is drawn that way because it is a property—a property ofpayment. The association betweenpay- mentand payment amountis labeled with “has,” and the fact typepayment has payment amountalso uses the word “has.” “Has” indicates that payment amount is a property of payment. “Has” is reserved just for properties. No non- property fact types use “has.”