• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

MySQL HELP :(

Joined
Feb 15, 2008
Messages
213 (0.04/day)
System Name Shark's Build
Processor AMD Ryzen 7 5700X 3.4 GHz
Motherboard Gigabyte B450 I AORUS PRO
Cooling Noctua NH-C14 heatsink core with swapped Phanteks PH-F140HP PWM
Memory G.SKILL Aegis (2 * 8GB) DDR4-3000
Video Card(s) GeForce RTX 3060Ti 8GB
Display(s) Tri-Monitor setup 1x144hz 2x60hz
Case Corsair Obsidian 250D Mini ITX
Audio Device(s) On-Board
Power Supply EVGA Supernova NEX750B 750W ATX Power Supply 80+ Bronze
Hey all!

So I'm working on an assignment and I'm getting an error when I try and load my .SQL file.

https://pastebin.com/4GajJ9MT <--- here is my code blocks

I get the error l_id doesn't exist when I have it in the limo table.

I'm a real scrub when it comes to this. Please help me :(

Edit: Fixed qualify and rental up a little by adding q_ to the foreign keys and r_ to the rental foreign keys. Now I'm getting error "Cannot add foreign key constraint" regarding the rental table create.
 
Last edited:
Joined
Nov 13, 2007
Messages
10,209 (1.71/day)
Location
Austin Texas
Processor 13700KF Undervolted @ 5.6/ 5.5, 4.8Ghz Ring 200W PL1
Motherboard MSI 690-I PRO
Cooling Thermalright Peerless Assassin 120 w/ Arctic P12 Fans
Memory 48 GB DDR5 7600 MHZ CL36
Video Card(s) RTX 4090 FE
Storage 2x 2TB WDC SN850, 1TB Samsung 960 prr
Display(s) Alienware 32" 4k 240hz OLED
Case SLIGER S620
Audio Device(s) Yes
Power Supply Corsair SF750
Mouse Xlite V2
Keyboard RoyalAxe
Software Windows 11
Benchmark Scores They're pretty good, nothing crazy.
the constraint command syntax looks weird to me... (I work mostly with T-SQL but with a google this is what came up for mySQL):

CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
PRIMARY KEY (ID)
);

also I usually don't declare width on PKs just leave is as int
 

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
8,193 (1.50/day)
Location
Charleston, SC
System Name Tower of Power / Sechs
Processor i7 14700K / i7 5820k @ 4.5ghz
Motherboard ASUS ROG Strix Z690-A Gaming WiFi D4 / X99S GAMING 7
Cooling CM MasterLiquid ML360 Mirror ARGB Close-Loop AIO / CORSAIR Hydro Series H100i Extreme
Memory CORSAIR Vengeance LPX 32GB (2 x 16GB) DDR4 3600 / G.Skill DDR4 2800 16GB 4x4GB
Video Card(s) ASUS TUF Gaming GeForce RTX 4070 Ti / ASUS TUF Gaming GeForce RTX 3070 V2 OC Edition
Storage 4x Samsung 980 Pro 1TB M.2, 2x Crucial 1TB SSD / Samsung 870 PRO 500GB M.2
Display(s) Samsung 32" Odyssy G5 Gaming 144hz 1440p, ViewSonic 32" 72hz 1440p / 2x ViewSonic 32" 72hz 1440p
Case Phantek "400A" / Phanteks “Enthoo Pro series”
Audio Device(s) Realtek ALC4080 / Azalia Realtek ALC1150
Power Supply Corsair RM Series RM750 / Corsair CXM CX600M
Mouse Glorious Gaming Model D Wireless / Razer DeathAdder Chroma
Keyboard Glorious GMMK with box-white switches / Keychron K6 pro with blue swithes
VR HMD Quest 3 (128gb) + Rift S + HTC Vive + DK1
Software Windows 11 Pro x64 / Windows 10 Pro x64
Benchmark Scores Yes
the constraint command syntax looks weird to me... (I work mostly with T-SQL but with a google this is what came up for mySQL):

CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
PRIMARY KEY (ID)
);

also I usually don't declare width on PKs just leave is as int

Yea, I never declare width on PKs or int's in general as well. The biggest issue I seen was not setting the pk to NOT NULL, but I see you fixed that for him in your code.

I would write it like this if I wanted to use the constraint. I would add the constraint after the PK.
Code:
CREATE TABLE limo (
l_id INT,
l_callsign VARCHAR(15),
l_type VARCHAR(300),
PRIMARY KEY(l_id),
CONSTRAINT limo_l_id_PK
);

or create table without the constraint using your code then ALTER the table
Code:
ALTER TABLE limo
ADD CONSTRAINT limo_l_id_PK;
 
Top