使用 MySQL 管理列表和子列表

发布于 2024-12-05 13:01:15 字数 361 浏览 1 评论 0原文

我正在尝试为以下场景创建数据库安排:

每个网站的用户都有自己的主列表。这部分已经由一张包含每个用户的项目的表来处理,该表的字段与每个用户的独特想法相匹配。

每个用户还可以创建任意数量的由主列表中的项目组成的子列表。这些列表中项目的顺序将是可编辑的,并且能够在某些点插入一些全局值。这是我坚持的部分。

处理子列表最有效的方法是什么?我考虑过创建一个由用户 id 标识的列表,并有一个逗号分隔值字段,该字段对应于子列表组成的主列表中的项目,但我觉得我会很难以这种方式跟踪项目订单。

我试图搜索这个,但我很难找到一种方法来以可搜索的方式表达我想要做的事情。

另外,如果有任何学习材料的建议可以帮助我自己找到这个答案,我会喜欢一些建议。

I am trying to create a database arrangement for the following scenario:

Users of the site each have their own master list. This part is already being handled by one table that holds everyone's items, with a field that matches each user's unique idea.

Each user will also be able to create any number of sub lists that are made up of the items from their master list. The order of the items in these lists will be editable, as well as the ability to insert some global values at certain points. This is the part I am stuck on.

What would be the most efficient way to handle the sub lists? I've thought about creating a table of lists that are identified by user id and have a field of comma separated values that correspond to the items from the master list that the sub list is composed of, but I feel I would have a hard time keeping track of the item order that way.

I have tried to search for this, but I am having trouble finding a way to phrase what I am trying to do in a searchable way.

Also, if there are any recommendations for learning material that may help me come up with this answer on my own, I would love some recommendations.

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

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

发布评论

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

评论(1

困倦 2024-12-12 13:01:15

我会使用带有额外列的多对多表。您将拥有 user_id、item_from_master_list_id 和位置。这样你就可以通过 user_id 选择,并按位置排序。

I would use a many-to-many table with an extra column. You'd have user_id, item_from_master_list_id, and position. That way you could select by user_id, and order by position.

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