-
Notifications
You must be signed in to change notification settings - Fork 518
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Advanced SQL for Application Development Initail commit
- Loading branch information
Showing
6 changed files
with
2,431 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
Advanced SQL for Application Development/data/create_ecommerce_tables.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
-- Table: customers | ||
DROP TABLE IF EXISTS customers; | ||
|
||
CREATE TABLE customers | ||
( | ||
customer_id integer NOT NULL, | ||
first_name character varying(50), | ||
last_name character varying(50) , | ||
email character varying(50), | ||
address character varying(100), | ||
city character varying(50), | ||
state_province character varying(10), | ||
CONSTRAINT customers_pkey PRIMARY KEY (customer_id) | ||
) | ||
|
||
TABLESPACE pg_default; | ||
|
||
ALTER TABLE customers | ||
OWNER to postgres; | ||
|
||
|
||
|
||
-- Table: orders | ||
DROP TABLE IF EXISTS orders; | ||
|
||
CREATE TABLE orders | ||
( | ||
order_id integer NOT NULL, | ||
customer_id integer NOT NULL, | ||
order_date date NOT NULL, | ||
CONSTRAINT orders_pkey PRIMARY KEY (order_id) | ||
) | ||
|
||
TABLESPACE pg_default; | ||
|
||
|
||
ALTER TABLE orders | ||
OWNER to postgres; | ||
|
||
|
||
-- Table: product_orders | ||
DROP TABLE IF EXISTS product_orders; | ||
|
||
CREATE TABLE product_orders | ||
( | ||
order_id integer NOT NULL, | ||
product_id integer NOT NULL, | ||
quantity integer NOT NULL, | ||
unit_price numeric(10,2) NOT NULL, | ||
CONSTRAINT product_orders_pkey PRIMARY KEY (order_id, product_id) | ||
) | ||
|
||
TABLESPACE pg_default; | ||
|
||
ALTER TABLE product_orders | ||
OWNER to postgres; | ||
|
||
|
||
|
||
-- Table: products | ||
DROP TABLE IF EXISTS products; | ||
|
||
CREATE TABLE products | ||
( | ||
product_id integer NOT NULL, | ||
product_name character varying COLLATE pg_catalog."default" NOT NULL, | ||
product_type character varying COLLATE pg_catalog."default" NOT NULL, | ||
CONSTRAINT products_pkey PRIMARY KEY (product_id) | ||
) | ||
|
||
TABLESPACE pg_default; | ||
|
||
ALTER TABLE products | ||
OWNER to postgres; |
Oops, something went wrong.