代码之家  ›  专栏  ›  技术社区  ›  Bear Bile Farming is Torture

在MongoDB中,将DOB和GENDER列复制到所有表中是否安全?

  •  0
  • Bear Bile Farming is Torture  · 技术社区  · 4 年前

    所以我的应用程序有一个表来承载 User .每个用户都有一个 DOB GENDER .

    当然,这些领域永远不会改变。

    在其他表格中,我需要从 使用者 ,例如:

    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,
      });
    };
    

    复制这两列、打破规范化是更好的选择,还是从 使用者 谁的推荐信?

    此查找不是联接,因此它应该扩展吗?

    0 回复  |  直到 4 年前