Depending on your choice of RDBMS, you may find it is advantageous. Your application, and the planned development thereof, would also influence your decision.

It would be fairly trivial to write a Java or VB client for your DB, and it could view the images by retrieving them from the DB quite easily. However, if these were stored in some alternate method (a.k.a. files on disk), then you would need to use HTTP or some other mechanism to transport them, which would be more complicated.

Retrieval Time
Remember that after you put 10,000 images in a single directory, your OS may have trouble looking up filenames. Quite often these directories are not indexed, so finding a file takes, to put it in math terms, O(n) time, which is, to put it in simple English, really awful. You may find that a simple lookup in a large directory could take 1-2 seconds. In a properly indexed DB, retrieval time should always be fairly quick.

Of course, you can always get around this by sorting your images into different directories using a hash-technique, or some creative variation. 100 directories with 100 files each is much, much faster than 10,000 files in a single directory. The downside is more programming.

Storage Space
Your DB might actually be a better way to store images than your filesystem, if the block sizes for "BLOB" fields are small enough. It is not uncommon to see people using 64K blocks, which means that a 2K GIF image actually uses 64K of disk space. A lot of tiny images can fill up a disk, even though their aggregate size is much smaller. A DB with a 1K block would actually save disk space.

Of course, if you were planning ahead, you could format your filesystem with the appropriate block size, if your OS allows for such a thing (i.e. mkfs -b 1024). This, though, is a lot of work for something that should be quite easy.

Access Control
Implementing a DB-level access control, especially using an RDBMS's own methods, is fairly easy. Reimplementing this on the filesystem level can be quite tricky, especially if system accounts are involved.

Your decision should be based on careful analysis of your immediate and planned requirements. The DB solution works, and the filesystem one does too. Personally, if you want a more "elegant" solution, the DB route does keep things much more managable, since in effect you can query your filesystem.

In reply to Re: Is it a good idea to store images in a RDBMS? by tadman
in thread Is it a good idea to store images in a RDBMS? by Coyote

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.