自定义表单构建器的数据库设计(和结果存储) [英] Database design for custom form builder (and storage of results)

查看:2717
本文介绍了自定义表单构建器的数据库设计(和结果存储)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施自定义表单构建器,类似于 Wufoo Google

I'm trying to implement a custom form builder, similar to those provided by Wufoo and Google.

虽然我创建了一个简单的UI来创建这些自定义形式与我的问题在于数据库设计。创建表单后,JSON实现将保存在数据库中(希望改进),并引用构建用户将看到的表单。

While I've created a simple UI to create these custom forms with, my issues lie in the database design. Upon creating the form, a JSON implementation is saved in the database (would like to improve this) and referenced to build the form that a user would see.

提交后,我想将表单的所有字段存储在数据库中。遵循用于设计数据库的JSON结构,这是很容易的。

Upon submission, I'd like to store all of the fields of the form in a database. Following the JSON structure used for designing the database, this is easy enough. However I'd like each individual field to be searchable.


  1. 是否有更好的方式存储表单设计?

  2. 什么数据结构/模型将适合表单结果的存储?我看到EAV可能是可能的,但是由于涉及到不同的输入类型(下拉框,复选框,文本,文本区域),这可能会变得乏味。

  3. 哪种结构将允许最简单的搜索并允许使用WHERE子句?

  1. Is there a better way to store the form design?
  2. What data structures/models would fit storage of the form's results? I've seen that EAV could be a possiblity, but due to the different input types involved (drop-down, checkbox, text, textarea) this may become tedious.
  3. Which structure would allow easiest searching and permit the use of WHERE clauses? The JSON example given, doesn't allow me to do this quite as nicely


推荐答案

EAV是一个有效的选项 - 它可以是复杂和尴尬的,有效地成为无类型的数据。

EAV is a valid option - it can be complex and awkward with what effectively becomes untyped data.

XML与XPath也将是一个选项: a href =http://dev.mysql.com/tech-resources/articles/xml-in-mysql5.1-6.0.html =nofollow noreferrer> http://dev.mysql.com/tech -resources / articles / xml-in-mysql5.1-6.0.html

XML with XPath would also be an option: http://dev.mysql.com/tech-resources/articles/xml-in-mysql5.1-6.0.html

我认为大多数情况下都需要您生成动态SQL,如果要搜索的字段可能有所不同。

I would think that most cases would require you to generate dynamic SQL if the fields to search can vary.

这篇关于自定义表单构建器的数据库设计(和结果存储)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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