Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2007
    Posts
    219
    Thanks
    25
    Thanked 1 Time in 1 Post

    exif in db or on the fly ?

    Together with some friends i'm making a simple 'flickr' website, where people can upload their pictures.

    On this site we also want to display some exif data (photo information), which can be extracted from the photo's themself. There are two way's I can do this:

    Option 1:
    When the user uploads a picture, my php script will obtain the exif data and write it in the database. When a visitor comes accross the picture the exif data will be retrieved from the db.

    Option 2:
    When a visitor comes accross the picture, the exif information is being pulled from the photo on the fly.

    Which of both options would be more efficient (faster), when a couple of hundreds/thousands of photo's will be viewed every day ?

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    I would say option 1.

    My opinion is based on the ability to 'filter' or 'search' the database by specific exif data.
    The CPU is already querying for the photo, the exif data would just be adding more to the array.

    Whether to store the photos in a directory and the filenames in the database VS storing the actual photos (BLOB) in the database is another issue. My opinion is the photos in a directory, but only because that is most familiar to me. We'll see if someone else has some advice that is more scientific.

    One might question if PHP/MySQL is the best option for a 'Flickr' type of website. Maybe Perl is better, or ASP, or something running on your own private server? And MySQL may not be the best database to use? You might want to investigate that further before settling on PHP/MySQL ... "MySQLi" to be specific.



    .
    Last edited by mlseim; 12-16-2013 at 08:41 PM.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by mlseim View Post
    Whether to store the photos in a directory and the filenames in the database VS storing the actual photos (BLOB) in the database is another issue. My opinion is the photos in a directory, but only because that is most familiar to me. We'll see if someone else has some advice that is more scientific..
    There are a range of things that need to be considered when determining which way to go with storing the images. With smaller systems maintaining the images outside the database is not a big concern. With larger systems - particularly once you start using transaction processing with the database where you want updates to be backed out if later updates fail then including the image in the database where it can be processed as part of the transaction may be the deciding factor. In some cases storing the image in both places may be the solution.

    There's one system I am working on where everything those using the site do currently gets stored in the database except for the images that they upload. I am considering storing a copy of the images in the database itself simply because the database gets backed up regularly online whereas the rest of the site content doesn't get backed up online because I already have multiple copies backed up on my system.

    Storing images outside the database is one of the Anti-patterns that the book "SQL Anti-Patterns" http://pragprog.com/book/bksqla/sql-antipatterns warns against and gives a few reasons why you would and a lot more why you wouldn't. I think the pros and cons are a little more evenly matched with this one than that book suggests and that there are a number of legitimate reasons for keeping images outside the database.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    I agree that it's confusing and I'm not very experienced at answering about the image storage. That wasn't the original question, but I think it's more important than the exif question. It is something to research for sure.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •