Skip to content

Instantly share code, notes, and snippets.

@vedashree29296
Created January 26, 2021 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vedashree29296/979f400df9dff7596618b7f4c66b5fca to your computer and use it in GitHub Desktop.
Save vedashree29296/979f400df9dff7596618b7f4c66b5fca to your computer and use it in GitHub Desktop.
database sql file for petstore app in Go Chronicles
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");
@okcthulhu
Copy link

The alter table commands are throwing errors here. I had to alter these to get this working

@JustJakeCalifornia
Copy link

JustJakeCalifornia commented Jun 26, 2022

I had to alter these to get this working

What do you mean by that?

@Lemorz56
Copy link

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

@okcthulhu
Copy link

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