So I’ve got this form with an array of checkboxes to search for an event. When you create an event, you choose one or more of the checkboxes and then the event gets created with these “attributes”. What is the best way to store it in a MySQL database if I want to filter results when searching for these events? Would creating several columns with boolean values be the best way? Or possibly a new table with the checkbox values only?
I’m pretty sure selializing is out of the question because I wouldn’t be able to query the selialized string for whether the checkbox was ticked or not, right?
Thanks
You can use the
setdatatype or a separate table that you join. Either will work.I would not do a bunch of columns though.
You can search the set easily using
FIND_IN_SET(), but it’s not indexed, so it depends on how many rows you expect (up to a few thousand is probably OK – it’s a very fast search).The normal solution is a separate table with one column being the ID of the event, and the second column being the attribute using the
enumdatatype (don’t use text, it’s slower).