用于存储用户配置文件的更好的数据模型是什么?

时间:2022-12-08 13:06:43

I am working on the data model for a relational database where I have to store User Information as well as User's profile such as Education Level, personal interests, hobbies, and etc. Similar to what most of the social networking sites have or any other systems that allow you to build a profile.

我正在研究关系数据库的数据模型,我必须存储用户信息以及用户的个人资料,如教育水平,个人兴趣,爱好等。类似于大多数社交网站或任何其他系统允许您构建配置文件。

I cannot decide if it would be better to store all this information in one Users table, or break it into 2 tables.

我无法确定将所有这些信息存储在一个Users表中是否更好,或者将其分成两个表。

If I would break it into two tables I would have Users table that would just store UserID, Name, e-mail, DOB, gender.

如果我将它分成两个表,我会有Users表,只存储UserID,Name,e-mail,DOB,gender。

UserProfiles would store the rest of the stuff pertaining to a profile, sharing the same UserID with Users table

UserProfiles将存储与配置文件相关的其余内容,与Users表共享相同的UserID

3 个解决方案

#1


3  

  1. If there are multiple profiles of a single user means one to many relation then i would recommend you to create 2 tables one is user and other is user-profile.

    如果单个用户有多个配置文件意味着一对多关系,那么我建议您创建2个表,一个是用户,另一个是用户配置文件。

  2. If one user have only one profile then your should create only one table with both attributes on User as well as profile.

    如果一个用户只有一个配置文件,那么您应该只创建一个表,其中包含User和profile两个属性。

#2


2  

Go for the more modular design, this will allow for more flexibility and control. The only time I would recommend keeping the data in a single table is if you plan to query the same data frequently.

采用更模块化的设计,这将提供更多的灵活性和控制。如果您打算经常查询相同的数据,我建议将数据保留在单个表中的唯一时间。

There is a great article here which goes into depth as to why joins are expensive. You should ultimately base your decision off the information provided in the link, however as I mentioned before if you plan to query the two tables together frequently then keep the data in a single table.

这里有一篇很棒的文章深入探讨了为什么连接很昂贵。您最终应根据链接中提供的信息做出决定,但正如我之前提到的,如果您计划频繁查询两个表,则将数据保存在单个表中。

#3


1  

I think,in order to decide which data model to chose, just look at some of the similar requirement Datamodels, which are presented in this Datamodel Library.

我认为,为了决定选择哪种数据模型,只需看看这个Datamodel库中提供的一些类似的需求Datamodels。

Specific to your User-profiles Datamodel Requirement, this link may be useful.

具体到您的用户配置文件数据模型要求,此链接可能很有用。

Hope those links will be useful. OR I got this Data model image depicting facebook type data model:

希望这些链接有用。或者我得到了描述facebook类型数据模型的数据模型图像:

用于存储用户配置文件的更好的数据模型是什么?

#1


3  

  1. If there are multiple profiles of a single user means one to many relation then i would recommend you to create 2 tables one is user and other is user-profile.

    如果单个用户有多个配置文件意味着一对多关系,那么我建议您创建2个表,一个是用户,另一个是用户配置文件。

  2. If one user have only one profile then your should create only one table with both attributes on User as well as profile.

    如果一个用户只有一个配置文件,那么您应该只创建一个表,其中包含User和profile两个属性。

#2


2  

Go for the more modular design, this will allow for more flexibility and control. The only time I would recommend keeping the data in a single table is if you plan to query the same data frequently.

采用更模块化的设计,这将提供更多的灵活性和控制。如果您打算经常查询相同的数据,我建议将数据保留在单个表中的唯一时间。

There is a great article here which goes into depth as to why joins are expensive. You should ultimately base your decision off the information provided in the link, however as I mentioned before if you plan to query the two tables together frequently then keep the data in a single table.

这里有一篇很棒的文章深入探讨了为什么连接很昂贵。您最终应根据链接中提供的信息做出决定,但正如我之前提到的,如果您计划频繁查询两个表,则将数据保存在单个表中。

#3


1  

I think,in order to decide which data model to chose, just look at some of the similar requirement Datamodels, which are presented in this Datamodel Library.

我认为,为了决定选择哪种数据模型,只需看看这个Datamodel库中提供的一些类似的需求Datamodels。

Specific to your User-profiles Datamodel Requirement, this link may be useful.

具体到您的用户配置文件数据模型要求,此链接可能很有用。

Hope those links will be useful. OR I got this Data model image depicting facebook type data model:

希望这些链接有用。或者我得到了描述facebook类型数据模型的数据模型图像:

用于存储用户配置文件的更好的数据模型是什么?