是这样的,我正在做一个调查问卷系统, 每个新建的调查问卷的表单字段都是可以自定义的, 那么问题来了, 我需要为每个填表的用户添加一个数据库字段, 但是既然是自定义字段, 那么用列名表示字段名就不行了,而且可以创建不止一个问卷,我该怎么办?
1
uyhyygyug1234 2016-09-04 09:49:44 +08:00 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 |
2
C0dEr 2016-09-04 10:54:14 +08:00
比较简单的做法 ,自定义 html ,可以将 html 抽象成 json 存在数据库
|
3
tftk 2016-09-04 12:19:29 +08:00 via iPhone
EAV
Jsonb |
4
Comdex 2016-09-04 12:49:46 +08:00
用文档型非关系数据库
|
5
huamei 2016-09-04 17:10:54 +08:00
再建一个 schema 表,或者使用 mongodb
|
6
zrp1994 2016-09-04 19:27:57 +08:00 via iPhone
用非关系型数据库
|