wiredfordesign
wiredfordesign

Reputation: 211

Efficient MongoDB database design

I'm fairly new to both Meteor and MongoDB. I'm building a basic medical application that helps to run a small clinic. So one of its functionalities is to display a patient's info.

I'm not sure how to best structure the database and I feel as though what I have is inefficient.

first_name: 'Andrew',
middle_name: 'Baines',
surname: 'Bernard',
sex: 'Male',
age: '40',
dateAdded: new Date(),

contacts: {
  // mobile no, email etc
},

work: {
// company, position etc
},

insurance: {
  // insurance details
},

next_of_kin: {
// name, phone no, etc
},

medical_history: {
    significant_illnesses: [
        // illnesses
    ],
    significant_surgeries: [
        // surgeries    
    ],
    allergies: [
        // allergies
    ],
    current_medication: [
        // medication
    ]
}

What's the most efficient way to structure this data? Should they all be in the same collection?

Upvotes: 0

Views: 72

Answers (1)

Andriy Simonov
Andriy Simonov

Reputation: 1288

It seems that embedding suits well here because patients have one-to-one relationship with their profile data and a medical history, so embedding won't introduce any duplication. In general, the main idea of embedding is that you can in one request access the information that your application usually processes. As long as all information that you have put to the document is required each time you get a patient the schema is OK otherwise you may consider putting it in separate collections.

Upvotes: 1

Related Questions