在提出这个问题之前,我应该说,我对数据库的效率知之甚少,不久后数据库的效率就会变得显而易见。
这是一个相当简单的问题:
I d like to store attendance to events within a mysql database. I ve thought of two possible methods (there are more, I m sure):
- Create an additional
attendance
row in theevents
table, containing a comma separated list of user ids - Create an
attendance
table, containing two columns,event_id
anduser_id
我的直觉说,方法2是最有效率的-- 虽然多行必须返回和穿行,但这可能比在刻录的字符串中搜索特定的user_id
的成本要低...
有人能证实吗?