June 2010
Intermediate to advanced
328 pages
7h 51m
English
If any of the issues described in the “Antipattern” section of this chapter apply to you, you should consider storing images inside the database instead of in external files. All database brands support the BLOB data type, which you can use to store any binary data.
| Phantom-Files/soln/create-screenshots.sql | |
| | CREATE TABLE Screenshots ( |
| | bug_id BIGINT UNSIGNED NOT NULL, |
| | image_id BIGINT UNSIGNED NOT NULL, |
| | screenshot_image BLOB, |
| | caption VARCHAR(100), |
| | PRIMARY KEY (bug_id, image_id), |
| | FOREIGN KEY (bug_id) REFERENCES Bugs(bug_id) |
| | ); |
If you store an image in this way in a BLOB column, all the issues are solved:
The image data is stored in the database. There is no extra ...
Read now
Unlock full access