John O'Sullivan
John O'Sullivan

Reputation: 63

Building a multi-step webforms - One table DB or multiple tables

I'm in the process of building a multi-step application form that has 7 sections such as 'your details', 'your financial circumstances', 'previous history', etc.

I would like to save the users input at the end of each section - i.e. on submit/continue - but I'm unsure whether to use one huge table (there are lots of fields!) or break the data down into multiple tables based on the sections.

I'm leaning towards the latter because it seems more logical and orderly, however I'm unsure how to link the tables so that the data will be linked to each user who fills out the form?

I've only worked on single page/table web forms in the past, one db with one table (example below) which collects data from a competition of some sort:

CREATE TABLE user_data ( 
id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
firstName VARCHAR(255) NOT NULL, 
lastName VARCHAR(255) NOT NULL, 
postcode VARCHAR(255) NOT NULL, 
telephoneNumber VARCHAR(255) NOT NULL, 
emailAddress VARCHAR(255) NOT NULL, 
dateTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP );

So this is a new area for me, any help/pointers would be greatly appreciated!

Upvotes: 1

Views: 580

Answers (2)

Artemy Prototyping
Artemy Prototyping

Reputation: 160

If you have collection data type in form (like table) you have two choice:

  1. Create one to many tables for each collection type
  2. Store data in software readable formate like json in text field of database.

Upvotes: 1

Prabir Ghosh
Prabir Ghosh

Reputation: 440

As you are using master and details here, I am not sure how can you store all the information in one big table. In this case, for one user there will be multiple history. That means you have to use one-to-many relationship in this case. You have not provided much detail. However, I would like to know how do you design you table schema using just one table.

Upvotes: 1

Related Questions