Here is the information about my development environment:

-Mongodb 3.0.0

-Microsoft Visual Studio Professional 2013

-.NET Framework 4.5

We are trying to design some MongoDB collections at work that are associated with each in a complex way.

Speed performance is very important because we will deal with millions of records.

In any case, here is a business requirement.

Let's say I have health care policies that vary across provincial states in the United States.

Along, with concern such as provincial states in the US, I may need to consider certain exceptional cases such as whether the person is a senior citizen, sex, health history, chronic illnesses, etc.

The Exceptional cases really vary in their values.

Let's say we have a Person Model.


_id: ObjectId

FirstName: String

LastName: String

ProvincialStateOfResidenceID: String

ExceptionCasesDocRefs: Array[ ExceptionCasesID ]

The ProvincialStateOfResidence field will always have a value.

The ExceptionCasesDocRefs array could be empty Or It could contain multiple IDs

Let's have a HealthPolicy Model that will always have a value for ProvincialStateOfResidenceID field.


ProvincialStateOfResidenceID: String

ExceptionCasesDocRefs: Array[ ExceptionCasesID ]

PolicyCost: Double

PolicyDuration: Double

RequiredHealthEvaluation: Double



We also have an ExceptionCasesReference Collection that will contain values like the following:


ExceptionCasesID : ObjectID

ExceptionCase: Name

ExceptionCaseDescription: String

I need to somehow make the following into a composite primary key:

ProvincialStateOfResidenceID: String

ExceptionCasesDocRefs: Array[ ExceptionCasesID ]

It is problematic to make the above into a composite primary key because ExceptionCasesDocRefs can have values that range from NULL to a many ExceptionCasesID.

Is there a way of modelling the aforementioned MongoDB Collection(s) in such a way that speed performance is upheld?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.