【发布时间】:2017-08-29 21:43:57
【问题描述】:
我使用 MongoDB 已经有一段时间了,但我只在其他人已经完成了设计模式的基本任务时才使用它来执行 CRUD 操作。所以,基本上这是我第一次设计模式,我需要一些建议。 我将从用户那里收集的数据是他们的常规信息、健康相关信息和保险相关信息。单个用户不会拥有多个健康和保险相关信息,因此它是简单的一对一关系。但是这些健康和保险相关的信息将有很多领域。所以我的问题是。单独收集健康和保险相关信息是否很好:
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
}
【问题讨论】:
标签: mongodb database-design mongoose schema