数据库关系分组项
您好,我正在创建一个在线工具,允许用户将服装添加到他们的帐户中。我想允许用户对这些项目进行分组,但不确定何时涉及数据库关系。
项目由用户添加;
然后多个项目应该能够组合在一起;
单个项目应该能够属于多个组。
在使用分组功能之前,我有一张用户表和一张项目表,通过主/外键链接。然后,为了从特定用户获取项目,我只需连接两个表并按 user_id 选择条目。
我不确定应该如何实现组功能
我是否应该有一个组表以及它们应该如何关联?
我对数据库关系真的很陌生,但是如果我有一个名为 groups 的表,它怎么能有一个项目数组作为条目呢? 或者一个项目如何拥有它所属的组数组?
任何帮助都会很棒
Hi I'm creating an online tool allowing users to add items of clothing to their account. I want to allow users to group these items but am unsure when it comes to the database relationships.
Items are added by users;
Multiple items should then be able to be grouped together;
A single item should be able to be in more than one group.
Before the grouping feature I had one table for users and one table for items, linked via a primary/foreign key. Then to get items from a specific user I simply joined the two tables and selected entries by user_id.
I'm unsure how I should go about implementing the groups feature
Should I have a table for groups and how should they relate ?
I'm really new to database relations but if I have a table called groups, how can it have an array of items as an entry?
or how can an item have an array of groups that it belongs to ?
any help would be brilliant
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
表
请注意,“GROUP”很可能是保留/关键字,因此您可能需要重命名它。
Tables
Be aware the "GROUP" will most likely be a reserved/keyword so you may want to rename it.