Image gallery system - which approach is better?

I am implementing an image loading system in PHP, the following is required:

  • Enter categories
  • Allow users to comment on images
  • Allow image rating

For this, I have 2 approaches:

1. Implement folder categorization

Each category will have its own folder, and PHP will define categories through these folders.

Pros

  • Structured appearance, easily placed images.
  • Using PHP's built-in functions to manage and collect information about folders and files

Against

  • Multiple categorization is pain.
  • You must save the full path in the database

2. Introduce database categorization

Each image in the database will have a catID (or several catIDs), and PHP will query the database to get the images

Pros

  • .

, ? , , ?

, , , , , .

.

+5
6

: .

. !

0

, , DB , , , , . , .

, Db , , db, , , , , , , db , , .
, , , :

  • , , , (, , ), , "/web_path/uploaded_photos/week4_2012/[some_generated_string].jpg"
  • , , , MD5 , , "photo_2012.jpg" "c02d73bb3219be105159ac8e38ebdac2", "/web_path/uploaded_photos/c/0/[some_generated_string].jpg"

, , , , .

.

PS , , .

+3

. , con, . , , , , , PHP , , SQL-?

, - , BLOBS , , () . , , , .

+2

( ) TAG/LABEL. , - Gmail Stackoverflow. , , , . , .

+2

, , ..

/b/e/beach001.jpg

, .
, .

+1

, . ; . , .

, .

: ; . . , , .. :

: /

/uploaded_images
    /2010/01
    /2010/02

: -

/uploaded_images
    /2010-01
    /2010-02

md5 hash of the image name: first character

/uploaded_images
    /0/
    /1/
    .
    .
    .
    /e/
    /f/

party of thousands

/uploaded_images
    /00001000/
    /00002000/
    /00003000/
+1
source

All Articles