Decision Tables

A decision table is another method of describing the logical flow of data that must take place to solve a problem. The decision table clearly presents all of the possible combinations of conditions so the programmer can be sure that no possibility has been overlooked in their logical analysis. The actions to be taken under each set of conditions are clearly laid out for the programmer to follow. A decision table can serve as a good development tool, a good documentation tool and a good visual explanation.

Elements of a decision table:

A condition table is divided into quadrants with double lines traditional separating the quadrants. (Note the table is in the middle - the information about stub and entries is there because it worked!)

                                                               -------------------Rules------------------

Condition

Stub

 

 

Action

Stub

Table Header

1

2

3

4

5

6

7

8

Condition

Entries

 

 

Action

Entries

1

 

 

 

 

 

 

 

 

 

2

 

 

 

 

 

 

 

 

 

3

 

 

 

 

 

 

 

 

 

1

 

 

 

 

 

 

 

 

 

2

 

 

 

 

 

 

 

 

 

3

 

 

 

 

 

 

 

 

 

4

 

 

 

 

 

 

 

 

 

Structuring the decision table:

The number of conditions determines the number of rules that are required to provide an analysis of all the possible combination of conditions. For example, if you have two conditions then there would be 4 rules:

As you can see 4 rules provides a rule for all of the possible combinations.

Frequently a business problem arises because all possibilities have not been analyzed and worked into the system. Frequently a program will develop problems because a certain combination of conditions occurs that was not provided for in the program logic/code. A decision table can help make sure that this situation does not arise. A properly done decision table will cover all situations by showing all possible combinations/sets of conditions.

As shown in the example above, each condition can be YES or NO (Y or N); therefore, we have a two state condition. A condition having 2 states produces 2 possibilities. Therefore, we need 2 rules. If there are 2 conditions, we have 2 times 2 possibilities so we need 4 rules. Three conditions produce 2 x 2 x 2 possibilities or eight rules. The logic here is that given a two state condition (Yes or No), where N represents the number of conditions, 2N will equal the number of possible combinations or the number of rules.

A rule map illustrating all the possible combinations would look like this. Note: This rule map is for 3 conditions. Each condition is represented in a row.

Starting at the bottom entry point of each rule path and reading up along the lines to the top of the map, we will follow each possible set of Y/N rules. Also starting at the top entry points and reading down along the lines we will encounter each set of possible rules.

Rule 1 will appear on the decision table as: Y, Y, Y

Rule 2 will appear on the decision table as: Y, Y, N

Rule 3 will appear on the decision table as: Y, N, Y

Rule 4 will appear on the decision table as: Y, N, N

Rule 5 will appear on the decision table as: N, Y, Y

Rule 6 will appear on the decision table as: N, Y, N

Rule 7 will appear on the decision table as: N, N, Y

Rule 8 will appear on the decision table as: N, N, N

Rule1

Rule2

Rule3

Rule4

Rule5

Rule6

Rule7

Rule8

Y

Y

Y

Y

N

N

N

N

Y

Y

N

N

Y

Y

N

N

Y

N

Y

N

Y

N

Y

N

Reading from left to right, beginning with the bottom row, the condition entries alternate with one Y followed by one N etc. The next row up shows two Y's followed by two N's in an alternating pattern. Finally, the top row has four Y's followed by four N's. If this was not the top row, you would see the same alternating pattern. But, because in the example there are only three levels, you see one repetition. Regardless of the size of the table, we may fill in the condition entries automatically following this pattern. Beginning with the bottom row and making entries from left to right, we give single repeats. Moving up, we double the number of successive Y's and N's in each higher row until the table is complete. This methodology will assure us that each possible combination has been used and that there has been no duplication.

Example: If the code is A and the on hand > 500, no order is needed. If the code is A and the on hand is not greater than 500, an order is needed. If the code is not A then we need to check with sales before ordering.

 

Inventory

1

2

3

4

1

Code = A

Y

Y

N

N

2

On hand > 500

Y

N

Y

N

1

No order needed

X

 

 

 

2

Order product

 

X

 

 

3

Check with sales

 

 

X

X

This example had two conditions, therefore there were four rules. There were three possible actions. Each action has an X entry when the rule indicates that action should be taken. The next topic is consolidation and we will come back to this table because it is a candidate for consolidation.

Consolidating decision table rules:

Lots of times, we find that a given condition doesn't matter in come circumstances. For example, in the inventory problem above if the Code isn't A then the number on hand does not matter, it will be referred to sales.

Two rules are considered equivalent if they have the same condition entries with the exception of the last condition and they produce the same action entries. Looking at the example above, rule 3 and rule 4 meet this criteria. The first condition entry is the same, the second is different, but the actions are the same.

 

 

Inventory

1

2

3-4

1

Code = A

Y

Y

N

2

On hand > 500

Y

N

0

1

No order needed

X

 

 

2

Order product

 

X

 

3

Check with sales

 

 

X

In the example above, we can consolidate rule 3 and 4 because the answer to Code = A is the same, the answer to on hand > 500 was different but the action was the same. That means that it doesn't matter what the on test reveals, the action will still be the same. We can than consolidate and enter a 0 for null or in fact leave the cell empty. When I consolidate, I see value in keeping the rule numbers that were consolidated know. Others will renumber the rules and you would simply see 1, 2, 3.

Sometimes you can get more than one level of condensing. For example:

Rule9

Rule10

Rule 11

Rule 12

 

 

=

9-10

11-12

 

 

=

9-12

N

N

N

N

N

N

N

Y

Y

Y

Y

Y

Y

Y

Y

Y

N

N

Y

Y

0

Y

N

Y

N

0

0

0

X

X

X

X

X

X

X

What this is saying is that in all four rules show, the pattern is N Y followed by either Y or N. Since the results are the same, clearly the only two things that matter are the initial NY. The others can be anything and the results will be the same. Therefore we can consolidate into one rule that covers all of the possibilities.