如何将零列标准化?
我有
{
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初始数据作为表是
ruled | workflieffieldId1 | 运算 | 符 | valieffieldiD workflieffieldId2 | 匹配 |
---|---|---|---|---|---|
1 | f1 | 比 | 10 | null | null |
2 | f1多于null null 2 f1 | 远比 | null | f2 | null |
3 | f3 | 远小于 | null f4 | f4 | f4 f4, |
所以我创建了我创建
可行table
ruled | workflieffieldID1 | 操作员 | 值 | workflieffieldId2 |
---|---|---|---|---|
1 | f1 | 超过 | 10个 | null |
2 | f1, | 比 | null | f2 |
3 | f3 | 多于 | null | f4 |
matchconditiontable ruleid
ruleid | key1 key1 | key2 key2 key2 |
---|---|---|
3 f3 | f3 f3 f3 | f3 f4 |
时,应查询时,它应该查询该对象的所有规则
问题是有某些情况下存在字段(value,workflieffieldid2),在某些情况下可能为无效 可以分成2个表可以吗? 例如
constantrule
ruleid | workfliffieldID1 | 操作员 | 值 |
---|---|---|---|
1 | f1 | 比 | 10 |
fieldrule
rule> rule | dorflifeffieldId1 | 运算 | 符workFliefFieldIDID2 |
---|---|---|---|
1 | f1 | 远小于 | f2 |
2 | f3 | 远小于 | 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
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 |
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论