2

I know this question was asked in various ways here, but none of the answer is conclusive.

I have a system which among other things updates a website gallery. I can both "upload" the file to the website (and save a copy at the system - needed) or just save it in the DB and save the space (and another upload). If I go with the files I would need to "notify" the webpage of every change (picture delete, add or change) instead of just making the change in the DB.

So:

  1. If we are talking about a standard website with a picture gallery, is it best to save the pictures as pictures or in the DB?
  2. If the webpage is very visited or very large, does it makes any difference?

Is the difference that significant? Or just go with the convenient way?

Although I presented my case I would like also to have a "more in general" answer, what is the "good" approach when talking about saving files.

Thanks in advance for clarifying it,

Michel.

4

2 回答 2

0

Only put structured data in a DB. Images are files and should be kept on a files system. The performance of the DB will degrade more and more as the number of pictures / users grows. Instead create an image object which you can use to track the image location and meta data.

于 2012-05-14T09:18:08.347 回答
0

I have had the same problem with you in a previous project of mine.

I decided to go with only storing the path of the image in my database (which is just a string) and save the image in the file system, not in the DB.

This is the best practice in many ways. It keeps your DB small, getting a large amount of rows is faster and DB back ups are significantly smaller.

Just put the images in a file and save the path in the DB so you can retrieve it later.

于 2012-05-14T10:20:04.780 回答