bir başka yöntem,
direk ürün tablosunda resim alanını jsonb türünden ayarlayınız.
sonra bu alana ilgili tüm resimleri json array olarak koyunuz. Böylece hem başka bir tabloda sorgu yapmanıza gerek de kalmaz.
İhtiyacınız olmadığı zaman select etmezsiniz, olduğu zaman select edersiniz. JSON alanının nimetlerinden faydalanmak lazım.
Hatta biz json ın içinde farklı boyutlardaki resimleri de tutuyoruz. db de json sorgusu yapabiliyoruz. mesela sadece küçük resimleri seç gibi. hatta bu json alanını modelde array olarak cast ederek rahatlığınıza rahatlık da katabilirsiniz.
örnek json aşağıdaki gibi.
[
{
"small_image": {
"size": 11998,
"width": 449,
"height": 300,
"local_url": "619ee84d-c4fd-4c15-bf4c-a4e9ee6ba88b/properties/photos/820/300x300/DSC_0003.jpg"
},
"medium_image": {
"size": 27410,
"width": 748,
"height": 500,
"local_url": "619ee84d-c4fd-4c15-bf4c-a4e9ee6ba88b/properties/photos/820/500x500/DSC_0003.jpg"
},
"large_image": {
"size": 56614,
"width": 800,
"height": 535,
"local_url": "619ee84d-c4fd-4c15-bf4c-a4e9ee6ba88b/properties/photos/820/w_800/DSC_0003.jpg"
}
},
{
"small_image": {
"size": 11998,
"width": 449,
"height": 300,
"local_url": "619ee84d-c4fd-4c15-bf4c-a4e9ee6ba88b/properties/photos/820/300x300/DSC_0004.jpg"
},
"medium_image": {
"size": 27410,
"width": 748,
"height": 500,
"local_url": "619ee84d-c4fd-4c15-bf4c-a4e9ee6ba88b/properties/photos/820/500x500/DSC_0004.jpg"
},
"large_image": {
"size": 56614,
"width": 800,
"height": 535,
"local_url": "619ee84d-c4fd-4c15-bf4c-a4e9ee6ba88b/properties/photos/820/w_800/DSC_0004.jpg"
}
},
{
"small_image": {
"size": 11998,
"width": 449,
"height": 300,
"local_url": "619ee84d-c4fd-4c15-bf4c-a4e9ee6ba88b/properties/photos/820/300x300/DSC_0005.jpg"
},
"medium_image": {
"size": 27410,
"width": 748,
"height": 500,
"local_url": "619ee84d-c4fd-4c15-bf4c-a4e9ee6ba88b/properties/photos/820/500x500/DSC_0005.jpg"
},
"large_image": {
"size": 56614,
"width": 800,
"height": 535,
"local_url": "619ee84d-c4fd-4c15-bf4c-a4e9ee6ba88b/properties/photos/820/w_800/DSC_0005.jpg"
}
}
]