Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

what is wrong with my \" Inspection\" and \"BusinessViolation\" tables? CREATE T

ID: 3766195 • Letter: W

Question

what is wrong with my " Inspection" and "BusinessViolation" tables?


CREATE TABLE BUSINESSVIOLATION(
CAMIS           VarChar(6) NOT NULL,
InspectionDate Date,
ActionCode      VarChar(1) NOT NULL,
ViolationCode   VarChar(100) NOT NULL,
PRIMARY KEY(CAMIS, InspectionDate, ActionCode, ViolationCode),
FOREING KEY(ViolationCode) REFERENCES ViolationFlag(ViolationCode),
FOREING KEY(ActionCode) REFERENCES Action(ActionCode),
FOREING KEY(InspectionDate) REFERENCES Inspection(InspectionDate),
FOREING KEY(CAMIS) REFERENCES Building(CAMIS)
);

CREATE TABLE INSPECTION(
InspectionDate        Date,
CAMIS                 VarChar(6)   NOT NULL,
Score                 Int,
CurrentGrade          Char(1),
GradeDate             Date,
Action                Char(100),
PRIMARY KEY(InspectionDate, CAMIS)
);

Explanation / Answer

                Avoid spelling mistakes while writing key workds

                 Ex: write FOREIGN instead of FOREING

for example create tables as follows:

CREATE TABLE Building(
CAMIS           VarChar(6) NOT NULL,
PRIMARY KEY(CAMIS)
);
CREATE TABLE INSPECTION(
InspectionDate        Date,
CAMIS                 VarChar(6)   NOT NULL,
Score                 Int,
CurrentGrade          Char(1),
GradeDate             Date,
Action                Char(100),
PRIMARY KEY(InspectionDate,CAMIS)
);

CREATE TABLE ViolationFlag(
ViolationCode   VarChar(100) NOT NULL,
PRIMARY KEY(ViolationCode)
);
CREATE TABLE Action(
ActionCode      VarChar(1) NOT NULL,
PRIMARY KEY(ActionCode)
);


CREATE TABLE BUSINESSVIOLATION(
CAMIS           VarChar(6) NOT NULL,
InspectionDate Date,
ActionCode      VarChar(1) NOT NULL,
ViolationCode   VarChar(100) NOT NULL,
PRIMARY KEY(CAMIS, InspectionDate, ActionCode, ViolationCode) ,
FOREIGN KEY(ViolationCode) REFERENCES ViolationFlag(ViolationCode) ,
FOREIGN KEY(ActionCode) REFERENCES Action(ActionCode) ,
FOREIGN KEY(InspectionDate) REFERENCES Inspection(InspectionDate) ,
FOREIGN KEY(CAMIS) REFERENCES Building(CAMIS)
);