You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Avoid SQL-Like Joint Entities in Document Oriented MongoDB
Summary
Our current MongoDB data model includes SQL-like joint entities, such as the UserRole entity. This approach can lead to complex queries, reduced performance, and suboptimal data modeling. To fully leverage MongoDB's document-oriented model, we may consider refactor our data model to use embedding and referencing instead now and in the future.
Steps to Reproduce
Inspect the current data model in MongoDB.
Identify the use of joint entities like UserRole.
Observe the complexity and performance of queries involving these joint entities.
Issue Name (title)
Avoid SQL-Like Joint Entities in Document Oriented MongoDB
Summary
Our current MongoDB data model includes SQL-like joint entities, such as the UserRole entity. This approach can lead to complex queries, reduced performance, and suboptimal data modeling. To fully leverage MongoDB's document-oriented model, we may consider refactor our data model to use embedding and referencing instead now and in the future.
Steps to Reproduce
Current Behaviour
User document:
Role Document:
RoleUser:
Using joint entities leads to:
Complex queries that mimic SQL joins.
Reduced performance due to the need for multiple queries to retrieve related data.
Expected Behaviour
Details
Embedding
For one-to-many relationships, consider embedding related documents.
Example: Embedding Roles within User Document
Referencing
For many-to-many relationships or when the related data is large, an approach based on references is more appropriate.
Example: Referencing Roles in User Document
User Document:
Action Items:
Benefits:
The text was updated successfully, but these errors were encountered: