Question

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 :)

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top