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.
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.
Generally speaking, your category table should have one row per category, not per fact table row.
It's OK if multiple EReport rows refer to the same category record, but having a category record per EReport record defeats the purpose of normalizing in the first place.
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.
This would only be a circular reference if, for example,
tenant
had auser_id
reference that pointed back down to theuser
table, which references back up to thetenant
.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.