How to store multiple images on server?

467 views Asked by At

Imagine that we have an e-shop. We need to store images connected with products somewhere on server. We already know, that it is better to store images in filesystem and keep the reference in DB.

The question is what is the best way to interconnect images in filesystem with product in DB:

I am thinking about:

  1. keep the reference to unique folder dynamically created for this product in DB (f.e. directly in products table)

  2. create new table in db (something like product_and_images) where we will keep information about product identification and image identification and table will serve for all products

Thanks for all of your answers and sorry for my terrible english :)

1

There are 1 answers

3
undefined_variable On BEST ANSWER

It is always better to maintain separate table and use foreign key reference