Antipattern: Create Multiple Columns
Let's create multiple columns for multi-column attributes.
We'll cover the following...
We still have to account for multiple values in the attribute, but we know that the new solution must store only a single value in each column. It may seem natural to create multiple columns in this table, each containing a single tag.
As we assign tags to a given bug, we’d put values in one of these three columns. Unused columns would remain null.
Let’s try to retrieve the Bugs table data after updating the value of tag2. Press “RUN” in the following playground and see the output.
Tasks we could do easily with a normal attribute are now more complex.
Searching for values
When searching for bugs with a given tag, we must search all three columns because the tag string could occupy any of these columns.
If we’re searching for a given value across multiple columns, it is a clue that the multiple columns should be stored as a single logical attribute.
For example, to retrieve bugs that reference performance, ...