Niroj
Niroj

Reputation: 1114

Database design for unknown fields

I am trying to make form builder in android. I have a real problem at designing database. In this application User first drags the required fields to the screen and change the labels of fields. The fields Contains:

  1. CheckBox
  2. RadioButton
  3. TeXtBox
  4. PlainText

This is my mockup: This is my first mockup

And form builder Activity

I have real problem in designing database.I need a help to accomplish it.

Any Links to the tutorials or ER Diagrams will be really appreciated. In this application user will drag his required fields to the screen as shown in mock up. Suppose when user drags on checkbox icon then the Editable Checkbox label and editable options will appear in the screen. Then Form builder names the label according to his requirements and options also. In this way he first builds the form .

Upvotes: 2

Views: 366

Answers (2)

RRTW
RRTW

Reputation: 3190

That's what I created in 10 minutes, hope it helps.

  • TB_FieldType //field type

UUID_Type,

Type_Name, (Checkbox, RadioButton, Textbox, PlainText, Password, DropdownSelect...)


  • TB_FieldRule //Table field rule

UUID_Rule,

Rule (numeric only, not null...)


  • TB_UserTable //Save user designed thrir own table

UUID_Table,

Table_Name, (Designed table name)


  • TB_UserTable_Field //Designed table field detail

UUID_TableField,

UUID_Table,

UUID_Type,

UUID_GroupID, (can be null if field is single type*)

UUID_Rule,

Field_Name, (Display name)

Field_Length,


  • TB_Group //(for field(s) in multi type*, like RadioButton, DropwodnSelect... )

UUID,

GroupID,

GroupData,

Upvotes: 1

ttamas
ttamas

Reputation: 192

I would create a table for storing the field definitions with fields like this:

  • survey_id (reference to the survey which the field belongs to)
  • field_id (unique id of the field)
  • field_type (checkbox, radio, plain etc.)
  • field_label
  • field_data (additional information if required, e.g. selection options for radio - dependent on type)
  • field_index (defines the order of fields)
  • ... any additional field you may need

From this data, you can dynamically build your GUI.

And you will need another table for storing the answers (if it is in scope of your app):

  • field_id (reference to the former table)
  • value (entered by the user)
  • ...user_id, timestamp etc. according to your needs

Upvotes: 0

Related Questions