Recommended Way to Store Logical Expressions Say, I have the following SQL table:
| ID | GameId   | PlanId | MinAgeLimit | Amount |
|:--------------|--------|-------------|-------:|
| 1  | Cricket  |   P1   |   10        |   500  |
| 2  | Cricket  |   P2   |   15        |  1000  |
| 3  | Football |   P1   |   10        |   750  |
| 4  | Football |   P2   |   20        |  1000  |
| 5  | Football |   P3   |   22        |  2000  |
| 6  | Chess    |   P2   |   20        |   800  |

Now, I can have some logical expressions for different 'ReferrerId', like:

If Referrer=ABC, then do not display items where PlanId=P2.
If Referrer=PQR, display only items where GameId=Cricket.
If Referrer=XYZ, display items where (GameID=Cricket OR GameID=Chess) AND MinAgeLimit&gt;10 AND AMOUNT&gt;500

What is the recommended approach to store these custom rules?
PS: I do not want to hard code these rules in my Java program, as I have plans to further provide an interface where the Referrer can update these rules through a self-service portal.
This could be implemented as a set of tables. There will be one column for each logical operator against each source column. As this can lead to a great many combinations I'd suggest deploying only the columns needed at the time. The design allows for new columns to be included later.

The decision table:

Referrer
PlanIdNotEqual
GameIdIn              -- this is just a flag to say whether this condition applies to this referrer
MinAgeLimitGreaterThan
AmountGreaterThan
...
further columns to meet additional conditions


Since there are multiple GameId values for one Referr's conditions it gets a separate table:

DecisionGameIdIn
    Referrer
    GameId


The query then becomes (in pseudo-SQL)

select
  &lt;columns&gt;
from Game
inner join Decision
on  (Decision.PlanIdNotEqual is NULL 
     or Decision.PlanIdNotEqual &lt;&gt; Game.PlanId)
and (Decision.GameIdIn is NULL 
     or Game.GameId in (select GameId from DecisionGameIdIn where Referrer = &lt;current value&gt;))
and (Decision.MinAgeLimitGreaterThan is NULL 
     or Game.MinAgeLimit &gt; Decision.MinAgeLimitGreaterThan)
and (Decision.AmountGreaterThan is NULL 
     or Game.Amount &gt; Decision.AmountGreaterThan)
... continue for further conditions
where Decision.Referrer = &lt;the current value&gt;


This can rapidly become out-of-control. Keeping Decision's columns aligned with the query logic is one problem. The combinatorial explosion is another. The plethora of Boolean conditions can overwhelm any indexing strategy resulting in table scans.