嗯,我可能會創建一個數據庫結構是這樣的:
-- This table will hold the forms
CREATE TABLE tblForm
(
Form_Id int IDENTITY(1,1) PRIMARY KEY
, Form_Name varchar(100)
-- Any other form related data such as create date, owner etc`
)
-- This table will hold the input types (i.e text box, combo box, radio buttons etc`)
CREATE TABLE tblInputType
(
InputType_Id int IDENTITY(1,1) PRIMARY KEY
, InputType_Name varchar(100)
)
-- This table will hold the inputs used in the form
CREATE TABLE tblFormInput
(
FormInput_Id int IDENTITY(1,1) PRIMARY KEY
, FormInput_Form int FOREIGN KEY REFERENCES tblForm(Form_Id)
, FormInput_InputType int FOREIGN KEY REFERENCES tblInputType(InputType_Id)
, FormInput_Name varchar(100)
, FormInput_DisplayOrder numeric(18,18)
, FormInput_DefaultText varchar(100)
)
-- This table will hold the texts and values used for combo boxes, radio buttons, check boxes etc`
CREATE TABLE tblFormInputExtraData
(
FormInputExtraData_FormInput int FOREIGN KEY REFERENCES tblFormInput(FormInput_Id)
, FormInputExtraData_Text varchar(100)
, FormInputExtraData_Value varchar(100)
)
問題的興趣:對所有文本數據
我用VARCHAR(100)只是作爲一個任意 這個例子的數字。您應該爲您的應用程序選擇適當的長度 長度。
我已經使用varchar來存儲輸入值,如組合框 和單選按鈕,因爲它很容易。如果您打算使用 非文本值(例如。網絡對象或圖像,你應該改變這種數據類型爲任何適合你的需求 - xml和 varbinary浮現在腦海。
你打算如何將下拉菜單綁定到其他窗體?我不明白那一部分。除此之外,我建議保持您的結構儘可能通用。 –
我想如果我按照選項2,我的表格結構將是: – user3230681
我認爲如果我按照選項2,我的表格結構將是:Template_Form_table(form_id,Form_Name)和Template_Field_Table(field_id,field_Name,field_order,form_id,field_datasource )所以field_datasource被引用到同一個表(自引用關係) – user3230681