How to model this context in db?

I have in a backoffice a screen that shows a table similar like this:

This table is associated with a process (processId) and this table is static is not possible to create new items (rows, columns) for the table, the table only shows this information by default and then the user can select the checkboxes to check the checkboxecs that he wants. 

My doubt is how to properly store the checkboxes checked by the user. In the image there are only 8 checkboxes but in this scenario there are 30 checkboxes. Do you know how to properly model this context? Thanks!

Rank: #10

Hi Jake,

The data model could look something like this (if I understood your scenario correctly):

The inner line checkbox is selected, if there's a entree in ElementStaticSelected.

I'm not sure if this was the help you were looking for, but if not, please let me know,


Rank: #7206

Thanks, maybe I didnt explain correctly. But every text is static the only thing that the user can do is check or uncheck the checkboxes. So is necessary to store each static text in a regular entity?

Rank: #7206

Its not possible to have only one static entity with every static text´'s? But like that how to store the checked checkboxes?

Rank: #10

I would advise against all static, because in the future you're completely locked to that, and changes will become much harder.

But, following what you mentioned, and without knowing anything else:

Rank: #7206

Thanks, but Im not understanding your model. For example in the web screen all text is static, for example the text "Some text 1" is static, never changes is always "Some text 1" and Im using a text widget to show the text.

The only doubt is how to properly store the checkboxes in this table and show the checked/unchecked checkboxes in the webscreen.

This is only a static table with static text and there are some checkboxes in the table, some checkboxes are associated with some text (static text) like the first checkox associated with "Some Text 1". Other checkboxes are not associated with any text, are the checkboxes that are at left column.

The only thing that the user should be able to do is to check/uncheck the checkboxecs that he wants, the rest of the table layout and text is hard coded html. There is a process (processId) availalbe on this page and when the user checks a checkbox that should be associated with the processId, that is, is necessary to assocaite the checked checkboxes with the processId to know which checkboxes are checked for a given process.

Rank: #10

Even if everything is static, I would still generate the HTML :)

This means that I would dynamically create the whole html based on 1 query (or 2 to be easier) and 2 webblocks (webblock parent in green, nested weblock in blue):

There's an additional advantage, which is, in the "backoffice", you'll be able in a easy way to related the data input by each user /in each process without having to hardcode everything again.

Let me know, if this gets things a bit more clear, or if you need additional help.



Rank: #7206

Thanks and for that approach is using the 4 entities that you said  (StaticSubOption, StaticOption, UserChoiceStaticSubOption, UserChoiceStaticOption)? Can you give an example of which data each entity will have to understand better your approach? 



UserId, CheckBoxId, isChecked.
1, 1, true
1, 2, false
1, 3, true (maybe here is not true or false is the id but then in the web screen which column we associate with each checkbox?)

Rank: #10

Jake, I've been sketching pseudo code, please do not take it the best possible option :)

This said, the data could look like something:

StaticOption (Id, text, order)
[auto number (e.g. 34)], Some Title 1, Text 1, 1
[auto number (e.g. 35)], Some Title 2, Text 2, 2
[auto number], ...

StaticSubOption (Id, StaticOption.Id, text, order)
[auto number (e.g. 12)], 1, Some Text 1, 1
[auto number (e.g. 13)], 1, Some Text 2, 2
[auto number (e.g. 18)], 1, Some Text 3, 3
[auto number (e.g. 10)], 2, Some other Text 1, 1
[auto number (e.g. 11)], 2, Some other Text 2, 2
[auto number (e.g. 37)], 2, Some other Text 3, 3
[auto number], ...

UserStaticOption (Id, StaticOption.Id, User.Id, ProcessId)
[auto number (e.g. 1)], 34, 111, 444
[auto number (e.g. 2)], 35, 111, 444
[auto number (e.g. 3)], 35, 333, 222
[auto number (e.g. 4)], 35, 999, 777
[auto number (e.g. 5)], 36, 999, 777
[auto number (e.g. 6)], 34, 666, 777
[auto number (e.g. 7)], 36, 666, 777
[auto number], ...

UserStaticSubOption (Id, StaticSubOption.Id, User.Id, ProcessId)
[auto number], 12, 111, 444
[auto number], 13, 111, 444
[auto number], 12, 333, 222
[auto number], 12, 999, 777
[auto number], 13, 999, 777
[auto number], 10, 666, 777
[auto number], 13, 666, 777
[auto number], ...

If you have questions, book a slot for us to talk.