Thank you Marcio and Vinod. I appreciate both of your suggestions.
To clarify, a sub-organization can only belong to one parent organization - a simple tree:
- Acme Inc. [no parent]
- Sales Division [parent Id points to Acme]
- Manufacturing Division [parent Id points to Acme]
- Design Team [parent Id points to Manufacturing Division]
- XYZ Corp. [no parent]
- Marketing Division [parent Id points to XYZ]
- Web Team [parent Id points to Marketing Division]
- Accounting Division [parent Id points to XYZ]
Other entities (to be developed) would have an OrganizationId attribute and should be able to point to any organization in the tree, e.g. Acme or any one of its divisions/subdivisions.
A variation of Marcio's structure could work. I would use an Organization entity and an OrganizationOrganization entity connecting two Organizations, one as parent and one as sub. The issue with this is I'll need to put in several protections to guard against a user creating an illogical tree (an org pointing to itself, an org pointing to a sub of itself, or an org having more than one parent).
The structure Vinod shows is what I've got. Just not sure why the "View or Edit Data" function is requiring a value for ParentOrganizationId even though it is set as not mandatory. I set Delete Rule to Ignore as Vinod suggests and that gets me past this blocker, but of course this will allow referential integrity to be broken unless I protect from this manually in my update & delete actions (which is fine).
Seems to be a bug in the "View or Edit Data" function that Delete Rule = Protect is overriding IsMandatory = No. Delete Rule ought to only specify what should happen when attempting to delete an entity with foreign key references. SQL databases do allow a foreign key to be specified as null, while also allowing the delete rule to be "don't allow", "allow", "set to null", "cascade deletes". Not sure why "View or Edit Data" function is overriding this.
Thanks,
John