Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

Is there a workaround for the lack of foreign keys constraint to a partitioned table in PostgreSQL?

$
0
0

I have a big table A (~30 million lines) at the core of my model. Another table B has a foreign key referencing A. I would like to partition A using the well-known inheritance hack.

Is there a manageable way to have a foreign key constraint in table B so that every line in B is constrained to reference an existing line in A? (You know, a foreign key constraint.)

I am actually considering dropping this constraint as I see no other solution. Is there?

edit

I believe I can have a foreign key constraint from B to A but it is useless since when inserting into A, the line would go into a sub-table instead and would never be found by the constraint. Is it correct?


Viewing all articles
Browse latest Browse all 1138

Trending Articles