One can expand on this by adding a join table between Organization and Users, this allows Users to be in more than one Organization, have more than one role in an Organization, and allows multiple roles, and can enforce having only one "primary" per organization. OrganizationUsers would have user_id, organization_id, and role. Add a unique index on user_id, organization_id, and the primary role to enforce one primary User per Org. Add a unique index on organization_id, user_id, and role to avoid duplication.
↧