2 / 4
Jun 2024

I am new to MongoDB and would like to understand best practises in modling for the scenario below
I have a RDMS table called Reasons
This has a Reason ID , Reason type, Reason Name ameand a few audit fields (last upd user, last updt dt etc)
Each reason type has multiple reason names
Current size of this able is very small - about 200 records
ex:
reasontype_1 → 50 reasons(reason names)
reasontype_2 → 50 reasons(reason names)

Given the above is it better to have
a. one Reasons collection or
b. better to have different collections for each reason type

Given that we have to create CRUD operations to manage the above and also this collection is going to be replicated in myltiple data centers

The read queries on this are going to be
a. Get all reasons
b. Get reasons for a specified reason type

wha t is the recommended approach? what are the pros and cons of each

Appreciate your guidance

Thanks

Hello, @SURAJ_BELVADI NY State of Health site

Given a Reasons table with various reason types, it’s better to use one Reasons collection for the following reasons:

Pros:
Simpler queries and management
Easier to add new reason types
Better indexing and replication
Unified CRUD operations

Cons:
Potential performance impact if the collection grows
Queries need to filter by reason_type
Multiple Collections:

Pros:
Clear separation of data
Potential performance gain for very large datasets

Cons:
Increased complexity in management and CRUD operations
Redundant operations for each collection
Scalability and replication issues

Recommendation:
Use one Reasons collection. This approach simplifies management and is sufficient given the small dataset size.

I hope this suggestion will be helpful for you
Best regards
chris wright