P粉9482589582023-08-28 11:49:53
"One of the reasons is laziness."
This is a wake-up call. The only reason you should do something like this is if you know how to do it "the right way", but you conclude there is a solid reason not to do it.
Having said that: If the data you choose to store this way is data you will never need to query, then there may be a case for storing it the way you choose.
(Some users will take issue with my statement in the previous paragraph, saying "you never know what requirements may be added in the future". These users are either misinformed or state religious beliefs. Sometimes, hard work is advantageous in front of you Require.)
P粉5459565972023-08-28 09:02:45
In addition to violating First Normal Form, there are many other more practical problems with duplicate group value columns, comma separated lists stored in a single value:
idlist REGEXP '[[:<:]]2[[:>:]]'
Or in MySQL 8.0: idlist REGEXP '\\b2\\b'
李>
To solve these problems, you have to write a lot of application code and reinvent the more efficient features that RDBMS already provides.
The comma-separated list is wrong, and I made it the first chapter in my book: SQL Anti-Patterns, Volume 1: Avoiding the Pitfalls of Database Programming.
Sometimes you need to denormalize, but as @OMG Ponies mentioned, these are exceptions. Any non-relational "optimization" will benefit one type of query at the expense of other uses of the data, so make sure you know which queries need special handling so that they are worthy of denormalization.