Here’s a layout of my data:
Heading 1:
Sub heading
Sub heading
Sub heading
Sub heading
Sub heading
Heading 2:
Sub heading
Sub heading
Sub heading
Sub heading
Sub heading
Heading 3:
Sub heading
Sub heading
Sub heading
Sub heading
Sub heading
Heading 4:
Sub heading
Sub heading
Sub heading
Sub heading
Sub heading
Heading 5:
Sub heading
Sub heading
Sub heading
Sub heading
Sub heading
These headings need to have a ‘Completion Status’ boolean value which gets linked to a user Id.
Currently, this is how my table looks:
id | userID | field_1 | field_2 | field_3 | field_4 | etc...
-----------------------------------------------------------------------
1 | 1 | 0 | 0 | 1 | 0 |
-----------------------------------------------------------------------
2 | 2 | 1 | 0 | 1 | 1 |
Each field represents one Sub Heading. Having this many columns in my table looks awfully inefficient…
How can I go about optimizing this? I can’t think of any way to neaten it up :/
Don’t use boolean values but simple relations:
table completion_statusFrom that it’s easy to see that user 1 has completed field 3, and user 2 fields 1, 3 and 4.
This way you don’t have to change your database schema whenever you want to change the amount of fields.