Storing Binary Image data in a mySql

Discussion in 'OT Technology' started by Swak, Jan 15, 2007.

  1. Swak

    Swak Artificially known as ObsoleteAsian

    Joined:
    Jun 3, 2004
    Messages:
    18,996
    Likes Received:
    0
    Location:
    Chatsworth, California
    This is a bad idea huh. I wrote a small uploader that does it and writes the binary data of the photos to a database. I should probably have it save the picture in a folder and mysql write a link to that file. Please point out pros and cons of what i did.
     
  2. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    It won't make much difference to the database's search engine whether the image is linked or stored internally, because databases all use pointers anyway; it's not like the search engine will actually have to traverse across enormous data fields with images in them to get to the next recordset.

    However, unless the image is compressed, the data file itself will get enormous and will become very hard to defragment. If you want to make your little uploader a little more sexy, you can link it to ZLIB.DLL (you can get it online for free) and have it feed the binary data through its compression function before storing it in your database.

    Of course, compressing the data will only help with bloat to a certain extent. You'll just have to decide whether it's more advantageous for database users to be able to retrieve images directly using a program on their computers that can read your binary image data, or whether you prefer the idea of having a smaller database file that relies upon Windows' file-sharing capabilities to let users download images via the links your database maintains.
     
  3. Swak

    Swak Artificially known as ObsoleteAsian

    Joined:
    Jun 3, 2004
    Messages:
    18,996
    Likes Received:
    0
    Location:
    Chatsworth, California
    Ahhh.. awesome ok thanks. I will do some research on what you said. :)
     

Share This Page