You have multiple rows in CourseInfo with the same value for CourseNo. The primary key on CourseInfo is (CourseNo, Year), but your foreign key only references CourseNo. (EDIT: This actually works even though it shouldn't! Bug in Sqlite?) Thank you:)Ī typo in your GradeInfo table definition that should be a syntax error, but unfortunately sqlite is all too often too lenient about what it accepts: FOREIGN KEY (Student_ID) REFERENCES StudentInfo (Student_ID) Note that Student_ID is a foreign key from StudentInfo and CourseNo is a foreign key from CourseInfoĪny help would be appreciated. The values for student_ID and courseNo are already in the table but still get the error message of "foreign key mismatch - "GradeInfo" referencing "CourseInfo". INSERT INTO GradeInfo(Student_ID, CourseNo, Pts, Grade) INSERT INTO StudentInfo (Name, Student_ID, Date_of_Birth, Gender, Address, Email, Degree) VALUES("INFO101", "Foundations of Info Systems", "2019") NSERT INTO CourseInfo( CourseNo, Title, Year) VALUES("FCOM111", "Government, Law and Business", "2019") INSERT INTO CourseInfo( CourseNo, Title, Year) This is my DML for the tables INSERT INTO CourseInfo( CourseNo, Title, Year) What I was wanting to know is how do I Insert these values from the foreign keys from other tables? I kept getting an error message of "foreign key mismatch - "GradeInfo" referencing "CourseInfo" CREATE TABLE CourseInfo ( /*Created 2nd*/įOREIGN KEY (Student_ID) REFERENCES StudentInfo (Student_ID)įOREIGN KEY (CourseNo) REFERENCES CourseInfo (CourseNo),ĬREATE TABLE StudentInfo ( /*Created 1st*/ Keep in mind that CourseNo in GradeInfo table is a foreign key from CourseInfo and Student_ID in GradeInfo is a foreign key from CourseInfo. I want to add the same value for Student_ID that is in the Studentinfo table in the GradeInfo and also wanted to add the same value for CourseNo that is in the CourseInfo table and add it to GradeInfo.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |