Multiple foreign keys in a single field
Sync an Airtable linked record field to Postgres or Supabase using a uuid[] array column named as a foreign key array, such as People_fk_Contacts.
About foreign key arrays
Section titled “About foreign key arrays”Unfortunately, Postgres (including Supabase) does not support arrays of foreign keys. Some of the other apps we connect with (e.g. Airtable) do, so we've tried to build a workaround for this. With this workaround you'll be able to sync Airtable linked records with a fake Postgres foreign key array.
How it works
Section titled “How it works”At a high-level, you can configure a Postgres/Supabase column to be an array BUT signal to Whalesync that you'd like us to treat it as a foreign key array.
Since Postgres just sees this as an array, the field no longer has the same validation, but it will sync.
How do I implement this?
Section titled “How do I implement this?”Imagine you have two tables:
- Contacts
- Company
To create a foreign key array you can:
-
Ensure both tables have a primary key (e.g. uuid)
-
In Company, create an array column "People_fk_Contacts" with type uuid[] to match the type of the table id.
- The "_fk" designates to Whalesync that you want this to be a foreign key.
- The "_Contacts" designates that it should point to the Contacts table.
(*note - must match capitalization)
-
Set up your sync in Whalesync as normal, mapping your fields.
Example snippet
Section titled “Example snippet”CREATE TABLE public."Contacts" ("id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),"Email" text );
CREATE TABLE public."Company" ("id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),"Name" text,"People_fk_Contacts" uuid[] );