开发者

Photos Gallery - Database Design

This is my database design on photo gallery, I like feedback please or what can it be i开发者_如何学Pythonmproved?

photos_category
- photocat_id (P)
- name
- slug
(5, 'Cars', 'cars')



photos_albums
- album_id (P)
- photocat_id (F)
- name
- description
- active
(20,5,'BMW','Nice BMW cars',1)

photos
- photos_id (P)
- album_id (F)
- image
(33,20,'bmw_car4.jpg')

bmw_car4.jpg is original size and it will be located at: /gallery/original/bmw_car4.jpg

For frontend (resized):

Thumbnail: /gallery/thumbs/bmw_car4.jpg

Image: /gallery/images/bmw_car4.jpg


Your design seems quite correct to me :

  • it's simple and functionnal,
  • there is no duplication of information,
  • and you can, from one object, find its related informations


I would just, if you plan on having a lot of photos, add some kind of sub-directories scheme, to avoid having too many files in a single directory (/gallery/original/, and the directories for resized images).

You could add some hashing mecanism, based on the upload date (month or day, depending on the amount of images) of the images, or something like that.
For example, you could have :

  • /gallery/original/2011/01/ : all images uploaded in january
  • /gallery/original/2011/02/ : all images uploaded in february
  • and so on

Then, you'll store the path in your photos table, and not only the file's name.


Ooooh! Absolute must is to include a field in your image table that stores doctype. Its very handy for image retrieval and also if you forget to limit what files get uploaded, you can see at a glance which types are being uploaded that you don't want in there, and also which types you want to support and currently don't. I had people uploading word documents containing images you see, and I thought, "What the hey" and added support for them. Storing files outside the database is a great idea. I made the mistake of alt, name, description, created, last-modified in there when I used a database to actually store the images themselves, and the content size of the image data meant that getting the results was VERY SLOW. You've done a great job.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