-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelivery_db.sql
More file actions
50 lines (41 loc) · 1.15 KB
/
delivery_db.sql
File metadata and controls
50 lines (41 loc) · 1.15 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
CREATE DATABASE delivery_db;
USE delivery_db;
CREATE table user(
id INT primary key auto_increment,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE NOT NULL,
phone VARCHAR(20),
address VARCHAR(255) NOT NULL
);
CREATE TABLE restaurats(
id INT primary KEY auto_increment,
nombre VARCHAR(100) NOT NULL,
direccion VARCHAR(255) NOT NULL unique,
telefono VARCHAR(28) NOT NULL
);
CREATE TABLE products(
id INT PRIMARY KEY auto_increment,
restaurants_id INT,
nombre VARCHAR(100) NOT NULL,
descripcion text(100),
precio decimal(10.2) NOT NULL,
foreign key(restaurants_id) references restaurats (id)
);
CREATE TABLE pedidos(
id INT PRIMARY KEY auto_increment,
user_id INT NOT NULL,
restaurants_id INT NOT NULL,
fecha timestamp default current_timestamp,
estado varchar(50) default 'Pendiente',
foreign key(user_id) references user(id),
foreign key(restaurants_id) references restaurats (id)
);
CREATE TABLE detalles_Pedido(
id INT PRIMARY KEY AUTO_INCREMENT,
pedidos_id INT NOT NULL,
products_id INT NOT NULL,
cantidad INT NOT NULL,
precio_Unitario DECIMAL(10,2)NOT NULL,
foreign key(pedidos_id) references pedidos (id),
foreign key(products_id) references products (id)
);