is it possible to have multiple variables in one column for when someone does a checkbox search? Let’s say the checkboxes are like this:
Music to dance to:
1.Oldies
2.Reggae
3.pop
4.house
And let’s say there’s a table by the name of ‘Events’, and one of the columns is music.
Can the column somehow contain let’s say, 1,3,4 which would be searched for if someone selects checkboxes 1,3 or 4 it would return this row?
Thanks 🙂
What you describe is a many-to-many relationship. This means there can be many events, and each event can have several styles of music covered. On the other hand, a style of music can be represented on many events.
Generally, you can express these kinds of relationships with a helper table and two different tables for ‘Event’ and ‘Music’: Assume ‘Event’ has a primary key id and so does ‘Music’, but there is no column in either ‘Music’ or ‘Event’ referencing each other. Instead, to set up a link between them, you would create a third table ‘Event_Music’ with columns ‘event_id’ and ‘music_id’. Consider this example:
This tells you that there is going to be Event A with oldies and pop and there is going to be Event C with only house music.