-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sql
More file actions
27 lines (27 loc) · 1.24 KB
/
script.sql
File metadata and controls
27 lines (27 loc) · 1.24 KB
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
DROP TABLE IF EXISTS product_consumptions;
DROP TABLE IF EXISTS stocks;
DROP TABLE IF EXISTS stores;
CREATE TABLE stores (
id BIGINT AUTO_INCREMENT ,
name VARCHAR(255) NOT NULL,
location VARCHAR(255) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE stocks (
id BIGINT AUTO_INCREMENT,
store_id BIGINT NOT NULL,
product_id BIGINT NOT NULL,
quantity BIGINT NOT NULL,
data_added TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (store_id) REFERENCES stores(id),
PRIMARY KEY (id)
);
CREATE TABLE product_consumptions (
id BIGINT AUTO_INCREMENT ,
store_id BIGINT NOT NULL,
product_id BIGINT NOT NULL,
quantity_consumed BIGINT NOT NULL,
data_consumed TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (store_id) REFERENCES stores(id),
PRIMARY KEY (id)
);