faqts : Computers : Programming : Languages : PHP : Database Backed Sites : General : BLOBs (Binary Large Objects)

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

46 of 49 people (94%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Pros and cons of storing text data in file vs. BLOB

May 28th, 2000 09:15
Erik Johansson, Onno Benschop, http://marc.theaimsgroup.com/?l=php-general&m;=92256728003845&w;=2


The pros of each principle from my point of view:
In a file:
 - Quicker transfer of bits and bytes _if_ the files
   can be linked with "a href" or "src=" in the 
   main document, as would be the case with a 
   picture gallery.
 - Easier to make static information cacheable in
   proxies; normally this will be the case without
   further intervention; information served via PHP
   needs special HTTP-headers to be cacheable.
 - Lower memory requirement.
 - Picture sizes are easier to determine if stored
   in a file, due to the GetImageSize function.
 - Rasmus seems to think that storage of pictures
   in BLOBs is bad style per definition ;-)
In a database:
 - Depending on the server configuration: Quicker if
   the pieces of information are included directly
   together on one page as in a guest book page.
 - Less permission problems.
 - With proper DB-design, related pieces of information
   are easily kept up-to-date if the relation is 
   removed/changed.
   Example: Let's say that you have a collection of 
   people, each with user-ID, name (text) and picture
   (blob vs. file):
   If a person is deleted, all information (including
   the picture) is very easily removed if the picture
   is kept as a BLOB in the "people"-table.
 - If text is stored in a text-blob, it's easier to
   search several blobs than to examine several files.