数据库保存记要的思路

WBOY
Release: 2016-06-13 12:26:45
Original
701 people have browsed it

数据库保存记录的思路
现在网站有一个活动信息,每条活动都可以有很多用户参加,现在有两种方式来保存参加用户的ID,
一是在每条活动里开个字段,然后参加者的ID以这种方式保存(1,2,3,4),这样的话当根据用户来查找它参加的活动时就比较麻烦(我用tp开发的)
还有一种是再新建设个数据库,添加两个字段activeid(保存活动ID), joinid(保存参加者的ID),一个保存活动ID,另一个字段保存参加者的ID,如下
activeId      joinId
1                   1
1                   2
1                  3
这种方式可能会产生多条记录,

------解决思路----------------------
第一种是 NoSQL 的正常做法
第二种是 SQL 的正常做法

如在关系型数据库(SQL)中使用方案一的话,目前只有 MySQL 支持(通过 find_in_set 函数查找)
但需要注意字段的容量

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!