Left Join Lateral and array aggregates
问题 I'm using Postgres 9.3. I have two tables T1 and T2 and a n:m relation T1_T2_rel between them. Now I'd like to create a view that in addition to the columns of T1 provides a column that, for each record in T1, contains an array with the primary key ids of all related records of T2. If there are no related entries in T2, corresponding fields of this column shall contain null-values. An abstracted version of my schema would look like this: CREATE TABLE T1 ( t1_id serial primary key, t1_data int