Q
Q
Quber2014-06-02 09:13:09
PHP
Quber, 2014-06-02 09:13:09

Should I create a separate table for images in the database?

Suppose there are several tables - Categories, Posts, Reviews, Photo Album, Partners, News, Articles, Events and so on. An image must be attached to each entry for each of the tables. Should I create a separate table with pictures for this? It can be linked to other tables + you can store a description of the picture in it. Or is it a stupid idea?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Kuleshov, 2014-06-02
@Quber

Pictures - a separate table, definitely! Normalization, indexing, optimization!

S
svd71, 2014-06-02
@svd71

In fact, pictures are such a resource that it is better not to mess with the engine unnecessarily. It will easily affect performance. It is much better to store a description of the image in a separate table in the database (path to the file, title, etc., etc.), but physically store the image on disk. With the file system, image display operations will be much faster.

A
Alexander Kubintsev, 2014-06-02
@akubintsev

In the vast majority of cases, it is best to store the file name in the database, and not the picture itself. This is a much more efficient solution. The only case that comes to mind when storing in a database makes sense is when there are several backends, but there is no dedicated file storage and you don’t want to bother with file synchronization.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question