Answered step by step
Verified Expert Solution
Question
1 Approved Answer
i need help creating a n S Q L Statement, all the Solutions found o n this provide invalid S Q L statementsCREATE TABLE Officer
i need help creating Statement, all the Solutions found this provide invalid statementsCREATE TABLE Officer
OfficerNumber INT UNSIGNED AUTOINCREMENT,
BadgeNumber INT NOT NULL,
DepartmentName VARCHAR NOT NULL,
FullName VARCHAR NOT NULL,
RankCode CHAR
PRIMARY KEY OfficerNumber
UNIQUE BadgeNumber DepartmentName
;
CREATE TABLE Event
EventNumber INT UNSIGNED AUTOINCREMENT,
EventDateTime DATETIME NOT NULL,
LocationDesc TEXT NOT NULL,
ReportDesc TEXT
EventCode CHAR NOT NULL,
CauseEventNumber INT UNSIGNED,
ReportOfficerNumber INT UNSIGNED NOT NULL,
PRIMARY KEY EventNumber
FOREIGN KEY CauseEventNumber
REFERENCES Event EventNumber
ON UPDATE SET NULL
ON DELETE SET NULL,
FOREIGN KEY ReportOfficerNumber
REFERENCES Officer OfficerNumber
ON UPDATE RESTRICT
ON DELETE RESTRICT
;
CREATE TABLE Vehicle
Vehicle ID INT UNSIGNED AUTOINCREMENT PRIMARY KEY,
TypeCode CHAR NOT NULL,
YearNumber INT UNSIGNED NOT NULL,
MakeCode CHAR NOT NULL,
ModelName VARCHAR NOT NULL,
PlateID INT UNSIGNED,
StateCode CHAR NOT NULL,
RegistrationDate DATE
CONSTRAINT fkPlateID FOREIGN KEY PlateID REFERENCES PlatePlateID
;
CREATE TABLE Vehicle Event
EventNumber INT UNSIGNED AUTOINCREMENT PRIMARY KEY,
VehicleID INT UNSIGNED NOT NULL,
EventDate DATE NOT NULL,
TimeTIME NOT NULL,
LocationDesc VARCHAR NOT NULL,
ReportDesc TEXT,
Officer Number INT UNSIGNED,
EventCode CHAR NOT NULL,
CauseEventNumber INT UNSIGNED,
CONSTRAINT fkVehicleID FOREIGN KEY VehicleID REFERENCES VehicleVehicleID
CONSTRAINT fkOfficerNumber FOREIGN KEY OfficerNumber REFERENCES OfficerOfficerNumber
CONSTRAINT fkCauseEventNumber FOREIGN KEY CauseEventNumber REFERENCES CauseEventCauseEventNumber
;
please review the last expert answer which i incuded here and was incorrect.
please provide the correct SQL in the proper format, the previous answers themselves had syntax issues and spacing issues
CREATE TABLE Officer
OfficerNumber INT UNSIGNED AUTOINCREMENT,
BadgeNumber INT NOT NULL,
DepartmentName VARCHAR NOT NULL,
FullName VARCHAR NOT NULL,
RankCode CHAR
PRIMARY KEY OfficerNumber
UNIQUE BadgeNumber DepartmentName
;
CREATE TABLE Event
EventNumber INT UNSIGNED AUTOINCREMENT,
EventDateTime DATETIME NOT NULL,
LocationDesc TEXT NOT NULL,
ReportDesc TEXT
EventCode CHAR NOT NULL,
CauseEventNumber INT UNSIGNED,
ReportOfficerNumber INT UNSIGNED NOT NULL,
PRIMARY KEY EventNumber
FOREIGN KEY CauseEventNumber
REFERENCES Event EventNumber
ON UPDATE SET NULL
ON DELETE SET NULL,
FOREIGN KEY ReportOfficerNumber
REFERENCES Officer OfficerNumber
ON UPDATE RESTRICT
ON DELETE RESTRICT
;
CREATE TABLE Vehicle
Vehicle ID INT UNSIGNED AUTOINCREMENT PRIMARY KEY,
TypeCode CHAR NOT NULL,
YearNumber INT UNSIGNED NOT NULL,
MakeCode CHAR NOT NULL,
ModelName VARCHAR NOT NULL,
PlateID INT UNSIGNED,
StateCode CHAR NOT NULL,
RegistrationDate DATE
CONSTRAINT fkPlateID FOREIGN KEY PlateID REFERENCES PlatePlateID
;
CREATE TABLE Vehicle Event
EventNumber INT UNSIGNED AUTOINCREMENT PRIMARY KEY,
VehicleID INT UNSIGNED NOT NULL,
EventDate DATE NOT NULL,
TimeTIME NOT NULL,
LocationDesc VARCHAR NOT NULL,
ReportDesc TEXT,
Officer Number INT UNSIGNED,
EventCode CHAR NOT NULL,
CauseEventNumber INT UNSIGNED,
CONSTRAINT fkVehicleID FOREIGN KEY VehicleID REFERENCES VehicleVehicleID
CONSTRAINT fkOfficerNumber FOREIGN KEY OfficerNumber REFERENCES OfficerOfficerNumber
CONSTRAINT fkCauseEventNumber FOREIGN KEY CauseEventNumber REFERENCES CauseEventCauseEventNumber
;
the last submission provided these errors please provide SQL statement without these errors
Latest submission : PM CST on
Total score:
Download this submission
:Test Vehicle primary key
Query failed: ERROR HY at line : Failed to open the referenced table 'plate'
:Test multiple Vehicle columns
Query failed: ERROR HY at line : Failed to open the referenced table 'plate'
:Test Vehicle unique columns
Query failed: ERROR HY at line : Failed to open the referenced table 'plate'
:Test VehicleEvent primary key
Query failed: ERROR HY at line : Failed to open the referenced table 'plate'
:Test restrict rules for VehicleID
Query failed: ERROR HY at line : Failed to open the referenced table 'plate'
:Test restrict rules for EventNumber
Query failed: ERROR HY at line : Failed to open the referenced table 'plate'
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started