I have 2 tables.
Table 1 = Visit (Someone came into the store)
Table 2 = VisitReason (Why they came into the store).
Is there any reason why table 2 could be all boolean fields that get translated into checkboxes in my mvc view?
This would be an alternative to creating a record for every reason for their visit that is associated with the visit.
Thoughts?
(Yes I’m new and learning).
Thanks for any comments.
Think six months in the future. What if you need to add a new reason? Do you add another column? What if the table has 800 million rows by that time? It’s going to take a long time to restructure the table to add that column. Whereas if you add one row per reason, you can add a new reason type at any time.
Imagine the query to answer the question, “show me users who had at least two reasons to come into the store.” That is, any two columns are true. Then extend that to three reasons.
What indexes would you create on this table of N columns to speed up searching for a given reason. One index on each column? What if I want to know about visitors who had two reasons? Now you need one index for each combination of any two reasons.
Is it valid for all the boolean fields to be false? That is, the customer visited but for none of the reasons. If that’s invalid, how would you ensure that at least one is checked as true?