Repository navigation
Expand file tree
/
Copy paththespoon.sql
More file actions
170 lines (135 loc) · 6.01 KB
/
Copy paththespoon.sql
File metadata and controls
170 lines (135 loc) · 6.01 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
DROP DATABASE IF EXISTS thespoon;
CREATE DATABASE thespoon;
use thespoon;
-- thespoon.prodotto definition
CREATE TABLE `prodotto` (
`id_prodotto` int NOT NULL AUTO_INCREMENT,
`Nome` char(30) NOT NULL,
`Descrizione` varchar(2000) NOT NULL,
`Prezzo` decimal(10,2) NOT NULL,
`idristorante` int NOT NULL,
PRIMARY KEY (`id_prodotto`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.ristorante definition
CREATE TABLE `ristorante` (
`id_ristorante` int NOT NULL AUTO_INCREMENT,
`Nome` varchar(50) NOT NULL,
`N_Civico` varchar(3) NOT NULL,
`Cap` int NOT NULL,
`Via` varchar(100) NOT NULL,
`Provincia` varchar(2) NOT NULL,
`Telefono` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
PRIMARY KEY (`id_ristorante`),
FULLTEXT KEY `ristorante_Nome_IDX` (`Nome`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.ristoratore definition
CREATE TABLE `ristoratore` (
`id` int unsigned NOT NULL AUTO_INCREMENT,
`Password` binary(60) NOT NULL,
`Nome` varchar(20) NOT NULL,
`Cognome` varchar(20) NOT NULL,
`Email` varchar(20) NOT NULL,
`Telefono` varchar(20) NOT NULL,
`Data_Nascita` date NOT NULL,
`Genere` char(1) DEFAULT NULL,
`role` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email_unique` (`Email`)
) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.menu definition
CREATE TABLE `menu` (
`id_menu` int NOT NULL AUTO_INCREMENT,
`Nome` char(30) NOT NULL,
`Categoria` char(30) NOT NULL,
`fk_id_ristorante` int NOT NULL,
PRIMARY KEY (`id_menu`),
KEY `menu_ristorante_FK` (`fk_id_ristorante`),
CONSTRAINT `menu_ristorante_FK` FOREIGN KEY (`fk_id_ristorante`) REFERENCES `ristorante` (`id_ristorante`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.menuprodotto definition
CREATE TABLE `menuprodotto` (
`id_prodotto` int NOT NULL,
`id_menu` int NOT NULL,
UNIQUE KEY `menuprodotto_unique` (`id_prodotto`,`id_menu`),
KEY `IdMenu` (`id_menu`),
CONSTRAINT `menuprodotto_ibfk_1` FOREIGN KEY (`id_prodotto`) REFERENCES `prodotto` (`id_prodotto`),
CONSTRAINT `menuprodotto_ibfk_2` FOREIGN KEY (`id_menu`) REFERENCES `menu` (`id_menu`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.ordine definition
CREATE TABLE `ordine` (
`IdRistorante` int NOT NULL,
`IdOrdine` int NOT NULL AUTO_INCREMENT,
`Tipologia` tinyint(1) NOT NULL,
`Ora` time DEFAULT NULL,
`Nr_Tavolo` char(2) DEFAULT NULL,
`Quantita` int DEFAULT NULL,
`Totale` decimal(10,2) NOT NULL,
`ChatId` int NOT NULL,
`Stato` tinyint(1) NOT NULL,
PRIMARY KEY (`IdOrdine`),
KEY `IdRistorante` (`IdRistorante`),
CONSTRAINT `ordine_ibfk_1` FOREIGN KEY (`IdRistorante`) REFERENCES `ristorante` (`id_ristorante`)
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.possiede definition
CREATE TABLE `possiede` (
`id_ristorante` int NOT NULL,
`id` int unsigned NOT NULL,
KEY `IdRistorante` (`id_ristorante`),
KEY `Id` (`id`),
CONSTRAINT `possiede_ibfk_1` FOREIGN KEY (`id_ristorante`) REFERENCES `ristorante` (`id_ristorante`),
CONSTRAINT `possiede_ibfk_2` FOREIGN KEY (`id`) REFERENCES `ristoratore` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.prenotazione definition
CREATE TABLE `prenotazione` (
`IdPrenotazione` int NOT NULL AUTO_INCREMENT,
`Data` date NOT NULL,
`Ora` time NOT NULL,
`Nr_Persone` int NOT NULL,
`Email` varchar(100) NOT NULL,
`Cellulare` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
`chatid` int NOT NULL,
`IdRistorante` int NOT NULL,
`Stato` tinyint NOT NULL,
`PasswordPrenotazione` varchar(100) NOT NULL,
PRIMARY KEY (`IdPrenotazione`),
KEY `prenotazione_ristorante_FK` (`IdRistorante`),
CONSTRAINT `prenotazione_ristorante_FK` FOREIGN KEY (`IdRistorante`) REFERENCES `ristorante` (`id_ristorante`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.prodotto_ordine definition
CREATE TABLE `prodotto_ordine` (
`id_prodotto` int NOT NULL,
`idOrdine` int NOT NULL,
`Quantita` int NOT NULL,
KEY `prodotto_ordine_prodotto_FK` (`id_prodotto`),
KEY `prodotto_ordine_ordine_FK` (`idOrdine`),
CONSTRAINT `prodotto_ordine_ordine_FK` FOREIGN KEY (`idOrdine`) REFERENCES `ordine` (`IdOrdine`),
CONSTRAINT `prodotto_ordine_prodotto_FK` FOREIGN KEY (`id_prodotto`) REFERENCES `prodotto` (`id_prodotto`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.tavolo definition
CREATE TABLE `tavolo` (
`NumeroTavolo` varchar(2) NOT NULL,
`Stato` tinyint(1) NOT NULL,
`Capacita` int NOT NULL,
`id_ristorante` int NOT NULL,
PRIMARY KEY (`NumeroTavolo`),
KEY `tavolo_ristorante_FK` (`id_ristorante`),
CONSTRAINT `tavolo_ristorante_FK` FOREIGN KEY (`id_ristorante`) REFERENCES `ristorante` (`id_ristorante`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.prenota definition
CREATE TABLE `prenota` (
`IdPrenotazione` int NOT NULL,
`IdRistorante` int NOT NULL,
KEY `IdPrenotazione` (`IdPrenotazione`),
KEY `IdRistorante` (`IdRistorante`),
CONSTRAINT `prenota_ibfk_1` FOREIGN KEY (`IdPrenotazione`) REFERENCES `prenotazione` (`IdPrenotazione`),
CONSTRAINT `prenota_ibfk_2` FOREIGN KEY (`IdRistorante`) REFERENCES `ristorante` (`id_ristorante`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
-- thespoon.prenotazionetavolo definition
CREATE TABLE `prenotazionetavolo` (
`IdPrenotazione` int DEFAULT NULL,
`NumeroTavolo` varchar(2) DEFAULT NULL,
KEY `IdPrenotazione` (`IdPrenotazione`),
KEY `NumeroTavolo` (`NumeroTavolo`),
CONSTRAINT `prenotazionetavolo_ibfk_2` FOREIGN KEY (`IdPrenotazione`) REFERENCES `prenotazione` (`IdPrenotazione`),
CONSTRAINT `prenotazionetavolo_ibfk_3` FOREIGN KEY (`NumeroTavolo`) REFERENCES `tavolo` (`NumeroTavolo`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;