I understand that JOINs are impossible or incredulous in documents. I come from a relational database and try to figure out how to handle such scenarios.
Let's say I have a team of employees where I store all the information related to the employee. The following is a typical employee document:
{ "id": 1234, "firstName": "John", "lastName": "Smith", "gender": "Male", "dateOfBirth": "3/21/1967", "emailAddresses":[ { "email": " johnsmith@mydomain.com ", "isPrimary": "true" }, { "email": " jsmith@someotherdomain.com ", "isPrimary": "false" } ] }
Suppose also that I have a separate collection of projects that stores project data that looks something like this:
{ "id": 444, "projectName": "My Construction Project", "projectType": "Construction", "projectTeam":[ { "_id": 2345, "position": "Engineer" }, { "_id": 1234, "position": "Project Manager" } ] }
If I want to return a list of all my projects along with project teams, how can I handle so that I return all the relevant information about the people in the team, that is, names, email addresses, etc.?
Are these two separate requests? One for projects, and another for people whose identifier appears in the project collection?
If so, how do I insert data about people, that is, full names, email addresses? Then I do a foreach loop in my application to update the data?
If I rely on my application to process all the relevant data, is this not a performance measure that would offset the performance benefits of document databases such as MongoDB?
Thank you for your help.