How to modify it sql road rally table CREATE TABLE RoadRally

How to modify it? sql

--road rally table
CREATE TABLE RoadRally
        (EventDate DATE NOT NULL,
        PhoneNum NUMERIC,
CONSTRAINT RoadRally_PK PRIMARY KEY (EventDate));

--start gdp is a multivalue attribute of road rally
CREATE TABLE StartGdp
        (Latitude FLOAT NOT NULL,
        Longitude FLOAT NOT NULL,
        EventDate DATE,
CONSTRAINT StartGdp_PK PRIMARY KEY(Latitude, Longitude),
CONSTRAINT StartGdp_FK FOREIGN KEY(EventDate) REFERENCES RoadRally(EventDate));

--end gdp is a multivalue attribute of road rally
CREATE TABLE EndGdp
        (Latitude FLOAT NOT NULL,
        Longitude FLOAT NOT NULL,
        EventDate DATE,
CONSTRAINT EndGdp_PK PRIMARY KEY(Latitude, Longitude),
CONSTRAINT EndGdp_FK FOREIGN KEY(EventDate) REFERENCES RoadRally(EventDate));

--person table
CREATE TABLE Person
        (PersonId NUMERIC NOT NULL,
        CellNum NUMERIC(6,0),
        NumTop3Finish NUMERIC,
CONSTRAINT Person_PK PRIMARY KEY (PersonId));

--clue table
CREATE TABLE Clue
        (ClueId NUMERIC NOT NULL,
        CluePrompt VARCHAR2(100),
CONSTRAINT Clue_PK PRIMARY KEY (ClueId));

--answer is a multivalue attribute of clue
CREATE TABLE Answer
        (AnswerText VARCHAR2(100) NOT NULL,
        ClueId NUMERIC,
CONSTRAINT Answer_PK PRIMARY KEY (AnswerText),
CONSTRAINT Answer_FK FOREIGN KEY(ClueId) REFERENCES Clue(ClueId));

--location gdp is a multivalue attribute of clue
CREATE TABLE LocationGdp
        (Latitude FLOAT NOT NULL,
        Longitude FLOAT NOT NULL,
        ClueId NUMERIC,
CONSTRAINT LocationGdp_PK PRIMARY KEY(Latitude, Longitude),
CONSTRAINT LocationGdp_FK FOREIGN KEY(ClueId) REFERENCES Clue(ClueId));

--team table
CREATE TABLE Team
        (LicenseProvience VARCHAR2(2),
        LicenseNum NUMERIC,
        TeamNum NUMERIC(20,0) NOT NULL,
        TimePenalty NUMERIC(10,0),
        Disqualified VARCHAR2(5),
        EventDate DATE NOT NULL,
        ClueId NUMERIC NOT NULL,
        PersonId NUMERIC NOT NULL,
CONSTRAINT Team_PK PRIMARY KEY (TeamNum,EventDate,ClueId,PersonId),
CONSTRAINT Team_FK1 FOREIGN KEY (EventDate) REFERENCES RoadRally(EventDate),
CONSTRAINT Team_FK2 FOREIGN KEY (ClueId) REFERENCES Clue(ClueId),
CONSTRAINT Team_FK3 FOREIGN KEY (PersonId) REFERENCES Person(PersonId));

--team clue table
CREATE TABLE TeamClue
        (SerialNum NUMERIC,
        EventDate DATE NOT NULL,
        TeamClueNum NUMERIC NOT NULL,              
        ClueId NUMERIC NOT NULL,    
        TimeGiven NUMERIC,
        TimeAnswered NUMERIC,       
        TeamNum NUMERIC(20,0),
CONSTRAINT TeamClue_PK PRIMARY KEY (EventDate,TeamClueNum,ClueId),
CONSTRAINT TeamClue_FK1 FOREIGN KEY (EventDate) REFERENCES RoadRally(EventDate),
CONSTRAINT TeamClue_FK2 FOREIGN KEY (ClueId) REFERENCES Clue(ClueId),
CONSTRAINT TeamClue_FK3 FOREIGN KEY (TeamNum) REFERENCES Team(TeamNum));


DROP TABLE TeamClue;
DROP TABLE Team;
DROP TABLE LocationGdp;
DROP TABLE Answer;
DROP TABLE Clue;
DROP TABLE Person;
DROP TABLE EndGdp;
DROP TABLE StartGdp;
DROP TABLE RoadRally;

SQL Error: ORA-02270: no matching unique or primary key for this column-list
02270. 00000 - \"no matching unique or primary key for this column-list\"
*Cause:    A REFERENCES clause in a CREATE/ALTER TABLE statement
           gives a column-list for which there is no matching unique or primary
           key constraint in the referenced table.
*Action:   Find the correct column names using the ALL_CONS_COLUMNS
           catalog view

Solution

This Error is Beacause the parent table\'s constraint is a compound key (i.e. StartGdp TABLE) and we haven\'t referenced all the columns in the foreign key statement.

Remove all the compound key and declare as individual.

How to modify it? sql --road rally table CREATE TABLE RoadRally (EventDate DATE NOT NULL, PhoneNum NUMERIC, CONSTRAINT RoadRally_PK PRIMARY KEY (EventDate)); --
How to modify it? sql --road rally table CREATE TABLE RoadRally (EventDate DATE NOT NULL, PhoneNum NUMERIC, CONSTRAINT RoadRally_PK PRIMARY KEY (EventDate)); --

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site