How best to add/remove selections

Certified Associate Developer

I have an interface where a user is able to click on several choices in a checkbox. Each selection is stored as a separate row in a data table that is linked to their user data.  Adding new choices is easy as you just write a new row for that box. Removing them is a bit more tricky. Is there a standard best practice for this row addition/subtraction process? 

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    The "best practice" (IMHO) is to not remove but instead deactivate rows that a user un-selects in this manner (via an "active flag" row or a "removed flag" row, both the same thing except for being opposite in value).  The question then becomes, what happens if a user re-selects previously un-selected rows?  The code is a little trickier but it helps prevent DB rows from getting spammed if you implement a system that looks up any deactivated rows for the current user and marks them as re-activated if they're re-selected (instead of selected for the first time).  IMHO it's worth the time and hassle to implement.

Reply
  • 0
    Certified Lead Developer

    The "best practice" (IMHO) is to not remove but instead deactivate rows that a user un-selects in this manner (via an "active flag" row or a "removed flag" row, both the same thing except for being opposite in value).  The question then becomes, what happens if a user re-selects previously un-selected rows?  The code is a little trickier but it helps prevent DB rows from getting spammed if you implement a system that looks up any deactivated rows for the current user and marks them as re-activated if they're re-selected (instead of selected for the first time).  IMHO it's worth the time and hassle to implement.

Children
No Data