clear markdown compare help donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 497198 fiddles created (9426 in the last week).

create table prop(id integer primary key);
 hidden batch(es)


create table objx(id integer primary key);
 hidden batch(es)


create table objy(id integer primary key);
 hidden batch(es)


create table objx_objy( x_id integer references objx , y_id integer references objy , c1_p_id integer not null references prop , c2_p_id integer not null references prop , c3_p_id integer not null references prop , primary key (x_id, y_id) );
 hidden batch(es)


insert into prop(id) select generate_series(90,99);
10 rows affected
 hidden batch(es)


insert into objx(id) select generate_series(10,12);
3 rows affected
 hidden batch(es)


insert into objy(id) select generate_series(20,22);
3 rows affected
 hidden batch(es)


insert into objx_objy(x_id,y_id,c1_p_id,c2_p_id,c3_p_id) select objx.id, objy.id, 90, 91, 90+floor(random()*10) from objx cross join objy;
9 rows affected
 hidden batch(es)


create view objx_objy_prop as select x_id , y_id , unnest(array[1,2,3]) c_id , unnest(array[c1_p_id,c2_p_id,c3_p_id]) p_id from objx_objy;
 hidden batch(es)


select distinct p_id from objx_objy_prop where x_id=10 order by p_id;
p_id
90
91
93
96
98
 hidden batch(es)