# Multiple foreign keys in a single field

### **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**

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.

{% hint style="info" %}
**Note:** a bad value here will not break Whalesync, that value will simply not sync until you correct it.
{% endhint %}

### **How do I implement this?**

Imagine you have two tables:

* Contacts
* Company

To create a foreign key array you can:

1. Ensure both tables have a primary key (e.g. uuid)
2. In Company, create an array column "People\_fk\_Contacts" with type uuid\[] to match the type of the table id.

   1. The "\_fk" designates to Whalesync that you want this to be a foreign key.
   2. The "\_Contacts" designates that it should point to the Contacts table.

   (\*note - must match capitlization)
3. Set up your sync in Whalesync as normal, mapping your fields.

### **Example snippet**

```sql
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[] );
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.whalesync.com/connectors/postgres/multiple-foreign-keys-in-a-single-field.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
