Skip to content

Instantly share code, notes, and snippets.

@rponte
Created February 13, 2023 17:06
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 rponte/b4b6fd13d692ef5f934dc61da8eb9610 to your computer and use it in GitHub Desktop.
Save rponte/b4b6fd13d692ef5f934dc61da8eb9610 to your computer and use it in GitHub Desktop.
SQL and Postgres: simple schema that can be used as example
DROP TABLE customers, invoices, items;
CREATE TABLE customers (
customer_id SERIAL PRIMARY KEY,
name TEXT NOT NULL UNIQUE
);
CREATE TABLE invoices (
invoice_id SERIAL PRIMARY KEY,
customer_id BIGINT REFERENCES customers (customer_id)
);
CREATE TABLE items (
item_id SERIAL PRIMARY KEY,
invoice_id BIGINT REFERENCES invoices (invoice_id),
name TEXT NOT NULL
);
@rponte
Copy link
Author

rponte commented Feb 13, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment