Quantcast
Viewing latest article 3
Browse Latest Browse All 3

Problem of matching unique or primary key for this column-list

I have work to do in SQL, and I have a problem about the referencing of a key. So I have two tables:

CREATE TABLE Surveillances(    NumEns NUMERIC(10) REFERENCES Enseignants,    DateHeureDebut TIMESTAMP(0),    NumSal NUMERIC(4) REFERENCES Salles,    PRIMARY KEY(NumEns, DateHeureDebut));
CREATE TABLE Horaires(    NumEpr NUMERIC(10) REFERENCES Epreuves,    DateHeureDebut TIMESTAMP(0) REFERENCES Surveillances,    PRIMARY KEY(NumEpr));

I already created the table Surveillances, but when I try to create the table Horaires, this error appears

Error report -

ORA-02270: no matching unique or primary key for this column-list.

I find out that the problem comes from the key DateHeureDebut which is a primary key in the table Surveillances, but not in Horaires.

I tried to modify my Horaires table, but that didn't work:

CREATE TABLE Horaires(    NumEpr NUMERIC(10) REFERENCES Epreuves,    DateHeureDebut TIMESTAMP(0),    PRIMARY KEY(NumEpr),    FOREIGN KEY(DateHeureDebut) FROM Surveillances(DateHeureDebut));

I just tried this :

CREATE TABLE Horaires(    NumEpr NUMERIC(10) REFERENCES Epreuves,    DateHeureDebut TIMESTAMP(0),    NumEns NUMERIC(10),    PRIMARY KEY(NumEpr),    FOREIGN KEY(NumEns, DateHeureDebut) REFERENCES Surveillances(NumEns, DateHeureDebut));

And it works, I mean no error, but in the Horaires table there is no NumEns key.

I have to follow this schema :

Image may be NSFW.
Clik here to view.
enter image description here

The underline words are primary key


Viewing latest article 3
Browse Latest Browse All 3

Trending Articles