许多与许多关系表字段到MongoDB

发布于 2025-01-24 23:58:09 字数 430 浏览 3 评论 0原文

在SQL中进行许多与许多关系时,我们创建了一个表格,该表将具有形成关系的2个表的ID。有时,在我们正在创建的表中,我们会保留更多数据。

示例:

一个名为Worker的表和一个称为部门的表。工人可以在许多部门工作,许多工人可以在同一部门工作。

但是,工人在部门之间移动,我们需要存储他们进入另一个部门的年份。

在Mongodb,我们该年如何代表。我正在为每个工人创建ID,并添加他们工作的部门,但是我该如何存储一年?

如何代表想要的菲尔德。

While doing a many to many relationship in SQL we create a table that will have the ID of the 2 tables that are forming the relationship. Sometimes in that table that we are creating, we put more data.

Example:

A table called worker and a table called department. Workers can work in many departments and many workers can work in the same department.

However the workers move between department and we need to store the year that they move into another department.

In mongoDB how can we represent that year. I am creating id for every worker and adding the department where they have worked but how do I store the year?

How to represente the WantedField.

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萝莉病 2025-01-31 23:58:09

您可以实现这一目标的一种方法就是简单地在MongoDB中做同样的事情,创建另一个表格只是为了拯救工人和部门的关系。

one way that you could achieve this can be to just simply do the same thing in mongoDB, create another table just to save the relations of workers and departments.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文