Created
January 26, 2021 06:11
-
-
Save vedashree29296/979f400df9dff7596618b7f4c66b5fca to your computer and use it in GitHub Desktop.
database sql file for petstore app in Go Chronicles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE "category" ( | |
"id" int PRIMARY KEY, | |
"category_name" varchar | |
); | |
CREATE TABLE "breed" ( | |
"id" int, | |
"breed_name" varchar, | |
"category_id" int, | |
PRIMARY KEY ("id", "category_id") | |
); | |
CREATE TABLE "location" ( | |
"id" int, | |
"location_name" varchar | |
); | |
CREATE TABLE "pet" ( | |
"id" int, | |
"name" varchar, | |
"category_id" int, | |
"breed_id" int, | |
"age" float, | |
"location_id" int, | |
"image_url" varchar, | |
"description" varchar, | |
PRIMARY KEY ("category_id", "breed_id", "location_id") | |
); | |
ALTER TABLE "breed" ADD FOREIGN KEY ("category_id") REFERENCES "category" ("id"); | |
ALTER TABLE "category" ADD FOREIGN KEY ("category_name") REFERENCES "pet" ("category_id"); | |
ALTER TABLE "breed" ADD FOREIGN KEY ("category_id") REFERENCES "pet" ("breed_id"); | |
ALTER TABLE "location" ADD FOREIGN KEY ("id") REFERENCES "pet" ("location_id"); |
I had to alter these to get this working
What do you mean by that?
The alter table commands are throwing errors here. I had to alter these to get this working
Can you share how you altered them? @okcthulhu
I wish I could remember! Sorry, guys.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The alter table commands are throwing errors here. I had to alter these to get this working