· 5 years ago · May 07, 2020, 07:20 PM
1CREATE DATABASE IF NOT EXISTS `restaurant`;
2USE `restaurant`;
3
4--
5-- Table structure for table `employee`
6--
7
8
9
10DROP TABLE IF EXISTS `listaProdus`;
11DROP TABLE IF EXISTS `produs`;
12DROP TABLE IF EXISTS `comanda`;
13DROP TABLE IF EXISTS `masa`;
14DROP TABLE IF EXISTS `staff`;
15
16CREATE TABLE staff (
17 idStaff int(11) NOT NULL AUTO_INCREMENT,
18 nume varchar(45) DEFAULT NULL,
19 prenume varchar(45) DEFAULT NULL,
20 nrComLivrate int(11) DEFAULT NULL,
21 parola varchar(45) DEFAULT NULL,
22 PRIMARY KEY (idStaff)
23);
24
25
26
27CREATE TABLE masa (
28 idMasa int NOT NULL AUTO_INCREMENT,
29 locuri int,
30 PRIMARY KEY (idMasa)
31);
32
33
34
35CREATE TABLE comanda (
36 idComanda int(11) NOT NULL AUTO_INCREMENT,
37 idStaff int(11) NOT NULL,
38 idMasa int(11) NOT NULL,
39 dataComanda datetime DEFAULT NULL,
40 total int,
41 finalizata boolean DEFAULT FALSE,
42 PRIMARY KEY (idComanda),
43 FOREIGN KEY (idMasa)
44 references masa(idMasa) on delete cascade,
45 FOREIGN KEY (idStaff)
46 references staff(idStaff) on delete cascade
47);
48
49
50
51CREATE TABLE produs (
52 idProdus int NOT NULL AUTO_INCREMENT,
53 nume varchar(20) NOT NULL,
54 tip varchar(20) NOT NULL ,
55 cantitate varchar(10) NOT NULL,
56 pret int NOT NULL,
57 popularitate int DEFAULT 0,
58 descriere varchar(100),
59 PRIMARY KEY (idProdus)
60);
61
62
63
64CREATE TABLE listaProdus (
65 idListaProdus int NOT NULL AUTO_INCREMENT,
66 idComanda int NOT NULL,
67 idProdus int NOT NULL,
68 cantitate int DEFAULT 1,
69 PRIMARY KEY (idListaProdus),
70 FOREIGN KEY (idComanda)
71 references comanda(idComanda) on delete cascade,
72 FOREIGN KEY (idProdus)
73 references produs(idProdus) on delete cascade
74);