简体   繁体   English

用户的自定义配置文件字段

[英]User's custom profile fields

I am currently working on a system that would allow users to add additional custom fields for the contacts that they add. 我当前正在使用一个系统,该系统将允许用户为他们添加的联系人添加其他自定义字段。

I wondered what is the best and most efficient approach to add such ability? 我想知道增加这种能力的最好,最有效的方法是什么?

Right now what I was thinking was to have 1 table per users (with foreign keys to a "main" contacts table) and then adding a column for each custom fields that the user adds (since I don't expect to have more then 100-200 users per database shards [sharding is easy since every users never see each-other's content in this system]), although I am not 100% sure that this would be the right solution for such problems. 现在我在想的是每个用户有1个表(外键指向“主”联系人表),然后为用户添加的每个自定义字段添加一列(因为我预计不会有100个以上)每个数据库分片-200个用户(分片很容易,因为每个用户在此系统中都不会看到彼此的内容)),尽管我不是100%地确定这将是解决此类问题的正确方法。

也许您可以尝试使用一个单独的表来存储对用户的引用,再加上字段名称和值,这样您就可以拥有许多自定义字段。

If you go with Boyce-Codd , you separate the information and store them into a table. 如果与Boyce-Codd一起使用,则将信息分开并将它们存储在表中。 Means one table for all users with a foreign key. 对所有具有外键的用户表示一个表。

One table per user would lead to hundreds or more tables with possible repeated information. 每位用户一张桌子将导致数百张或更多张带有重复信息的桌子。

You need to have one table named USERS that stores the id of a user and fixed info you might want. 您需要有一个名为USERS的表,该表存储用户ID和您可能需要的固定信息。 Then, you could have a CONTACT table, that stores the type of contact user might create, and one matching table USER_CONTACT that matches the user unique id with the id of the contact that was created. 然后,您可以拥有一个CONTACT表,其中存储了可能创建的联系人类型,还有一个匹配表USER_CONTACT,该表将用户唯一ID与创建的联系人ID进行匹配。

With this, you could have advanced data mining on all the information stored, like nowing how many contacts each user created, who created more, etc... 这样,您就可以对所有存储的信息进行高级数据挖掘,例如现在确定每个用户创建了多少联系人,创建了更多联系人等等。

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

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