The data model for this project may seem overly complicated or obscure. The reason behind this is because Boolean statements like “A or B or (C and D)” have a certain nesting level that requires some level of precedence as these statements are evaluated.
Nesting Levels
In that last statement, A and B are at the top level inside which, is nested another statement, “C or D”.
Similarly, the actions taken when the criteria statement evaluates to true must be grouped. Thus, you get a many-to-many relationship between criteria and actions. But, each criteria can be made up of several conditions and the same with actions. So, you get a many-to-many-to-many-to-many relationship.
Overview
That’s an abstraction, but it felt right for the data model, and so I ended up with what’s shown below.
For modeling the nesting levels I used an adjacency list model. It is illustrated in the right two columns here:
Let’s label subgroup 1: B, 2: C and so on. (The empty subgroup 0 is there only to keep the adjacency list from being broken, as we need a root, and you will see, there is no root condition in the expression below.)
(B sub 1 AND B sub 2) OR (C sub 1 AND C sub 2 AND (D sub 1 OR D sub 2)) OR (E))
In this expression the root subgroup just ORs the other subgroups together.
Enough on that for now. We’ll do a ground up review of the model in Part III, as the JS UI library is dependent on two more tables, which the two lowest tables link to.
Leave a Reply