Antipattern: Format Comma-Separated Lists
To minimize changes to the database structure, you decide to redefine the account_id column as a VARCHAR so you can list multiple account IDs in that column, separated by commas.
â | âCREATEâ âTABLEâ Products ( |
â | product_id âSERIALâ âPRIMARYâ âKEYâ, |
â | product_name âVARCHARâ(1000), |
â | account_id âVARCHARâ(100), â-- comma-separated listâ |
â | â-- . . .â |
â | ); |
â | |
â | âINSERTâ âINTOâ Products (product_id, product_name, account_id) |
â | âVALUESâ (âDEFAULTâ, â'Visual TurboBuilder'â, â'12,34'â); |
This seems like a win, because youâve created no additional tables or columns; youâve changed the data type of only ...
Get SQL Antipatterns, Volume 1 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.