The following query is executed by the current executor of the table to retrieve the table references:
regexp_replace(att1.attname, '_'||att2.attname||'$', '')
,cl1.relname as "foreignTable"
,att1.attname as "foreignColumn"
,cl2.relname as "referencedTable"
,att2.attname as "referencedColumn"
cl1.relname = \$1
and co.confrelid != 0
and co.conrelid = cl1.oid
and co.conkey = att1.attnum and cl1.oid = att1.attrelid
and co.confrelid = cl2.oid
and co.confkey = att2.attnum and cl2.oid = att2.attrelid
Relations can be accessed as virtual properties or through pq\Gateway\Table\Relations::getReference().
$relations = new Table\Relations(new Table("account_email"));
The relation name is the column name of the foreign key with the column name of the referenced column cut off the end.
Retrieve the table's relations (foreign keys).
Retrieve the foreign key of the table to another table.