How to relate a table to other two?
There is likely something wrong with your model. Mutual dependencies are very rare in relational database designs. This is what I assume you want to do:

create table photos
( photo_id ... not null primary key
, &lt;additional attributes&gt; );

create table venues
( venue_id ... not null primary key
, photo_id ... not null
      references photos (photo_id) 
, &lt;additional attributes&gt; );

create table products
( product_id ... not null primary key
, photo_id ... not null
      references photos (photo_id) 
, &lt;additional attributes&gt; );


To determine whether a photo belongs to a venue, product or both you could do something like:

select x.photo_id
     , case when y.photo_id is not null then 'Venue' end
     , case when z.photo_id is not null then 'Product' end
from photos x
left join venues y
    on x.photo_id = y.photo_id
left join products z
    on x.photo_id = z.photo_id