Foreign Keys Snippets

Handy snippets to help you set up Postgres to work with Whalesync

Whalesync supports foreign keys. After creating your tables, you can designate a foreign key and then point it to another table's primary key.

ALTER TABLE public."Table"
ADD CONSTRAINT table_category_fkey
FOREIGN KEY ("category")
REFERENCES categories("name");

In the example above we are adding to a table called "Table" to an existing column called "category" a foreign key pointing to column called "name" in a table called "categories". The example creates the foreign key relationship, it does not create any tables and columns, they must already all exist.

Last updated