Situation: SQL data storage for HTML form submissions.
Scenario 1: 1 table with each form field as a table field (form).
Scenario 2: 2 tables - 1st table with id and timestamp (form_submission). 2nd table with id, fk to form_submission, field_title, field_value (form_field). Only inserts data if the HTML field has a value.
Which requires more memory?
In scenario 1... only 1 record per submission, but each record will have multiple null values.
In scenario 2... 5+ records from the form_field table as well as the time submitted from the form_submission table.
Side note: we only get ten-thousands of form submissions per year.
Assuming the majority of users fill out the majority of fields, then yes, the more normalized form will take more space/memory (especially because of the timestamp - which I'm really hoping is a DATETIME
/DATETIME2
, and that's a terrible name for it, regardless).
Personally, for a HTML submission form (that doesn't have 'child' data), I'd probably do a single table for the form; EAV tables can be much more difficult to query. Non-required columns can simply default to null. If you're building a more complex system though (like customer management), you're going to need to split things differently.