Skip to content
Advertisement

ora-02270 How do i fix this?

This is what I have:

When I try to create the 3rd table I get this error. Is it because of the composite primary key in the grade table? How do I fix this?

Advertisement

Answer

Your primary key in GRADE covers two columns: stu_id and course_id. You cannot use course_id as a reference from the COURSE table, because it could potentially reference multiple rows.

Your foreign key should be in the GRADE table instead:

Additionally, for your COURSE table, your primary key needs to be NOT NULL, and should only encompass the course_id field. If you could potentially have multiple course_id’s for different instructors, how is GRADE.course_id going to distinguish which course I’m in, if I don’t supply an instructor_id?

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement