Single table desing
Base Object Commom Properties
{
type: "RULE_SET" | "ENTITY_ID_RULE_SET_RELATIONS"
}
Rule Set Spefic Propertiers
... Rule set props
Entity ID Rule Set Relations
Primary Key or Wathever indexed propertier is entity id
"type": "ENTITY_ID_RULE_SET_RELATIONS"
"entity_id": ["rule_set_id_1", "rule_set_id_2", ...]
- Read item with entity ID passed as argument and type equals "ENTITY_ID_RULE_SET_RELATION"
- Batch read items by
rule_sets_ids
of item retrieved on step 1.
[
{
"type": "RULE_SET",
"id": 1,
"allocations": [
{
"entity_id": 123,
"other_field": "bla bla"
}
]
//... other rule set props
},
{
"type": "RULE_SET",
"id": 2,
//... other rule set props
"allocations": [
{
"entity_id": 123,
"other_field": "bla bla"
},
{
"entity_id": 321,
"other_field": "bla bla2"
}
]
},
{
"type": "ENTITY_ID_RULE_SET_RELATIONS",
"id": 123,
"rule_sets_ids": [1, 2]
},
{
"type": "ENTITY_ID_RULE_SET_RELATIONS",
"id": 321,
"rule_sets_ids": [2]
},
]