Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It really depends on what you want to do. If you are building a simple browser of local images and have no need for interaction/meta information, then yeah just scan the file system.</p> <p>If this is a shared gallery and you want to be able to name, describe, classify, etc... Then you absolutely need a database.</p> <p>Another thing to consider is, will users be uploading these images? How do you plan on backing them up? Will it be easy for you to access the server's file system? If you need the code and gallery to be very portable and easy to back up, I suggest storing the images in your database in blob columns.</p> <p>The way I would do this is to have three tables.</p> <ol> <li>Image blob table will store the actual image blob with an md5 of the data it contains.</li> <li>Image URL table will store a URL through which image blobs can be accessed.</li> <li>Image data table will store information about each image blob. File type, upload date, who uploaded it, dimensions, file size, title, description, category, tags, etc...</li> </ol> <p>Why separate blob and data? Because your blob table could get very big very fast, and for performance and maintainability it will save you headache to separate it out.</p> <p>Why separate URL from blob/data tables? Because you can have multiple URLs for the same image, without duplicating the image data.</p> <p>Why use MD5 and not just an ID? So you can prevent storing duplicate images, and you can match existing meta information to new images with a known MD5. You shouldn't need to worry about MD5 collisions.</p> <p>Regarding the actual SQL for all this, you need to try to do it first and then ask a specific question if you get stuck. We're not here to write your code :) SQL isn't THAT hard to learn, just spend some time playing with it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload