Say I have these tables which define hierarchy
Org
- id
- name
SubOrg
- id
- org_id
- name
Now there is another table which refers both such that:
Rules
- id
- org_id
- sub_org_id (nullable)
- …
The way Rules table works is if sub_org_id is null, the rule applies to whole org. if sub_ord_id is not null, that rule overrides for that particular sub_org.
How do I map this into sqlalchemy relationship?
Thanks