create table products (
id int primary key generated always as identity,
name text
);
insert into products (name) values ('Товар 1');
create table products_photos (
id int primary key generated always as identity,
product_id int references products (id),
url text
);
insert into products_photos (product_id, url) values (1, 'example1.png'), (1, 'example2.png');
select products.id, products.name, jsonb_agg(url)
from products
left join products_photos on products.id = product_id
group by products.id, products.name