On Thu, 26 Feb 2004 23:42:48 +0000, "cover" <du*******@bigfoot.com> wrote:
The question is,
we have two options to store images, either in a Database (MySQL,
Postgres, ...) like blob data, or in the hard disk the file and the path in database.
Which option is better? When? Why?
Thanks you for your answers.
Database:
+ Files get same transactional integrity guarantees as all other data.
+ Only one thing to back up; the database, easy to keep consistent.
- Requires a database that handles BLOB data well. YMMV, depends on DB.
- Greatly increases data throughput in and out the database.
Filesystem:
+ Web server and browsers can use caching more effectively.
+ Less load on the database.
- Complicated to keep consistency; if you rollback an UPDATE of the database,
or it crashes, how do you keep that in sync with the filesystem?
- Similarly with backups - you have to keep them in sync somehow.
Or you could go for a hybrid; the database being the master for the data,
stored in a BLOB, but it's written out to a file on disk on demand for easy
access by the webserver. When doing a backup, ignore the cache, just backup the
database - everything stays consistent. When doing a restore, wipe out the
cache, and let it repopulate itself on the next accesses.
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>