-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_table.sql
More file actions
34 lines (30 loc) · 834 Bytes
/
create_table.sql
File metadata and controls
34 lines (30 loc) · 834 Bytes
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
-- Table 1: Users
CREATE TABLE Users (
user_id NUMBER PRIMARY KEY
);
-- Table 2: Departments
CREATE TABLE Departments2 (
department_id NUMBER PRIMARY KEY,
department VARCHAR2(255)
);
-- Table 3: Products
CREATE TABLE Products (
product_id NUMBER PRIMARY KEY,
department_id NUMBER REFERENCES Departments2(department_id),
product_name VARCHAR2(255)
);
-- Table 4: Orders
CREATE TABLE Orders (
order_id NUMBER PRIMARY KEY,
user_id NUMBER REFERENCES Users(user_id),
order_dow NUMBER,
order_hour_of_day NUMBER,
days_since_prior_order NUMBER
);
-- Table 5: Order Details
CREATE TABLE Order_Details (
order_id NUMBER REFERENCES Orders(order_id),
product_id NUMBER REFERENCES Products(product_id),
add_to_cart_order NUMBER,
reordered NUMBER
);