Until now, I wanted to keep those comma separated lists in my SQL db – well aware of all warnings!
I kept thinking that they have benefits over lookup tables (which provide a way to a normalized data base). After some days of refusing, I’ve seen the light:
- Using lookup tables is NOT causing more code than those ugly string operations when using comma separated values in one field.
- The lookup table allows for native number formats and is thus NOT bigger than those csv fields. It is SMALLER though.
- The involved string operations are slim in high level language code (SQL and PHP), but expensive compared to using arrays of integers.
- Databases are not meant to be human readable, and it is mostly stupid to try to stick to structures due to their readability / direct editability, as I did.
In short, there is a reason why there is no native SPLIT() function in MySQL.