我已經使用了MongoDB一段時間,但我只用它做CRUD操作時,其他人已經完成了設計模式的基本任務。所以,基本上這是我第一次設計一個模式,我需要一些建議。 我將從用戶處收集的數據是他們的常規信息,他們的健康相關信息以及他們的保險相關信息。單個用戶不會有多個與健康和保險相關的信息,因此它是簡單的一對一關係。但這些健康和保險相關信息將會有很多領域。所以我的問題是。它的好處是有一個單獨的收集健康和保險相關的信息:MongoDB Schema設計建議
var userSchema = {
name : String,
age : Number,
health_details : [{ type: Schema.Types.ObjectId, ref: 'Health' }],//reference to healthSchema
insurance_details : [{ type: Schema.Types.ObjectId, ref: 'Insurance' }] //reference to insuranceSchema
}
,或者有大量的字段作爲一個單一的集合:
var userSchema = {
name : String,
age : Number,
disease_name : String, // and many other fields related to health
insurance_company_name : String //and many other fields related to insurance
}