Foreign key problem [message #283258] |
Mon, 26 November 2007 09:31 |
Hunter_wow
Messages: 31 Registered: November 2007
|
Member |
|
|
Hello. Working on a school assignment and got some problem with creating my first tables. Oracle returns a error for the table "Student" who should contain the keys of both Program and Branch(weak). Have also tried to type "FOREIGN KEY(ProgramName) REFERENCES Program(Name));)," right after StudentName VARCHAR(50), but this also gives error. Any hint on how the FOREIGN KEY for progam should look? The Program table and Branch table seems to be correct.
CREATE TABLE Program(
Name VARCHAR(50),
Abbreviation VARCHAR(10),
PRIMARY KEY(Name));
CREATE TABLE Branch(
Abbreviation VARCHAR(10),
ProgramName VARCHAR(50) REFERENCES Program(Name),
PRIMARY KEY(ProgramName,Abbreviation));
CREATE TABLE Student(
ID INT,
StudentName VARCHAR(50),
ProgramName VARCHAR(50),
BranchAbbreviation VARCHAR(10) REFERENCES Branch(Abbreviation),
PRIMARY KEY(ID),
FOREIGN KEY(ProgramName) REFERENCES Program(Name));
|
|
|
|
|
|