Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DATABASE : Hi! Please someone help me when I'm trying to make a foreign key relation between branch and staff table I get this error:

DATABASE : Hi! Please someone help me when I'm trying to make a foreign key relation between branch and staff table I get this error:

ALTER TABLE BRANCH ADD FOREIGN KEY (MANAGER_ID, BRANCHID) REFERENCES STAFF(MANAGER_ID, BRANCHID) Error report - 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

--------------------------------------------------------------------------------------------------------------

Branch Table:

CREATE TABLE BRANCH (

BRANCHID NUMNER(4,0) NOT NULL, BRANCHNAME VARCHAR2 (30) NOT NULL, MANAGER_ID NUMBER(6,0), PLACEID NUMBER (4,0), FOREIGN KEY (MANAGER_ID, BRANCHID) REFERENCES STAFF(MANAGER_ID, BRANCHID); );

STAFF Table:

CREATE TABLE STAFF( STAFFID NUMBER(6,0) PRIMARY KEY NOT NULL, FNAME VARCHAR2(20), LNAME VARCHAR2(25) NOT NULL, SALARY NUMBER(8,2), MANAGER_ID NUMBER(6,0), BRANCHID NUMBER(4,0), FOREIGN KEY (BRANCHID, MANAGER_ID) REFERENCES BRANCH(BRANCHID, MANAGER_ID));

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

4. Design a career management system.

Answered: 1 week ago

Question

4. Evaluation is ongoing and used to improve the system.

Answered: 1 week ago

Question

6. Effectively perform the managers role in career management.

Answered: 1 week ago