Quantcast
Channel: Problem of matching unique or primary key for this column-list - Stack Overflow
Viewing all articles
Browse latest Browse all 3

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

$
0
0

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 :

enter image description here

The underline words are primary key


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>