Partition table with a foreign key self-reference

From: Oliver Urones <ourones(dot)joinup(at)gmail(dot)com>
To: pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Partition table with a foreign key self-reference
Date: 2025-02-04 15:57:55
Message-ID: CAH2eNKX7wg7mZYr6jt4c6iZey6HYQUY-3DLPJMT3wWqy1gNFmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hello.

I need help with the process of partitioning tables.

How can I partition a table that has a foreign key that references itself?

Something like this example:

CREATE TABLE employees (
employee_id SERIAL PRIMARY KEY,
name VARCHAR(50),
boss_id INTEGER,
CONSTRAINT fk_boss FOREIGN KEY (boss_id) REFERENCES
employees(employee_id)
);

I'm using Postgresql 14.

Thanks!

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Laurenz Albe 2025-02-05 07:18:02 Re: Partition table with a foreign key self-reference
Previous Message Benoit Lobréau 2025-02-04 15:22:45 Re: Commit with wait event on advisory lock!