存储值列表(例如兴趣) [英] Store list of values (such as interests)

查看:42
本文介绍了存储值列表(例如兴趣)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户表(ID,FNAME,LNAME,INTERESTS等),还有另一个表可以容纳他们可以从中选择的特定的一组利益:电影,电视,广播,舞台,站立式.

I've got a table of Users (ID, FNAME, LNAME, INTERESTS,...) plus another table to hold the specific set of INTERESTS they can choose from: Film, TV, Radio, Stage, Standup.

他们可能有不止一个兴趣,那么如何将这些信息存储在用户兴趣"字段中?还是实现这一目标的最佳替代方法是什么?

They can have more than one interest, so how can I store this information in the Users INTERESTS's field? Or what is the best alternative method to achieve this?

推荐答案

这是一个多对多的关系.您可以通过引入联接表"来存储它们.

It's a many-to-many relationship. You store these by intoducing a "join table".

Table Users:
-----------
UserID PK
Name
...


Table Interests
-------
InterestID PK
Description.
....


User_interest
-----------
UserID PK, FK
InterestID PK, FK

这篇关于存储值列表(例如兴趣)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