-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_create_tables.sql
More file actions
72 lines (65 loc) · 1.59 KB
/
Copy path02_create_tables.sql
File metadata and controls
72 lines (65 loc) · 1.59 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
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
USE business_performance;
CREATE TABLE stores (
store_id INT PRIMARY KEY,
store_name VARCHAR(100) NOT NULL,
city VARCHAR(50),
state VARCHAR(50),
region VARCHAR(20),
store_type VARCHAR(30),
opening_date DATE
);
CREATE TABLE employees (
employee_id INT PRIMARY KEY,
employee_name VARCHAR(100) NOT NULL,
job_role VARCHAR(50),
store_id INT,
hire_date DATE,
salary DECIMAL(10,2),
FOREIGN KEY (store_id)
REFERENCES stores(store_id)
);
CREATE TABLE products (
product_id INT PRIMARY KEY,
product_name VARCHAR(100) NOT NULL,
department VARCHAR(50),
category VARCHAR(50),
cost_price DECIMAL(10,2),
selling_price DECIMAL(10,2)
);
CREATE TABLE customers (
customer_id INT PRIMARY KEY,
customer_name VARCHAR(100) NOT NULL,
gender VARCHAR(10),
age INT,
city VARCHAR(50),
membership_type VARCHAR(30)
);
CREATE TABLE sales (
sale_id INT PRIMARY KEY,
sale_date DATE,
store_id INT,
employee_id INT,
customer_id INT,
product_id INT,
quantity INT,
discount DECIMAL(5,2),
FOREIGN KEY (store_id)
REFERENCES stores(store_id),
FOREIGN KEY (employee_id)
REFERENCES employees(employee_id),
FOREIGN KEY (customer_id)
REFERENCES customers(customer_id),
FOREIGN KEY (product_id)
REFERENCES products(product_id)
);
CREATE TABLE targets (
target_id INT PRIMARY KEY,
store_id INT,
target_month DATE,
sales_target DECIMAL(12,2),
FOREIGN KEY (store_id)
REFERENCES stores(store_id)
);
SHOW TABLES;
DESCRIBE stores;
DESCRIBE sales;