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
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]
ALTER TABLE SUBJECT ADD STUDID NUMBER(10) COMMENT 'fk ref student.studid', then the statement that adds the foreign key constraint will succeed. That fixes the error, but see the answer from Ditto: this looks way more like a many-to-many relationship, i.e. a subject should be allowed to be related to more than one student. But if you want a student related to at most one subject, then addSUBJECTIDcolumn toSTUDENT