June 2010
Intermediate to advanced
328 pages
7h 51m
English
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.
| Jaywalking/anti/create.sql | |
| | 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 one column. However, let’s look at the performance and data integrity problems this table ...
Read now
Unlock full access