Refactor two one-to-one and one-to-many relationships in a single table
The option I considered initially was a good start, just needed further improving. The schema of the solution is below.



The solution consists of two parts actually:


Add unique constraint on SubAccountId
Introduce table for SubAccount children hierarchy mapping, both columns have foreign key to Id of the SubAccount table.


Children nested hierarchy is restored at software layer, the adjacency list hierarchy was not really needed.