Bonjour,

J'ai une table produits ainsi que deux autres tables héritant de produits :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
CREATE TABLE PRODUITS (
    idProduit serial NOT NULL,
    nom character varying(100) NOT NULL,
    description character varying(255),
    annee integer,
    prixvente real NOT NULL,
    PRIMARY KEY (idVO),
    UNIQUE (idVO)
);
 
CREATE TABLE DVD (
    collection character varying(50),
    producteur character varying(50)
) INHERITS (produits);
 
CREATE TABLE POSSEDER
(
    idProduit int4 NOT NULL REFERENCES PRODUITS ON UPDATE CASCADE ON DELETE RESTRICT,
    qte int4 NOT NULL,
    prix real NOT NULL
  PRIMARY KEY (idProduit)
);
Mon problème est que je peux insérér une nouvelle entrée dans ma table posseder si idProduit est un id de la table mère mais
ça marche pas quand c'est celui d'une des table fille,
PostGreSQL me marque :
ERROR: insert or update on table "posseder" violates foreign key constraint "posseder_idproduit_fkey"
DETAIL: Key (idvo)=(2) is not present in table "produits".
Comment est-ce que je peux régler ce problème ?

Merci d'avance.