Search
Items tagged with: SQL
Question for the #MySQL / #MariaDB buffs, I have three tables defined thus:
Running the last query triggers the error
#SQL #Database #DBA
CREATE TABLE IF NOT EXISTS `user` (
`uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID',
...
PRIMARY KEY(`uid`)
);
CREATE TABLE IF NOT EXISTS `gserver` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
...
PRIMARY KEY(`id`)
);
CREATE TABLE IF NOT EXISTS `user-gserver` (
`uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Owner User id',
`gsid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'Gserver id',
...
PRIMARY KEY(`uid`,`gsid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
);
Running the last query triggers the error
Foreign key constraint is incorrectly formed
. Is there no way to reference multiple tables in foreign keys out of a compound primary key?#SQL #Database #DBA
#intro I'm an old netizen coming from IRC and the dawn of open source and the web. I work as an engineer in the #observability team at digital ocean. I'm firmly of the "visual" camp, enjoying art, design & math made pretty. My favorite #scifi novel remains the shockwave rider, my favorite movie blade runner. I enjoy #go AND #js. I really like #SQL. I'm a political scientist by training so I do antifa , eco, feminism & privacy since 1983. I love cats and my partner O. and chocolate and cheese. :)
Fellow Tooters,
I"m Jake, based in Southern #California, US. I’ve been on Mastodon since April/May 2022.
Background in #EnvironmentalEngineering and follow #ClimateChange, #WalkableCities, #RenewableEnergy, #EBikes.
Work in #Data, and use #Python, #SQL, #Git.
Recently built a #Discord bot that tracks #Wordle scores with a #RaspberryPi. I play #Fortnite.
Outside, I like #hiking, #cycling, #gym, #RoadTrips.
#Music faves: #AltRock, #EDM, #HipHop.
Thanks for reading my #introduction!
I"m Jake, based in Southern #California, US. I’ve been on Mastodon since April/May 2022.
Background in #EnvironmentalEngineering and follow #ClimateChange, #WalkableCities, #RenewableEnergy, #EBikes.
Work in #Data, and use #Python, #SQL, #Git.
Recently built a #Discord bot that tracks #Wordle scores with a #RaspberryPi. I play #Fortnite.
Outside, I like #hiking, #cycling, #gym, #RoadTrips.
#Music faves: #AltRock, #EDM, #HipHop.
Thanks for reading my #introduction!