How to make column with ARRAY(Integer) type, where each integer is primary key from some other table? If it's impossible, how to achieve similar table relationships with other method?
Not possible, but might be in the future. Foreign Key Arrays is a work in progress in PostgreSQL. Alternatively, you can do the usual approach of creating a junction(or join) table for this.
A foreign key in SQL is a table-level construct that constrains one or more columns in that table to only allow values that are present in a different set of columns, typically but not always located on a different table.
As of PostgreSQL 9.3, this is not implemented, see http://blog.2ndquadrant.com/postgresql-9-3-development-array-element-foreign-keys/ One should turn array into other table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With