Created
October 18, 2016 05:21
-
-
Save hanafiah/778c36e742c2a2969f2f8dd58825ad1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input name="sample[]" type="checkbox" value="1"> Test 1 | |
<input name="sample[]" type="checkbox" value="2"> Test 2 | |
<input name="sample[]" type="checkbox" value="4"> Test 3 | |
<input name="sample[]" type="checkbox" value="8"> Test 4 | |
<input name="sample[]" type="checkbox" value="16"> Test 5 | |
=========== | |
1. DB relationship | |
tblsample | |
--------------- | |
id | name | |
1 | Test 1 | |
2 | Test 2 | |
4 | Test 3 | |
8 | Test 4 | |
16 | Test 5 | |
tblanswer | |
--------------- | |
id | desc | |
1 | lorem ipsum | |
2 | dolor sit amet | |
tblselectionmatch | |
--------------- | |
id | sample_id | answer_id | |
1 | 2 | 2 | |
2 | 8 | 2 | |
3 | 16 | 2 | |
4 | 8 | 1 | |
2. store as string (Comma deliminated / json / serialize etc ) | |
Get array value and convert it to string | |
tblanswer | |
--------------- | |
id | desc | selection | |
1 | lorem ipsum | 8 | |
2 | dolor sit amet | 2, 8, 16 | |
3. bitmask | |
Get array value and sum it | |
tblanswer | |
--------------- | |
id | desc | selection | |
1 | lorem ipsum | 8 | |
2 | dolor sit amet | 26 | |
4. Any other options?.. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't see the need for tblselectionmatch. Can simply add tblsample.id in tblanswer, unless of course there's another layer of data granularity that you need to store but not shown here.