I have object
{
totalPrice : 20,
totalCost : 15,
invoice:{ [ { price : 10, name : "microphone" }, { price : 10, name : "speaker" } ] },
order: { [ { price : 10, description : "microphone" }, { price : 10, description :"speaker" } ] }
}
I want to create rules and store in database
- rule1 totalPrice > 10
- rule2 totalPrice > totalCost
- rule3 invoice.price > order.price where invoice.name = order.description
the initial data as table will be
RuleId | WorkFlowFieldId1 | Operator | Value | WorkFlowFieldId2 | Matching |
---|---|---|---|---|---|
1 | F1 | More Than | 10 | NULL | NULL |
2 | F1 | More Than | NULL | F2 | NULL |
3 | F3 | More Than | NULL | F4 | F5,F6 |
so I create
RuleTable
RuleId | WorkFlowFieldId1 | Operator | Value | WorkFlowFieldId2 |
---|---|---|---|---|
1 | F1 | More Than | 10 | NULL |
2 | F1 | More Than | NULL | F2 |
3 | F3 | More Than | NULL | F4 |
MatchConditionTable
RuleId | Key1 | Key2 |
---|---|---|
3 | F3 | F4 |
when query it should query all rules for the object
The question is there are fields (Value,WorkFlowFieldId2) that can be NULL for some cases Is it okay to separate into 2 tables? like
ConstantRule
RuleId | WorkFlowFieldId1 | Operator | Value |
---|---|---|---|
1 | F1 | More Than | 10 |
FieldRule
RuleId | WorkFlowFieldId1 | Operator | WorkFlowFieldId2 |
---|---|---|---|
1 | F1 | More Than | F2 |
2 | F3 | More Than | F4 |