-
Notifications
You must be signed in to change notification settings - Fork 0
/
sqlcreate.sql
37 lines (30 loc) · 939 Bytes
/
sqlcreate.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
create database `order`;
USE `order`;
CREATE TABLE `USER`(
USER_ID VARCHAR(20) PRIMARY KEY,
NAME NVARCHAR(25) NOT NULL,
PASSWORD VARCHAR(30) NOT NULL,
`E-MAIL` VARCHAR(255) NOT NULL,
PERMISSION INT NOT NULL
);
CREATE TABLE `TYPE`(
TYPE_ID INT PRIMARY KEY,
NAME NVARCHAR(20) NOT NULL
);
CREATE TABLE `STATUS`(
STATUS_ID INT PRIMARY KEY,
`STATUS` NCHAR(8) NOT NULL
);
CREATE TABLE PRODUCTS(
PRODUCT_ID INT AUTO_INCREMENT PRIMARY KEY,
`TYPE` INT NOT NULL,
NAME NVARCHAR(50) NOT NULL,
PRICE INT NOT NULL,
ORDER_DATE DATE NOT NULL,
DELIVERY_DATE DATE,
ORDER_STATUS INT NOT NULL,
ORDER_USER VARCHAR(20) NOT NULL,
FOREIGN KEY (ORDER_USER) REFERENCES `USER`(USER_ID),
FOREIGN KEY (`TYPE`) REFERENCES `TYPE`(TYPE_ID),
FOREIGN KEY (ORDER_STATUS) REFERENCES `STATUS`(STATUS_ID)
);