开发者

Template Design / Architecture

开发者 https://www.devze.com 2023-01-12 12:40 出处:网络
I am looking into creating something similar to a form template system on my web site.开发者_Go百科

I am looking into creating something similar to a form template system on my web site.开发者_Go百科

As an example, say I want the users to be able to create form templates (similar to Wufoo, they can define any number of inputs, etc). Then from these created templates, anybody would be able to use these templates, fill them out, and therefore create a number of form instances (this would be possible for each user-defined template). Also, there would be no limit to the number of templates and instances created.

Purely from a server/persistence perspective, what is the best way of creating a system like this? Would I need to create a new database table for each created template and then insert the form instances as records into the table? How well would this scale?


This topic is very broad. As to the scalability, Wufoo (and other form creation websites) currently work. So a brief answer is, it's already being done, so scaleability shouldn't be an issue. However, random generation of multiple tables will get out of control very quickly.

If you are not at a point where you are having this problem, I would first build the system with single tables and UUIDs for the Primary Keys. This makes them moveable later on. Then, if table sizes become an issue, you can split out the tables anyway you see fit. For example, you can have all of the customes whos last name start with A in the a_forms table.

As for the structure of the tables, you would build these as a ONE-TO-MANY. One form can have many elements. The elements can all be predefined (i.e. text, text area, radio button, check box, submit button, etc.) When someone builds a form, you can serialize() the form elements and save them in the table. When the form needs to be rendered, you unserialize(), parse the elements and build the form.

0

精彩评论

暂无评论...
验证码 换一张
取 消