简体   繁体   English

MYSQL / PHP-将用户附加到项目的有效方法

[英]MYSQL / PHP - Efficient method for attaching users to a project

I'm building a system that has a user table and a project table. 我正在构建一个具有用户表和项目表的系统。 I'm trying to determine the most efficient way to connect users to a project. 我正在尝试确定将用户连接到项目的最有效方法。

I'm was thinking about a table that records the relationship, but I wasn't sure if a serialized list in one field would work just as well. 我当时正在考虑一个记录该关系的表,但是我不确定一个字段中的序列化列表是否也能正常工作。

A join table (eg UserJoinProject ) would be my preference and would be well normalized. UserJoinProject表(例如UserJoinProject )将是我的首选,并且可以很好地进行规范化。 Assuming you have an ID column as a primary key for projects and for users. 假设您有一个ID列作为项目和用户的主键。

Serializing the list will make it difficult for mysql to do any kind of operation on that data. 序列化列表将使mysql难以对该数据进行任何类型的操作。

如果是多对多关系,则可以创建另一个表,该表仅将项目ID与用户ID相关联。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM