I'm having a problem with a FOREIGN KEY
. I'm always getting
FOREIGN KEY (STUDID)
*
ERROR at line 3:
ORA-00904: "STUDID": invalid identifier
You have no field called STUDID
in your SUBJECT
table. Looks like you're trying to create a foreign key on a field that doesn't exist.
Carson is correct - it seems like you are trying to build a relationship between Students and Subjects. Typically this is a many to many relationship, and would likely require a third, middle table to link them.
Think
"A Student can be enrolled to many subjects."
"A Subject can have many Students enrolled."
So you need a middle table with both STUDID
and SUBJECTID
columns, and that table would have 2 FKs declared, pointing to the other tables.
[edit] of course, that's the whole 3rd normal form thing .. you may or may not want/need to denormalize at some point, but that's a different discussion ;) [/edit]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.