Fix guide · updated 2026-11-16
Supabase "Could not find a relationship" error (PGRST200)
{"code":"PGRST200","details":"Searched for a foreign key relationship between 'orders' and 'profiles' in the schema 'public', but no matches were found.","hint":null,"message":"Could not find a relationship between 'orders' and 'profiles' in the schema cache"}
A query that reads a table together with a related one, like select('*, profiles(name)'), fails with "Could not find a relationship between 'orders' and 'profiles' in the schema cache", code PGRST200, HTTP 400. To put one table inside another, Supabase follows a foreign key between them, and it found none. We reproduced each cause on Supabase's Data API (PostgREST 13, November 2026).
What the error means
Supabase doesn't join tables on matching column names. It needs a declared foreign key between the two tables, in a schema the API can see, and it reads those keys from its "schema cache". In our test, the error came back in four situations, one per section below.
1. No foreign key between the tables
orders.customer_id holds profile ids, but nothing declares it as a foreign key. Add one, in the SQL Editor:
alter table public.orders
add constraint orders_customer_id_fkey foreign key (customer_id) references public.profiles (id);
It fails if some customer_id values don't exist in profiles: fix or remove those rows first. In our test, the same query worked once the key existed.
2. The other table is auth.users
select('*, users(*)') answered "Could not find a relationship between 'messages' and 'users'" in our test. The Data API only sees the schemas it exposes, public by default, and auth isn't one of them, so auth.users can't be embedded. Keep what your app shows about people in a public.profiles table whose id references auth.users, point your foreign keys at public.profiles, and embed profiles.
3. A misspelled table name
The name inside select() must be the table's exact name. In our test, profile(*) for a table named profiles failed, and the hint said so: "Perhaps you meant 'profiles' instead of 'profile'." Check error.hint first.
4. A key you just added isn't in the cache yet
The API keeps the list of keys in memory. On Supabase, creating or changing a table refreshes it by itself: Supabase's Postgres has an event trigger, pgrst_ddl_watch, that sends the reload. If a key you just added is still not found after a few seconds, reload the cache yourself:
notify pgrst, 'reload schema';
In our test, without the automatic reload, the query still failed right after the key was added, and worked after that line.
If an AI tool built your app
Give your AI tool this prompt, with your own tables:
This Supabase query fails with PGRST200: Could not find a relationship between 'orders' and 'profiles' in the schema cache. Write a SQL migration that adds a foreign key from orders.customer_id to public.profiles(id), and first check that every customer_id exists in profiles. If a query embeds users from auth.users, embed public.profiles instead. Don't change anything else.
Not quite your error?
- "Could not embed because more than one relationship was found" (PGRST201): Supabase "Could not embed because more than one relationship was found" (PGRST201).
- "Could not find the table … in the schema cache": Supabase "Could not find the table in the schema cache" (PGRST205).
- "Could not find the '…' column of '…' in the schema cache": Supabase "Could not find the column in the schema cache" (PGRST204).
Still stuck?
List the foreign keys on your table, in the SQL Editor:
select conname, pg_get_constraintdef(oid) from pg_constraint
where conrelid = 'public.orders'::regclass and contype = 'f';
If no row references the table you're embedding, there's no relationship for Supabase to follow: go back to section 1.
Other Supabase problems? See Supabase fixes.