Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

604
Vistas
How to add Foreign key constraint on array in PostgreSQL?

How to add Foreign key constraint on array in PostgreSQL?

look_up table for roles

CREATE TABLE party_role_cd
(
  party_role_cd bigint NOT NULL,
  code character varying(80) NOT NULL,
  CONSTRAINT party_role_cd PRIMARY KEY (party_role_cd)
);

Party can have zero or many roles [ 0-N relationship ]

CREATE TABLE party
(
  party_id biging NOT NULL,
  party_role_cd bigint[] NOT NULL,
  CONSTRAINT party_id PRIMARY KEY (party_id)
);

How to add the foreign key constraint for party_role_cd array in party table?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

That's not implemented in PostgreSQL. Currently, FK constraints only operate on equality between whole column values. No array-to-element references. There is an open TODO item that has been added in 2010. See:

  • https://wiki.postgresql.org/wiki/Todo#Referential_Integrity
  • https://www.postgresql.org/message-id/1288033876.6278.6.camel@vanquo.pezone.net

There were even attempts to implement it, but never to completion.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda