【发布时间】:2022-01-21 18:40:55
【问题描述】:
const image_schema = () => {
const common_fields = {
user_id: {
type: mongoose.Schema.Types.ObjectId,
ref: "user",
required: true,
},
file_name: {
type: String,
required: true,
},
};
return new mongoose.Schema(common_fields, {
collection: `image`,
timestamps: true,
});
};
以上是 image 集合的 mongoDB 架构。
每当我需要获取此表中的行子集时,我还需要从user 表中获取相应的user 信息,该表由user_id 列引用。
从user 表中提取附加列的时间复杂度是多少?
如果user 集合中的这些额外列包含在image 集合中,那么速度性能会显着提高,从而破坏规范化吗?
【问题讨论】:
标签: sql database mongodb nosql relational-database