如何在数据库中存储自定义用户字段 [英] How to store custom user fields in database

查看:736
本文介绍了如何在数据库中存储自定义用户字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到一个教程,指导我如何基于用户的自定义字段的工作原理。就像在调查网站,他们允许用户创建自定义字段并存储它们,更重要的是存储通过这些字段输入的数据。

I am trying to find a tutorial that will guide me on how user based custom fields works. Like in surveys sites, where they let users create custom fields and store them and more importantly store the data entered through those fields.

我在寻找一些描述如何是在数据库上完成的。我有一个麻烦找到一种方法,不会永远检索这个数据一旦用户的什么提取到excel / cvs文件。

I am looking for something that describes how this is done on database. I am having a little trouble finding a way that would not take forever retrieving this data once the users whats to extract it to excel/cvs files.

推荐答案

第六正常表单是实现此的正式方式。对于所有表,使用3NF,对于需要添加没有DDL更改的列的一个或两个表,使用6NF。谨慎使用。

Sixth Normal Form is the formal way to implement this. Go with 3NF for all tables, and 6NF for the one or two tables that you need to add columns without DDL changes. Use sparingly.

EAV是6NF的混蛋。这意味着,做这件事的人都不能正式理解6NF,所以经常会创造怪物。

EAV is the bastard son of 6NF. What that means is, people who do it, and write about it, do not have a formal understanding of 6NF, so often the create monstrosities.

当然,你必须保持良好的标准:使用数据类型;声明参考完整性(外键);不要让那些获得任何东西。

Of course, you must retain good standards: use datatypes; Declarative Referential Integrity (Foreign Keys); etc. Do not give those up obtain anything. Run like hell away from anyone telling you you have to give them up.

6NF / EAV是非常快的,没有妨碍使用设置处理能力的服务器。再次,运行像地狱远离任何人谁告诉你,你必须使用逐行处理或游标,或者你不能轻松地从行构建列。

6NF/EAV is very fast, there is no hindrance to using the set-processing capability of the server. Again, run like hell away from anyone who tells you that you have to use row-by-row processing or cursors or that you cannot build the columns from the rows easily. Post again if you have specific problems.

这需要超越SQL的当前功能(控件,DDL);为了以可控的方式做到这一点,并避免创建不可维护的怪物,你需要一个小目录,以包含元数据。如果你聪明,你可以使用它生成查询所需的SQL,从而消除很多其他的手工劳动。

This requires going beyond the current capability (controls, DDL) of SQL; in order to do that in a controlled fashion and avoid creating unmaintainable monsters, you need a small catalogue, to contain the meta-data. If you are clever, you can use it generate the SQL reruired for querying, and thus eliminate a lot of otherwise manual labour.

这里有很多错误信息,一些有rep的人是无能的。为了在技术上取得成功,我们需要准确的信息,而不是神话和恐惧。您可能对最近的帖子感兴趣,其中我尝试 将recond设置为

There is a lot of misinformation around, and some people with "rep" are clueless. In order to succeed technically, we need accurate info, not myths and fear mongering. You may be interested in a recent post in which I tried to set the recond straight.

这篇关于如何在数据库中存储自定义用户字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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