Circular reference and multi-tenancy

database-designmulti-tenant

I'm have an issue with circular reference in my DB design. As see the ER diagram below have 2 circular reference that I highlighted with Red and Orange arrow.

enter image description here

Anyone know how to resolve this issue?

Best Answer

You do not have circular references. All those arrows point in the same direction, "up" to the tenant.

You can insert data to populate the tables without having a dependency on data not yet inserted.

  • Tenant
  • Group
  • Task
  • App
  • Group App
  • User
  • Group User

This would only be a circular reference if, for example, tenant had a user_id reference that pointed back down to the user table, which references back up to the tenant.

The arrows in your diagram have multiple paths back up to the "top" of the hierarchy (tenant, which is drawn to the bottom left). There is a clear tail and head of every path.

But the arrows don't create a circular cycle. In a circular reference, there is no clear head or tail in the path of the arrows.

So great job on your schema design! You did better than you thought.