Answered step by step
Verified Expert Solution
Link Copied!

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 anSQL Statement, all the Solutions found on this provide invalid SQL statementsCREATE TABLE Officer (
OfficerNumber INT UNSIGNED AUTO_INCREMENT,
BadgeNumber INT NOT NULL,
DepartmentName VARCHAR(30) NOT NULL,
FullName VARCHAR(30) NOT NULL,
RankCode CHAR(3),
PRIMARY KEY (OfficerNumber),
UNIQUE (BadgeNumber, DepartmentName)
);
CREATE TABLE Event (
EventNumber INT UNSIGNED AUTO_INCREMENT,
EventDateTime DATETIME NOT NULL,
LocationDesc TEXT(1000) NOT NULL,
ReportDesc TEXT(5000),
EventCode CHAR(2) 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 AUTO_INCREMENT PRIMARY KEY,
TypeCode CHAR(1) NOT NULL,
YearNumber INT UNSIGNED NOT NULL,
MakeCode CHAR(1) NOT NULL,
ModelName VARCHAR(20) NOT NULL,
PlateID INT UNSIGNED,
StateCode CHAR(2) NOT NULL,
RegistrationDate DATE
CONSTRAINT fk_PlateID FOREIGN KEY (PlateID) REFERENCES Plate(PlateID)
);
CREATE TABLE Vehicle Event (
EventNumber INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
VehicleID INT UNSIGNED NOT NULL,
EventDate DATE NOT NULL,
TimeTIME NOT NULL,
LocationDesc VARCHAR (255) NOT NULL,
ReportDesc TEXT,
Officer Number INT UNSIGNED,
EventCode CHAR(1) NOT NULL,
CauseEventNumber INT UNSIGNED,
CONSTRAINT fk_VehicleID FOREIGN KEY (VehicleID) REFERENCES Vehicle(VehicleID),
CONSTRAINT fk_OfficerNumber FOREIGN KEY (OfficerNumber) REFERENCES Officer(OfficerNumber),
CONSTRAINT fk_CauseEventNumber FOREIGN KEY (CauseEventNumber) REFERENCES CauseEvent(CauseEventNumber)
);
please review the last expert answer which i incuded here and it 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 AUTO_INCREMENT,
BadgeNumber INT NOT NULL,
DepartmentName VARCHAR(30) NOT NULL,
FullName VARCHAR(30) NOT NULL,
RankCode CHAR(3),
PRIMARY KEY (OfficerNumber),
UNIQUE (BadgeNumber, DepartmentName)
);
CREATE TABLE Event (
EventNumber INT UNSIGNED AUTO_INCREMENT,
EventDateTime DATETIME NOT NULL,
LocationDesc TEXT(1000) NOT NULL,
ReportDesc TEXT(5000),
EventCode CHAR(2) 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 AUTO_INCREMENT PRIMARY KEY,
TypeCode CHAR(1) NOT NULL,
YearNumber INT UNSIGNED NOT NULL,
MakeCode CHAR(1) NOT NULL,
ModelName VARCHAR(20) NOT NULL,
PlateID INT UNSIGNED,
StateCode CHAR(2) NOT NULL,
RegistrationDate DATE
CONSTRAINT fk_PlateID FOREIGN KEY (PlateID) REFERENCES Plate(PlateID)
);
CREATE TABLE Vehicle Event (
EventNumber INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
VehicleID INT UNSIGNED NOT NULL,
EventDate DATE NOT NULL,
TimeTIME NOT NULL,
LocationDesc VARCHAR (255) NOT NULL,
ReportDesc TEXT,
Officer Number INT UNSIGNED,
EventCode CHAR(1) NOT NULL,
CauseEventNumber INT UNSIGNED,
CONSTRAINT fk_VehicleID FOREIGN KEY (VehicleID) REFERENCES Vehicle(VehicleID),
CONSTRAINT fk_OfficerNumber FOREIGN KEY (OfficerNumber) REFERENCES Officer(OfficerNumber),
CONSTRAINT fk_CauseEventNumber FOREIGN KEY (CauseEventNumber) REFERENCES CauseEvent(CauseEventNumber)
);
the last submission provided these errors please provide SQL statement without these errors
Latest submission -3:33 PM CST on 02/11/24
Total score: 0/10
Download this submission
1:Test Vehicle primary key
0/1
Query failed: ERROR 1824(HY000) at line 30: Failed to open the referenced table 'plate'
2:Test multiple Vehicle columns
0/2
Query failed: ERROR 1824(HY000) at line 30: Failed to open the referenced table 'plate'
3:Test Vehicle unique columns
0/2
Query failed: ERROR 1824(HY000) at line 30: Failed to open the referenced table 'plate'
4:Test VehicleEvent primary key
0/3
Query failed: ERROR 1824(HY000) at line 30: Failed to open the referenced table 'plate'
5:Test restrict rules for VehicleID
0/1
Query failed: ERROR 1824(HY000) at line 30: Failed to open the referenced table 'plate'
6:Test restrict rules for EventNumber
0/1
Query failed: ERROR 1824(HY000) at line 30: Failed to open the referenced table 'plate'
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Datalog Engines In Databases

Authors: Bas Ketsman ,Paraschos Koutris

1st Edition

1638280428, 978-1638280422

More Books

Students also viewed these Databases questions

Question

Contrast chronic and acute schizophrenia.

Answered: 1 week ago