如何将零列标准化?

发布于 2025-02-07 19:44:48 字数 2325 浏览 0 评论 0原文

我有

{
  totalPrice : 20,
  totalCost : 15,
  invoice:{ [ { price : 10, name : "microphone" }, { price : 10, name : "speaker" } ] },
  order:  { [ { price : 10, description : "microphone" }, { price : 10, description :"speaker" } ] } 
}

要创建规则并存储在数据库

  • 规则1 TotalPrice>的 对象。 10
  • 规则2 TotalPrice>总计
  • 规则3发票。 order.price where invoice.name = order.description

the初始数据作为表是

ruledworkflieffieldId1运算valieffieldiD workflieffieldId2匹配
1f110nullnull
2f1多于null null 2 f1远比nullf2null
3f3远小于null f4f4f4 f4,

所以我创建了我创建

可行table

ruledworkflieffieldID1操作员workflieffieldId2
1f1超过10个null
2f1,nullf2
3f3多于nullf4

matchconditiontable ruleid

ruleidkey1 key1key2 key2 key2
3 f3f3 f3 f3f3 f4

时,应查询时,它应该查询该对象的所有规则

问题是有某些情况下存在字段(value,workflieffieldid2),在某些情况下可能为无效 可以分成2个表可以吗? 例如

constantrule

ruleidworkfliffieldID1操作员
1f110

fieldrule

rule> ruledorflifeffieldId1运算符workFliefFieldIDID2
1f1远小于f2
2f3远小于f4

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

RuleIdWorkFlowFieldId1OperatorValueWorkFlowFieldId2Matching
1F1More Than10NULLNULL
2F1More ThanNULLF2NULL
3F3More ThanNULLF4F5,F6

so I create

RuleTable

RuleIdWorkFlowFieldId1OperatorValueWorkFlowFieldId2
1F1More Than10NULL
2F1More ThanNULLF2
3F3More ThanNULLF4

MatchConditionTable

RuleIdKey1Key2
3F3F4

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

RuleIdWorkFlowFieldId1OperatorValue
1F1More Than10

FieldRule

RuleIdWorkFlowFieldId1OperatorWorkFlowFieldId2
1F1More ThanF2
2F3More ThanF4

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文