How to Store Temporary Data: Multi-Page Forms
How do you solve the problem of storing temporary data in a database? Imagine a situation when you fill in a multi-page form. What happens if you pause and come back in a few days to finish it? It would be great if the data is saved, and if you can take it up right where you left it.
However, this brings up a question: where should this temporary data be stored? As the data is not complete yet, it should not land in the target table.
Instead, we can model the temporary state in a separate table structure as shown in the example below. Unfinished questionnaires are stored in
questionnaire_temp. Once submitted, the data is moved to the target
In our example, both tables have identical fields. However, depending on the situation, the temporary data table can differ from the one in which data is ultimately stored. Sometimes, a simpler structure is sufficient, but in other cases, we may need a more complicated structure.