在SQL中存储用户定义的数据的正确方法 [英] Proper way to store user defined data in SQL

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

问题描述

我想建立一个很像wufoo的在线表单制作工具,允许用户创建和发布自己的Web表单。每个提交应该保存到数据库,用户以后可以检索提交的内容。

I want to build an online form builder much like wufoo that allows the users to create and publish their own web forms. Each submission should be saved to a data base where the user can later retrieve the submissions.

由于这些表单将是动态的,即。用户可以完全控制表单域的数量和类型,我试图想到一个坚实的数据库设计来存储此信息。

As these forms will be dynamic, ie. the user has complete control over the amount and type of form fields I am trying to think of a solid database design to store this information.

我将有一个表字段类型包含用户可用的每种类型的字段,即。文本框,电子邮件地址等。

I would have one table fieldtype which contains every type of field available to the users, ie. textfield, emailfield etc.

一个baseform表将保存每个表单id,url等。

One baseform table which will hold each forms id, url etc.

我会然后有一个表格域,它将包含对基本格式和字段类型的引用,此表还可以包括在每个字段上进行的自定义验证。

I would then have a table formfields which would contain ref to the baseform and to fieldtype, this table could also include custom validation to be done on each field.

这个设计是否适合基础结构?我想像这个应用程序添加新的类型很容易,但是我不知道这个潜在的缺点是什么,因为我远离了一个sql专家。

Is this design good as a base structure? I imagine it will be easy to add new types of fields to the application however I don't know what the potential downsides are as I am far from a sql expert.

推荐答案


在SQL中存储用户定义的数据

store user defined data in SQL

我想你是查找实体属性值数据库模型中:

I think you are looking for the Entity–attribute–value database model in which:


基本思想是将属性及其对应的值
作为行在单个表中存储。

The basic idea is to store attributes, and their corresponding values, as rows in a single table.

通常,该表至少包含三列:entity,attribute和
值。虽然只有一个相关实体,一个表
用于应用程序配置或选项设置,实体列
可以被排除。

Typically the table has at least three columns: entity, attribute, and value. Though if there is only a single relevant entity, e.g. a table for application configuration or option settings, the entity column can be excluded.

查看此页作为开始:

< a href =http://scholarspace.manoa.hawaii.edu/bitstream/handle/10125/337/0409CCQPlanningImplementing.pdf?sequence=1 =nofollow>规划和实施元数据驱动的数字存储库(pdf)

我用 entity-attribute-value 标签,您可以在其中浏览很多线程与你的情况有关

I retagged your question with entity-attribute-value tag, in which you can browse a lot of threads that relate to your case.

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

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