-
Notifications
You must be signed in to change notification settings - Fork 42
/
create_db_tables_pg.sql
82 lines (68 loc) · 1.71 KB
/
create_db_tables_pg.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
-- Postgres Table Creation Script
--
--
-- Table structure for table departments
--
CREATE TABLE departments (
department_id INT NOT NULL,
department_name VARCHAR(45) NOT NULL,
PRIMARY KEY (department_id)
);
--
-- Table structure for table categories
--
CREATE TABLE categories (
category_id INT NOT NULL,
category_department_id INT NOT NULL,
category_name VARCHAR(45) NOT NULL,
PRIMARY KEY (category_id)
);
--
-- Table structure for table products
--
CREATE TABLE products (
product_id INT NOT NULL,
product_category_id INT NOT NULL,
product_name VARCHAR(45) NOT NULL,
product_description VARCHAR(255) NOT NULL,
product_price FLOAT NOT NULL,
product_image VARCHAR(255) NOT NULL,
PRIMARY KEY (product_id)
);
--
-- Table structure for table customers
--
CREATE TABLE customers (
customer_id INT NOT NULL,
customer_fname VARCHAR(45) NOT NULL,
customer_lname VARCHAR(45) NOT NULL,
customer_email VARCHAR(45) NOT NULL,
customer_password VARCHAR(45) NOT NULL,
customer_street VARCHAR(255) NOT NULL,
customer_city VARCHAR(45) NOT NULL,
customer_state VARCHAR(45) NOT NULL,
customer_zipcode VARCHAR(45) NOT NULL,
PRIMARY KEY (customer_id)
);
--
-- Table structure for table orders
--
CREATE TABLE orders (
order_id INT NOT NULL,
order_date TIMESTAMP NOT NULL,
order_customer_id INT NOT NULL,
order_status VARCHAR(45) NOT NULL,
PRIMARY KEY (order_id)
);
--
-- Table structure for table order_items
--
CREATE TABLE order_items (
order_item_id INT NOT NULL,
order_item_order_id INT NOT NULL,
order_item_product_id INT NOT NULL,
order_item_quantity INT NOT NULL,
order_item_subtotal FLOAT NOT NULL,
order_item_product_price FLOAT NOT NULL,
PRIMARY KEY (order_item_id)
);