Created
February 13, 2023 17:06
-
-
Save rponte/b4b6fd13d692ef5f934dc61da8eb9610 to your computer and use it in GitHub Desktop.
SQL and Postgres: simple schema that can be used as example
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
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 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://www.crunchydata.com/blog/sql-tricks-for-more-effective-crud