Register to reply

SQL Refrencing a Foreign Key

by JOZ
Tags: foreign, refrencing
Share this thread:
JOZ
#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
Scientists develop 'electronic nose' for rapid detection of C. diff infection
Why plants in the office make us more productive
Tesla Motors dealing as states play factory poker

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