Wufoo的数据库模式--你会如何设计它?[英] Wufoo's Database Schema - How would you design it?

本文是小编为大家收集整理的关于Wufoo的数据库模式--你会如何设计它?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

wufoo 是:

HTML表单构建器,可帮助您创建联系表格,在线调查和邀请函,因此您可以收集所需的数据,注册和在线付款,而无需编写一行代码.

如果构建类似站点,您将如何处理数据库设计?

更高级别的设计(表和关系)或较低级别的设计(表,关系,字段,视图,规则,MySQL查询等)...都欢迎: - )

基于mySQL的解决方案首选;-)

推荐答案

这种类型的数据库设计要求 eav 表.例如,表单部分可能包含:

1. User table (user_id, user_name, etc.)
2. Form table (user_id, form_id, form_name, etc.)
3. Form_field table (form_id, column_id, column_name, column_type, etc.)
4. column_type table (column_type_id, column_type_name)

填写的结果将保存在另一个表中:

Filled_form (form_id, column_id, value)

这个想法是创建一个数据库模型,该模型足够通用(但不超过),以满足不同用户的需求.例如,列类型由程序员设置,每种类型在呈现表单时都有不同的含义.

本文地址:https://www.itbaoku.cn/post/597498.html

问题描述

Wufoo is a:

HTML form builder that helps you create contact forms, online surveys, and invitations so you can collect the data, registrations and online payments you need without writing a single line of code.

How would you approach the database design if building a similar site?

Higher level designs (tables and relationships) or Lower level designs (tables, relationships, fields, views, rules, MySQl queries, etc)... are all welcome :-)

MySQL based solutions preferred ;-)

推荐答案

This type of database design calls for EAV tables. For example, the form section probably contains:

1. User table (user_id, user_name, etc.)
2. Form table (user_id, form_id, form_name, etc.)
3. Form_field table (form_id, column_id, column_name, column_type, etc.)
4. column_type table (column_type_id, column_type_name)

Filled in results will be saved in a different table:

Filled_form (form_id, column_id, value)

The idea is to create a database model that is just generic enough (but no more than) needed, in order to accommodate for the needs of different users. For example, the column types are set by the programmers, and each type has a different meaning when rendering the form.