Decision Tables

From CaseTalk Wiki
Jump to: navigation, search

Decision Tables

A decision table states a business rule or the derivation of a derivable fact type formally, in the rows-and-columns form of the DMN standard (Decision Model and Notation). It is not a separate model: its columns are roles of the fact types it reads, and its examples are the model's own population. What you state in a decision table is checked against that population, verbalized in reports and SBVR, and exported to DMN.

You find it in the OTFT editor: open a business rule or a derivable fact type (Edit OTFT) and choose the Decision Table tab. The tab is there only for those two kinds of type.

The examples on this page come from the EU-Rent case study.

Two kinds of decision

Decision What it decides Its rows are Its outcome
Business rule (_Rule) whether a fact is allowed the tuples of the fact type the rule judges allowed or forbidden
Derivable fact type the values of the fact type itself the fact type's own tuples the values of its label roles

Business rules

A rule is linked to the fact types it is about. The direction of each link says what the decision does with it (Role editor, Incoming / Outgoing):

  • Outgoing - the fact type the rule judges: its tuples are the examples, one row each. R04 Barred Driver May Not Drive judges Main Driver of Rental.
  • Incoming - a fact type the rule reads: its roles become condition columns. R04 reads Barred Driver.
  • A link without a direction is documentation only.

An example is allowed unless it is marked as a counter-example in the population editor; a counter-example is what the rule must forbid.

A business rule is stated in the positive, as SBVR states it: its rows say when the rule holds - If Licence Expiry Date is at least the Return Date, then R05 holds - and an example that no row covers does not hold. An example no row covers breaks the rule; a counter-example no row covers agrees with it. There is no need for rows that list what is forbidden.

Derivable fact types

A fact type marked derivable gets its values from other facts. Its participants are the fact types it reads: they are joined on the object types they share - two participants that both have a Rental role talk about the same rental - and their other roles are the condition columns. Rental Period Length (Rental R has a rental period of N days) reads Rental Period.

The Decision Table tab lists the columns and where each is read from. The participants themselves are currently set by the AI assistant (MCP tool decision, operation participant); for a transaction, the participants of a connection are edited in the Role editor.

Participants that share more than one type

Two participants are joined on every object type they both play. Sometimes that is too much. R09 One Way Rental Incurs Location Penalty Charge compares the branch where a rental is dropped off with the branch where it was picked up: Drop Off Branch and Pick Up Branch share both Rental and Branch, and joining them on Branch would leave only the rentals returned where they started.

Such a participant is listed apart: it gets a name of its own (a fix, for example pickup), and a listing apart is joined by explicit pairs only. One pair - Pick Up Branch (pickup) and Drop Off Branch on Rental - says the two facts are about the same rental; the branches stay two columns. The AI assistant sets it with the MCP tool decision, operations participant (with fix) and join.

Examples and rules

The tab has two views.

  • Examples - one row per example, read from the population: the inputs, the outcome, and whether it is a counter-example. Two examples with the same inputs and a different outcome are marked as a contradiction.
  • Rules - the generalized rows: one row per rule, a cell per condition column, and the outcome (or, for a business rule, allowed / forbidden). Add rule, Delete, Up and Down edit them; double-click the verdict cell of a business rule to switch between allowed and forbidden (a forbidden row is rarely needed: whatever no row allows is forbidden already).

Generalize proposes a rule from the examples you select: it keeps a value where they agree, makes a range or a list where they differ, and - (any) where every value occurs. Nothing is stored until you accept it.

Every example is checked against the rules:

Result Meaning
agrees exactly one rule fires and says what the example says
disagrees one rule fires and says otherwise - the rule or the example is wrong
no rule fires a gap: no rule covers this example (a derivable fact type; for a business rule this means the rule does not hold)
several rules fire an overlap: the rules are not unique for this example

Cells

A cell is written in the grammar of a value constraint.

Cell Holds when the value
- or empty is anything
domestic is domestic
lap; seat is one of the values
2..17 lies between 2 and 17, bounds included
(0..100) lies between, bounds excluded
18.. / ..2) is at least 18 / is less than 2
not domestic is anything but domestic
< 2, >= 18, <> x compares as written
like K% matches the pattern
empty has no value
>= [Return Date] compares with the value in another column of the same example
[Pick Up Branch] is the same as the value in another column
<> [Pick Up Branch\Branch\Branch Code] differs from the column with that path

