SQL Refrencing a Foreign Key


by JOZ
Tags: foreign, refrencing
JOZ
JOZ is offline
#1
Sep9-11, 10:39 AM
P: 8
Hi im trying to create the tables below and having problems with the timeLog table referencing allocation, when I put it into the modified form of Oricle my University uses it dosent like me refrencing the refrenced values it spits out the error:
ORA-02256: number of referencing columns must match referenced columns
Is it even possible to refrence a value thats already being refrenced?
Is there a way to refrence both the EmpID and ProjID together from allocation so that the EmpID, ProjID pair has to exist in allocation to be used in timeLog

CREATE TABLE employee (
	EmpID		number PRIMARY KEY,
	EmpName		varchar2(30),
	Gender		varchar2(1));
	
CREATE TABLE project (
	ProjID		 varchar2(2) PRIMARY KEY,
	Description	 varchar2(30),
	Budget	number);
	
CREATE TABLE allocation (
	EmpID		number references employee,
	ProjID		varchar2(2) references project,
	HourlyRate	number(5,2),
	PRIMARY KEY (EmpID, ProjID));
	
CREATE TABLE timeLog (
	EmpID		number references allocation,
	ProjID		varchar2(2) references allocation,
	WeekNo		number,
	HrsWorked	number,
	PRIMARY KEY (EmpID, ProjID, WeekNo));
Phys.Org News Partner Science news on Phys.org
Going nuts? Turkey looks to pistachios to heat new eco-city
Space-tested fluid flow concept advances infectious disease diagnoses
SpaceX launches supplies to space station (Update)

Register to reply

Related Discussions
which foreign language? Academic Guidance 2
Foreign Study? Academic Guidance 0
Does Foreign Aid Work Very Well? Current Events 5
Foreign Language Academic Guidance 1
Veterans of Foreign War General Discussion 8