Question: Can I place all this data needed onto one document (my concern is the 16MB cap) or should I have several documents, eg.
Document 1: Personal details,
Document 2: Contact details,
Document 3: Emergency Contact Numbers,
Document 4: Spouse or Next of Kin, and
Document 5: Postal & Physical Address.
Hello @Kyle_Oliver, welcome to the MongoDB Community forum!
You are likely to insert the entire data into one document in a collection called as “employee”. This is all related information to an individual in an organization. And, you are can store and lookup (query) the individual’s details from a single document.
The document size is not going to be large (a few kilo bytes at the most) for each employee. An important aspect would be how you are going to organize and group the data within the document - using various field types like array, sub-document, string, number, etc. This mostly depends upon the way you are going to query and how the data might grow (for example, to accommodate more than one phone number use an array field).
In general, you can consider storing the - Personal details, Contact details, Emergency Contact Numbers, Spouse or Next of Kin, and Postal & Physical Address - as sub-documents or array fields as needed (within the document).
An example:
{
id: 1234,
employeeName: "John Doe",
emloyeeGender: "male",
addresses: [
{ type: "postal", address: "123 West St.", city: "New York" },
{ type: "physical", address: "123 West St.", city: "New York" }
],
spouseOrKin: {
contactPerson: "Jane Doe",
mobileNumber: ""123-456-7890",
// ... other details
},
// ...
}