Assume that you have a hierarchy of organizational units:
- Company -- Branches --- Departments ---- Teams
Lets say I have some settings (for simplicity assume that they have the same properties) for each level of hierarchy:
- Max nr of documents
- Min something else
- Can do X
- Can do Y
- many other properties
So, the sub-units can reuse as default the parents settings, or they have only one or two of these settings modified. Same for their sub-units.
What would be the proper pattern to follow - both as code structures, as well as db storage to support that, with the idea that each unit's settings can be modified independently, and sub-unit's settings override the default of the parent.
We were thinking about key/value pairs, and then lookup for each one going up the hierarchy until we find the right setting, but this can become ugly pretty fast.
Another option we were considering is that each unit has it's own record of the settings, and update accordingly when parent's settings changed.
I'd appreciate any suggestion of well known approaches/patterns in that regard.