Re: Partition table with a foreign key self-reference

From: Juan Rincon Gonzalez <juanrincongonzalez347(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Oliver Urones <ourones(dot)joinup(at)gmail(dot)com>, pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Partition table with a foreign key self-reference
Date: 2025-02-05 10:25:46
Message-ID: CADXkp2rYdY=gm=jtVs57Ghw9V_dRUtHhUf=7b7vTik2ZyJgQJg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I can't help if am not present I need to follow rules
Juan Rincon

On Tue, Feb 4, 2025, 11:18 PM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:

> On Tue, 2025-02-04 at 16:57 +0100, Oliver Urones wrote:
> > 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.
>
> The question makes no sense as such. You'd have to tell us the purpose
> you want to achieve with partitioning. Depending on that, you'd choose
> the partitioning strategy and the partitioning key.
>
> At any rate, you'll probably have to drop the foreign key constraint
> unless your partitioning key is "id".
>
> Yours,
> Laurenz Albe
>
>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Mendbayar Alzakhgui 2025-02-07 06:04:10 Postgresql replication failed in Patroni
Previous Message Laurenz Albe 2025-02-05 07:18:02 Re: Partition table with a foreign key self-reference