Reputation: 592
I need guidance in how to properly set up a MongoDB collections/documents structure given the following relational database model:
Cases
Attorneys
CaseAttorneys (which Attorneys are assigned to this case)
TimeEntries
Attorney 0 and Attorney 1 are assigned to Case 0 in CaseAttorneys. Attorney 0 and Attorney 1 each bill an item on Case 0 in TimeEntries.
Sample TimeEntries Data
1st Record
2nd record
What is the best way to set up the structure for collections/documents/subdocuments in MongoDB in order to use simple, built-in queries to get, for example:
What collections would you make? What do the documents for each collection look like?
Upvotes: 0
Views: 133
Reputation: 5051
I would start by setting up the DB in the same way that the RDB was set up, and use Document References to map out your relationships. Document references can easily be populated (similar to a join) when you perform your query.
The above guide helps you to think through how to organize your references. Consider where it says "the growth of the relationships determine where to store the reference". In most cases, you would probably want to follow the last example on the page.
Upvotes: 1