I am very new to SQL and my class is using Oracle cloud as of now. I have created tables and I am trying to insert data into it. I keep receiving the error ORA-02291: integrity constraint violated when I try to insert data into my semester table. Any help would be extremely appreciated. Thank you!
CREATE TABLE SCHOOL (
SchoolID char(10) NOT NULL,
SchoolName char(50) NOT NULL,
SchoolAddress char(50) NOT NULL,
SchoolCity char(50) NOT NULL,
SchoolState char(2) NOT NULL,
SchoolZIP char(30) NOT NULL,
SchoolPhone char(25) NULL,
SchoolWebsite char(50) NOT NULL,
CONSTRAINT SCHOOL_PK PRIMARY KEY(SchoolID)
);
CREATE TABLE SEMESTER(
SemesterName char(20) NOT NULL,
Year char(4) NOT NULL,
SchoolID char(50) NOT NULL,
CONSTRAINT SEMESTER_PK PRIMARY KEY(SemesterName),
CONSTRAINT SEM_SCH_FK FOREIGN KEY(SchoolID)
REFERENCES SCHOOL(SchoolID)
);
/****************************** School ******************************************/
INSERT INTO SCHOOL(SchoolID, SchoolName, SchoolAddress, SchoolCity, SchoolState, SchoolZip, SchoolPhone, SchoolWebsite)
VALUES(
'NIU', 'Northern Illinois University', '1425 Lincoln Hwy', 'Dekalb', 'IL', '60115', '815-753-0446', 'https://myniu.niu.edu/');
SELECT * FROM SCHOOL;
/****************************** Semester ****************************************/
INSERT INTO SEMESTER(SemesterName, Year, SchoolID)
VALUES(
'Spring', '2020', 'NIU');
INSERT INTO SEMESTER VALUES(
'Fall', '2020', 'NIU');
SELECT * FROM SEMESTER;
SCHOOL.SchoolIDischar(10)andSEMESTER.SchoolIDischar(50)