0

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
Zhorov
  • 28,486
  • 6
  • 27
  • 52
Weanich Sanchol
  • 144
  • 1
  • 12
  • 1
    What does "Is it okay" mean? According to what? What does your title have to do with that? What exactly is your question? PS Reorganizing designs for subtypes/inheritance/polymorphism has nothing to do with DB normalization. (Why would it?) PS [ask] [Help] [How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/q/261592/3404097) Please use standard punctuation & spelling. PS There is a table format bug in the post editor where if you don't put a blank line before a table it looks OK in the preview even though it looks wrong when published. – philipxy Jun 16 '22 at 06:39
  • 2
    I have no clue what your question is, can you explain in other words maybe ? – GuidoG Jun 16 '22 at 06:46

0 Answers0