◷ Reading Time: 6 minutes

There are several ways to model a Decision Table. No matter what method is used, the end result will be a *IIterable<ITable>*. This can be used to execute the table.

For the purposes of this article, we picked a simple airline policy. We will model this in different ways.

### Airline Passenger Discount Policy

An airline offers only flights to India and Asia. Under special conditions, a discount is offered on the normal airfare:

- Passengers older than 18 with destinations in India are offered a discount of 20%, as long as the departure is not on a Monday or Friday.
- For destinations outside of India, passengers are offered a discount of 25%, if the departure is not on a Monday or Friday.
- Passengers who stay at least 6 days at their destination receive an additional discount of 10%.
- Passengers older than 2 but younger than 18 years are offered a discount of 40% for all destinations.
- Children 2 and under travel for free.

### Extracting Rules

If all the conditions and actions from the scenario are extracted, you can summarize it as follows:

Conditions:

- Destination (India, Asia)
- Passenger Age (<= 2, > 2 && < 18, > 18
- Depart on Monday or Friday (Yes, No)
- Stay 6 days or more (Yes, No)

Actions:

- Travel Free
- 0% discount
- 10% discount
- 20% discount
- 40% discount

Number of rules: 2 values * 3 values * 2 values * 2 values = 24 rules

Now we dump the result in a simple table to visualize a combination of all these conditions.

#### Scenarios

For rules 1 to 4, and 13 to 16, you’ve got an interesting set of actions: some of these columns state a 10% discount for staying 6+ days, but all of these columns also state that these passengers travel for free. Since a passenger traveling for free can’t receive an additional discount, we can combine all 8 rules into rule #1, as shown below.

You can reduce rules 10 and 22 (passengers over 18 departing on a Monday/Friday who are staying less than 6 days, regardless of destination, get no discount at all) although this may be hard to see until after you reduce the table at least once.

We can also reduce rules 5/7 (passengers traveling to India, between 3 and 18 years of age, staying 6+ days (it doesn’t matter what day they leave) and 6/8 (same as previous, except staying less than 6 days).

You can reduce rules 10 and 22 (passengers over 18 departing on a Monday/Friday who are staying six days or more, regardless of destination, get no discount at all), although this may be hard to see until after you reduce the table at least once.

Similarly, you can reduce rules 9 and 21 (passengers over 18 departing on a Monday/Friday who are staying less than six days, regardless of destination, get a 10% discount).

#### Reduced Table

*(Reference: http://www-acad.sheridanc.on.ca/~jollymor/info16029/week4.html)*

### Preparing Decision Table

Now we can define the aging groups as shown in the following definition:

- Group1 : <=2
- Group2 : 3-18
- Group3 : >18

It is simpler when we prepare a model to help make a decision. It would encapsulate all conditions:

- Destination: The destination of travel
- AgeGroup: The aging group as defined
- IsWeekDay: The condition for “Depart Mon/Fri?”
- StaryMoreThan6: The condition for “Stay >= 6 Days?”

And last, we change the table into a vertical table in which conditions/actions sit in columns. We can then have Decision Table like this:

Destination | Age | IsWeekDay | MoreThan6 | Discount | |
---|---|---|---|---|---|

Rule 1 | Group1 | 100 | |||

Rule 2 | India | Group2 | Y | 40 | |

Rule 3 | India | Group2 | N | 50 | |

Rule 4 | Group3 | Y | N | 0 | |

Rule 5 | Group3 | Y | Y | 10 | |

Rule 6 | India | Group3 | N | Y | 30 |

Rule 7 | India | Group3 | N | N | 20 |

Rule 8 | Asia | Group2 | Y | Y | 50 |

Rule 9 | Asia | Group2 | Y | N | 40 |

Rule 10 | Asia | Group2 | N | Y | 75 |

Rule 11 | Asia | Group2 | N | N | 65 |

Rule 12 | Asia | Group3 | N | Y | 35 |

Rule 13 | Asia | Group3 | N | N | 25 |

We do not need the Rule name (the first column)

The final table looks like this:

Destination | Age | IsWeekDay | MoreThan6 | Discount |

Group1 | 100 | |||

India | Group2 | Y | 40 | |

India | Group2 | N | 50 | |

Group3 | Y | N | 0 | |

Group3 | Y | Y | 10 | |

India | Group3 | N | Y | 30 |

India | Group3 | N | N | 20 |

Asia | Group2 | Y | Y | 50 |

Asia | Group2 | Y | N | 40 |

Asia | Group2 | N | Y | 75 |

Asia | Group2 | N | N | 65 |

Asia | Group3 | N | Y | 35 |

Asia | Group3 | N | N | 25 |

This table is now the source for modeling. In fact, **this exact table** can be executed by your application with a few more additional rows.

### What’s next?

- Introduction to decision tables
**Preparing a decision table**- Modeling decision table
- Decision Model and Notation – decision table
- Check overlaps
- Decision Table final logic
- Multilingual decision table
- Decision Table 101