In the sentences of a rule a repeated column is named by its path, shortened the way the model names its columns (the column name path setting that GLR uses). A negated list reads as one: not Open; empty is neither Open nor empty.

Comparing with another column states, for example, R05 Driver Holds Valid Licence: the licence expiry date must be at least the return date of the rental. When two columns have the same header, name the column by its path, as the column list shows it - in full ([\Pick Up Branch\Branch\Branch Code]) or by its last steps, as long as only one column ends that way ([Pick Up Branch\Branch\Branch Code]). A path is separated by backslashes; upper and lower case do not matter.

A cell compares; it does not calculate. = Pick Up Date + 90 is refused. A computed value - a duration, an age, a count - is the outcome of a derivable fact type (see below), and the rule reads that fact.

Outcomes and formulas

The outcome cell of a derivable fact type's rule is a value (7.50, infant) or a formula, starting with =. A formula uses the other columns, written in brackets, and the functions on the Formula Functions page, which carry spreadsheet names:

  • = [Return Date] - [Pick Up Date] - the rental period in days (a date counts as its day number)
  • = DATEDIF([Birth Date], [Pick Up Date], "Y") - the age on the pick-up date
  • = IF([Mileage] > 25000, "sell", "keep")
  • = [Car Group\Car Group Code] - a column named by its path, when headers repeat

A rule without conditions applies to every example; it reads Always, Rental Days is Return Date - Pick Up Date.

Computed populations

The population of a derivable fact type is computed, not entered. For every tuple of its first participant on which exactly one rule fires, a tuple is derived: the object roles come from the participant, the label roles from the rule's outcome. A counter-example in the participant gives a counter-example in the derived fact. Deriving again replaces the population.

Because the computed facts are ordinary population, the derived fact type's own constraints judge them. That is how a rule is often best stated: as a derived value with a constraint on it.

Example - R07 Maximum Rental Duration. It is obligatory that the rental period of a rental is at most 90 days.

  1. Rental Period Length: Rental R has a rental period of N days, derivable, reads Rental Period, one rule with outcome = [Return Date] - [Pick Up Date].
  2. A value constraint 0..90 on Rental Days.
  3. The rental from 2026-09-01 until 2026-12-15 derives 105 days, which the value constraint forbids.

The computation is currently started by the AI assistant (MCP tool decision, operation derive).

Counting

A count is a computed value too. R22 One Car On Rental At A Time - a customer has at most one open rental - is the derivable fact type Open Rental of Customer (Customer C has open rental R, read from Renter of Rental and Rental State with the rule Rental Status is Open), with a uniqueness constraint on Customer: a second open rental of the same customer breaks it. R23 is the same for the main driver.

The instances of a derived fact come from the first participant that supplies all of its object roles; the other participants are read for them. A participant marked optional that also supplies them is an alternative source. Where the count is over a single fact type, a frequency constraint says it directly: R03 Maximum Three Additional Drivers is a frequency constraint of at most 3 on the Rental role of Additional Driver.

Aggregates

When several source facts give the same derived instance - the bad experiences of one driver, the services of one car - they form a group, and a formula reads a column over the whole group:

Formula Over the group
= COUNT([Incident Date]) the number of facts
= SUM([Charge Amount]), = AVG(...) the total, the average
= MAX([Service Mileage]), = MIN(...) the largest, the smallest value

R14 Service Interval Of 5000 Miles: Last Service Mileage Of Car is = MAX([Service Mileage]) over the services of a car; Miles Since Service is = [Mileage] - [Last Service Mileage] (and = [Mileage] for a car never serviced, a rule with the cell empty); a value constraint 0..5000 on it finds the car that is overdue. R19 Three Bad Experiences Bar A Driver counts: Bad Experience Count Of Driver is = COUNT([Incident Date]).

An aggregate is checked by computing the population, not against one example: an example binds a single source fact, the value belongs to the group.

Whenever A, then B

Many rules say that one situation requires another: a rental returned late is charged a late return penalty. State both situations as derivable fact types and connect them with a subset constraint:

  1. Late Returned Rental (Rental R was returned late): reads Actual Return and Rental Period, one rule Actual Return Date is > [Return Date].
  2. Late Return Penalty Of Rental (Rental R is charged a late return penalty): reads Rental Charge, one rule Charge Kind is Late Return Penalty.
  3. A subset constraint: every rental returned late is a rental charged a late return penalty (R18).

