In general, this is a bad idea if your circuit cannot be sorted topologically, i.e. if you cannot establish the order in which the table refers only to the tables preceding it in the ordering. Such a "multi-level" dependency is also a very nice feature, for example, for software modules (you have a problem if two modules depend on each other).
In your case, you have a user who refers to an account and an account that contacts the user so clearly that there is no way to find a topological ordering.
One standard solution in this case is to introduce a separate table, for example. "role" where you have three columns: user, account and role. The role of the column can be "owner" or "guest".
The fact that you know that (subject to current requests) an account must have one and only one owner or that a user must be specified in one and only one account are not IMO rules that really apply to the users domain "and" accounts ".
You can easily implement these rules, but structuring your data so that you do not have another opportunity is an IMO error. You should strive to model the domain, not specific rules ... because people will change their mind about what the rules are.
Can you conceive a user with two accounts? Can you conceive an account with multiple owners / admins? I can ... and that means that most likely it will be a request soon. Structuring the data so that you cannot represent it is looking for problems.
Also, when you have circular dependencies in the model, your queries will be more difficult to write.
A very common case is, for example, an attempt to present a database of a list of hierarchical parts using only one table with a "parent" field that points to the table itself ... it is much better to have two tables instead, a part and a component where the component has two references per piece and quantity.
source share