0

I have a Product with many Images. The Product has one main Image.

I'm storing this main Image in a main_image_id column in the Products table.

Everything is working but I am not sure about this design.

ypercubeᵀᴹ
  • 113,259
  • 19
  • 174
  • 235
Theo B
  • 351
  • 1
  • 3
  • 12
  • Which DBMS? See my answer on a similar question for MySQL: **[In SQL, is it OK for two tables to refer to each other?](http://stackoverflow.com/questions/10446641/in-sql-is-it-ok-for-two-tables-to-refer-to-each-other/10458105#10458105)** (and there are links for other DBMS there) – ypercubeᵀᴹ Dec 22 '12 at 09:49
  • Postgres. I'll try the ypercube's fourth approach. A classic third table. – Theo B Dec 22 '12 at 10:15
  • Keep also in mind, **[Erwin's answer here: Complex foreign key constraint in SQLAlchemy](http://stackoverflow.com/questions/8394177/complex-foreign-key-constraint-in-sqlalchemy/8395021#8395021)** This is how it can be done in Postgres, with two tables only and deferrable constaints. – ypercubeᵀᴹ Dec 22 '12 at 10:20
  • I assume that you find your answer in here: [Would you store binary data in database or in file system?](http://stackoverflow.com/questions/662488/would-you-store-binary-data-in-database-or-in-file-system) – Borys Dec 26 '12 at 19:24
  • @Borys - Sorry for the delay. I'm not receiving the email notifications from Stack Overflow. I'm storing just the path for the image, not the binary. – Theo B Apr 23 '13 at 18:09

0 Answers0