是这样的,我正在做一个调查问卷系统, 每个新建的调查问卷的表单字段都是可以自定义的, 那么问题来了, 我需要为每个填表的用户添加一个数据库字段, 但是既然是自定义字段, 那么用列名表示字段名就不行了,而且可以创建不止一个问卷,我该怎么办?
是这样的,我正在做一个调查问卷系统, 每个新建的调查问卷的表单字段都是可以自定义的, 那么问题来了, 我需要为每个填表的用户添加一个数据库字段, 但是既然是自定义字段, 那么用列名表示字段名就不行了,而且可以创建不止一个问卷,我该怎么办?
|
1
1.新建一个表 存 StringValue1, StringValue2... IntValue1, IntValue2,...
2.创建一个动态表, 用户加了你就加。会有性能问题 3.生成一个表, UDFName, UDFDataType, and Value. When a new UDF gets added, generate a View which pulls just that data and parses it into whatever type is specified. Items which don't meet the parsing criteria return NULL. 4.Create multiple UDF tables, one per data type. So we'd have tables for UDFStrings, UDFDates, etc. Probably would do the same as #2 and auto-generate a View anytime a new field gets added 5. XML DataTypes? I haven't worked with these before but have seen them mentioned. Not sure if they'd give me the results I want, especially with performance. http://stackoverflow.com/questions/5106335/how-to-design-a-database-for-user-defined-fields |
|
z67nnciQnb7r8bLfSep 4, 2016
2
比较简单的做法 ,自定义 html ,可以将 html 抽象成 json 存在数据库
|
|
tftkSep 4, 2016 via iPhone
3
EAV
Jsonb |
|
ComdexSep 4, 2016
4
用文档型非关系数据库
|
|
huameiSep 4, 2016
5
再建一个 schema 表,或者使用 mongodb
|
|
zrp1994Sep 4, 2016 via iPhone
6
用非关系型数据库
|