- May 29, 2002
- 19
- 0
- 0
I'm working on a CIS project right now and having trouble with a little bit of SQL.
It's a workout database (don't ask)...In the 'Routine' table, we have a primary key composed of the 'Routine_name' and 'exercise' fields. In the 'Schedule' table, we want to reference the routine.routine_name field (as a foreign key), but the Oracle server doesn't seem to like it.
here's my code for the create tables....
CREATE TABLE SCHEDULE
(WO_DATE DATE,
CLIENT_ID CHAR(4),
ROUTINE_NAME CHAR(15),
PRIMARY KEY (WO_DATE, CLIENT_ID),
FOREIGN KEY (CLIENT_ID) REFERENCES CLIENT,
FOREIGN KEY (ROUTINE_NAME) REFERENCES ROUTINE);
CREATE TABLE ROUTINE
(ROUTINE_NAME CHAR(25),
EXERCISE CHAR(35),
FOREIGN KEY (EXERCISE) REFERENCES EXERCISE,
primary key (routine_name, exercise));
When i run the dump file for create schedule, this is the error message that comes back at me:
FOREIGN KEY (ROUTINE_NAME) REFERENCES ROUTINE)
ERROR at line 7:
ORA-02256: number of referencing columns must match referenced columns
We've trying to accomplish this without having to add an 'exercise' field to the 'schedule' table, because it gets redundant.
Any help would be greatly appreciated....thanks in advance!
It's a workout database (don't ask)...In the 'Routine' table, we have a primary key composed of the 'Routine_name' and 'exercise' fields. In the 'Schedule' table, we want to reference the routine.routine_name field (as a foreign key), but the Oracle server doesn't seem to like it.
here's my code for the create tables....
CREATE TABLE SCHEDULE
(WO_DATE DATE,
CLIENT_ID CHAR(4),
ROUTINE_NAME CHAR(15),
PRIMARY KEY (WO_DATE, CLIENT_ID),
FOREIGN KEY (CLIENT_ID) REFERENCES CLIENT,
FOREIGN KEY (ROUTINE_NAME) REFERENCES ROUTINE);
CREATE TABLE ROUTINE
(ROUTINE_NAME CHAR(25),
EXERCISE CHAR(35),
FOREIGN KEY (EXERCISE) REFERENCES EXERCISE,
primary key (routine_name, exercise));
When i run the dump file for create schedule, this is the error message that comes back at me:
FOREIGN KEY (ROUTINE_NAME) REFERENCES ROUTINE)
ERROR at line 7:
ORA-02256: number of referencing columns must match referenced columns
We've trying to accomplish this without having to add an 'exercise' field to the 'schedule' table, because it gets redundant.
Any help would be greatly appreciated....thanks in advance!