-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQL statements
59 lines (54 loc) · 1.37 KB
/
SQL statements
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
CREATE TABLE FN_USER (
ID SERIAL NOT NULL,
NAME varchar(25) NOT NULL,
LASTMANE varchar(25) NOT NULL,
EMAIL varchar(50) NOT NULL,
BIRTHDATE date NOT NULL,
PASSWORD varchar(20) NOT NULL,
FN_USER_LEVEL INT NOT NULL,
PRIMARY KEY(ID)
);
CREATE TABLE ADDRESS (
ID SERIAL NOT NULL,
FN_USER_ID INT NOT NULL,
STREET varchar(50) NOT NULL,
STREET_NUMBER INT NOT NULL,
TYPE char(1) NOT NULL,
PRIMARY KEY(ID),
FOREIGN KEY(FN_USER_ID) REFERENCES FN_USER
);
CREATE TABLE RESTAURANT (
ID SERIAL NOT NULL,
MINAMOUNT real NOT NULL,
DESCRIPTION text NOT NULL,
NAME varchar(30) NOT NULL,
PRIMARY KEY(ID)
);
CREATE TABLE FN_ORDER (
ID SERIAL NOT NULL,
FN_USER_ID INT NOT NULL,
ADDRESS_ID INT NOT NULL,
TOTAL real NOT NULL,
RESTAURANT_ID INT NOT NULL,
FN_ORDER_DATE timestamp NOT NULL,
PRIMARY KEY(ID),
FOREIGN KEY(FN_USER_ID) REFERENCES FN_USER,
FOREIGN KEY(ADDRESS_ID) REFERENCES ADDRESS,
FOREIGN KEY(RESTAURANT_ID) REFERENCES RESTAURANT
);
CREATE TABLE DISH (
ID SERIAL NOT NULL,
DESCRIPTION text NOT NULL,
PRICE real NOT NULL,
NAME varchar(30) NOT NULL,
RESTAURANT_ID INT NOT NULL,
MENU_CATEGORY varchar(30) NOT NULL,
PRIMARY KEY(ID),
FOREIGN KEY(RESTAURANT_ID) REFERENCES RESTAURANT
);
CREATE TABLE FN_ORDER_DISH (
FN_ORDER_ID INT NOT NULL,
DISH_ID INT NOT NULL,
FOREIGN KEY(FN_ORDER_ID) REFERENCES FN_ORDER,
FOREIGN KEY(DISH_ID) REFERENCES DISH
);