Cool K.
2009-02-19 03:01:07 UTC
The primary key in table SUPPLIERS is SNO. It also has a column named CITY.
The PART table also has the CITY column. However, in neither tables is CITY a primary key. How do I make the PART table reference the SUPPLIERS table? I did the following and got an error.
CREATE TABLE SUPPLIERS
(SNO VARCHAR(3),
SNAME VARCHAR(6),
STATUS NUMBER(3),
CITY VARCHAR (5),
CONSTRAINT SUPPLIERS_SNO_pk PRIMARY KEY (SNO));
CREATE TABLE PART
(PNO VARCHAR(3),
PNAME VARCHAR(6),
COLOR VARCHAR(6),
WEIGHT NUMBER(3),
CITY VARCHAR(5),
CONSTRAINT PART_PNO_pk PRIMARY KEY(PNO),
CONSTRAINT PART_CITY_fk FOREIGN KEY (CITY) REFERENCES SUPPLIERS(CITY));
ORA-02270: no matching unique or primary key for this column-list
I know that CITY is not the primary key in SUPPLIERS table but I have manipulated both tables using composite keys but to no avail! Please tell me how I can write this so it will work.
Thanks