R09 is the same with Rental Returned Elsewhere and Location Penalty Of Rental; R19 with Driver Due For Barring (three or more bad experiences, read from the count above) and Barred Driver. The AI assistant places the subset constraint with the MCP tool add_constraint (subset, rolenumbers and torolenumbers).

Constraints or a decision table?

The rule says State it as EU-Rent
at most / at least N per instance a frequency constraint R03 at most three additional drivers
never both an exclusion (XOR) R04 a barred driver may not drive
a computed value within bounds a derivable fact type + a value constraint R07 at most 90 days
conditions with an outcome or a verdict a decision table R05 licence valid until the return date; R21 sell at one year or 25,000 miles
whenever this, then that two derivable fact types + a subset constraint R09, R18, R19
a count, a total, a last value a derivable fact type with an aggregate R14, R19

Implemented as

A business rule that is stated by constraints rather than by a decision table shows, in the MIM report and in the SBVR export, Implemented as and the SBVR sentences of those constraints. They are found from the rule's links: the uniqueness, frequency and value constraints of the derivable fact types it is linked to, the frequency constraints of the fact type it judges, and the exclusion and subset constraints between the fact types it is linked to. R14 reads: Implemented as: It is necessary that each Miles Since Service Count must be 0..5000. R22: It is necessary that each Customer is related to at most one Rental (of the open rentals).

All EU-Rent rules

Rule Stated as
R01, R02, R08, R16, R17 the structure of the model: uniqueness and mandatory role constraints, the fact types themselves
R03 a frequency constraint (at most 3)
R04 an exclusion between Barred Driver and driving
R05, R15, R21 decision tables of business rules
R06 Driver Age At Pick Up (DATEDIF) + a value constraint 21..120
R07 Rental Period Length + a value constraint 0..90
R09, R18, R19 derivable fact types + subset constraints
R13 Allocated Car Group of Rental + a rule comparing it with the requested group
R14 aggregates (MAX) + a value constraint 0..5000
R22, R23 derivable fact types (the open rentals) + a uniqueness constraint
R10, R11, R12, R20 not checkable from the population: where a car is driven, and which car groups were available when a rental was requested, are not recorded in the model

Checking the population

Constraints and decision tables are both checked against the population in the well-formedness checks. Population is only checked, never refused.

  • The population must keep to the decision rules lists every confirmed example a rule disagrees with, with the rule as a sentence - example 2 (1004 holds a licence valid until 2026-09-01; 10002 runs from 2026-09-20 until 2026-09-24) breaks R05 Driver Holds Valid Licence.
  • A counter-example must be forbidden lists every counter-example nothing forbids. A counter-example is forbidden by a constraint, by a business rule none of whose rows allows it, or through a derivable fact type that reads it: when the counter-example derived from it is forbidden by that fact type's own constraints. Rental 10006's period of 105 days is forbidden because the Rental Period Length derived from it breaks the value constraint 0..90.

So a rule that is missing shows up as an unforbidden counter-example, and population that breaks a rule shows up as a finding.

The same is shown for one fact in the population editor. Its Details tab lists, under Decisions, every decision the fact takes part in - one that judges it and every one that reads it - with the facts of that example as sentences and what the rules make of it: Agrees with rule 1: ..., No rule decides this example, or, in red, Breaks rule 2: If Licence Expiry Date is less than the Return Date, then R05 Driver Holds Valid Licence does not hold. Nothing is refused: the population is only checked.

Reports and export

  • MIM report and Show annotation (diagrams): the rules of a decision as a table, formulas as mathematics.
  • SBVR: a derivable fact type's rules as derivation rules, a business rule as one operative rule in the positive: It is obligatory that Licence Expiry Date is at least the Return Date. A rule with several rows lists them, one alternative per line, under It is obligatory that at least one of the following is true:, so the and inside a row never mixes with the or between rows. A business rule stated without a table - by a constraint or a derivable fact type - is listed with what implements it (see below).
  • DMN: Export DMN... on the Decision Table tab exports this decision; File > Export > DMN Decision Tables... exports all of them. The examples go along as DMN test cases. DMN 1.3 (read by Camunda and bpmn.io) is the default, 1.5 is available. Cells and formulas are written in FEEL, see Formula Functions. A decision whose examples contradict each other is left out and named in the report.

See also