New Reply

SQL Refrencing a Foreign Key

 
Share Thread
Sep9-11, 10:39 AM   #1
JOZ
 

SQL Refrencing a Foreign Key


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:
Code:
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

Code:
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));
PhysOrg.com science news on PhysOrg.com

>> New language discovery reveals linguistic insights
>> US official: Solar plane to help ground energy use (Update)
>> Four microphones, computer algorithm enough to produce 3-D model of simple, convex room
New Reply

Similar discussions for: SQL Refrencing a Foreign Key
Thread Forum Replies
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