用户,组和标签数据库设计 [英] Users, Groups and Tags database design
问题描述
我尝试为以下场景设计数据库结构时遇到困难:
我的数据库应包含一般用户信息UserID,FirstName,
LastName,JoiningDate。
每个用户都可以是组的一部分。
每个组都有附加到它的标签可以有多个标签。用户
还可以返回可用组列表(由
标签过滤)。
能够搜索组(由标签附加到组)和
搜索特定用户(按姓氏或唯一ID)。 )。它也应该可以
返回可用组列表(由标签过滤)和特定组的
成员(以姓名过滤并由
加入日期过滤) / p>
还应该有一种方法来发现哪些
组的用户属于多个组(对
的查询)是谁的成员Bravo组和Delta
组),并跟踪发送在组中的消息(如
论坛)。
这只是两张桌子吗?或者应该是三个表...用户,组和标签?它已经差不多一年了,因为我有任何关系数据库的东西,我想知道是否有人可以显示这个数据库设计的视觉表示?
我建议五个表:用户,组,标签和链接表UserGroups和GroupTags。
这是因为似乎有一个多对多的关系用户和组以及组和标签之间 - 关系设计需要一个链接实体来连接它们之间具有多对多关系的实体。
code> --------- ------------ --------
|用户| |组| |标签|
--------- ------------ --------
| | | |
| | | |
/ | \ / | \ / | \ / | \
-------------- ------------ -
| UserGroups | | GroupTags |
-------------- -------------
Im having difficulty trying to design a database structure for the following scenario:
My database should contain general user information UserID, FirstName, LastName, JoiningDate.
Each User can be part of a group.
Each group has "tags" attached to it and can have multiple tags. Users should also be able to return a list of available groups (filtered by tags).
Be able to search for a group (by tags attached to the group), and searching for particular users (by last name, or unique ID). ). It should also be able to return a list of available groups (filtered by tags), and the members of a particular group (filtered by last name and filtered by joining date).
There should also be a means of discovering which groups of users belong to a number of groups (a query on "who are the members of "Bravo group" and the "Delta" group), and keeping track of messages sent in the group (like a forum).
Is this just two tables? Or should it be three tables... Users, Groups and Tags? Its been almost a year since ive did any relational database stuff and I was wondering if anyone could show a visual representation of this database design?
I suggest five tables: Users, Groups, Tags and link tables UserGroups and GroupTags.
This is because there appears to be a many-to-many relationship between Users and Groups, and between Groups and Tags - a link entity is required in relational design to join entities with many-to-many relationships between them.
--------- ------------ --------
| Users | | Groups | | Tags |
--------- ------------ --------
| | | |
| | | |
/|\ /|\ /|\ /|\
-------------- -------------
| UserGroups | | GroupTags |
-------------- -------------
这篇关于用户,组和标签数据库设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!