-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts_bd.sql
More file actions
56 lines (47 loc) · 1.54 KB
/
scripts_bd.sql
File metadata and controls
56 lines (47 loc) · 1.54 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
-- Creación de tablas
CREATE TABLE IF NOT EXISTS usuarios (
id INTEGER PRIMARY KEY AUTOINCREMENT,
nombre TEXT NOT NULL,
correo TEXT NOT NULL UNIQUE,
password TEXT NOT NULL,
telefono TEXT,
direccion TEXT
);
CREATE TABLE IF NOT EXISTS pasteles (
id INTEGER PRIMARY KEY AUTOINCREMENT,
nombre TEXT NOT NULL,
descripcion TEXT,
imagen TEXT,
precio REAL NOT NULL
);
CREATE TABLE IF NOT EXISTS personalizaciones (
id INTEGER PRIMARY KEY AUTOINCREMENT,
usuario_id INTEGER,
pastel_id INTEGER,
tamano TEXT,
dedicatoria TEXT,
extras TEXT,
estado TEXT DEFAULT 'pendiente',
FOREIGN KEY (usuario_id) REFERENCES usuarios(id),
FOREIGN KEY (pastel_id) REFERENCES pasteles(id)
);
CREATE TABLE IF NOT EXISTS pedidos (
id INTEGER PRIMARY KEY AUTOINCREMENT,
usuario_id INTEGER,
fecha TEXT,
total REAL,
metodo_pago TEXT,
FOREIGN KEY (usuario_id) REFERENCES usuarios(id)
);
CREATE TABLE IF NOT EXISTS detalles_pedido (
id INTEGER PRIMARY KEY AUTOINCREMENT,
pedido_id INTEGER,
personalizacion_id INTEGER,
FOREIGN KEY (pedido_id) REFERENCES pedidos(id),
FOREIGN KEY (personalizacion_id) REFERENCES personalizaciones(id)
);
-- Datos de ejemplo
INSERT INTO usuarios (nombre, correo, password, telefono, direccion)
VALUES ('Usuario de Prueba', 'usuario@cakelab.com', '1234', '6671234567', 'Calle Falsa 123');
INSERT INTO pasteles (nombre, descripcion, imagen, precio)
VALUES ('Pastel de Chocolate', 'Delicioso pastel con betún de chocolate', 'chocolate.jpg', 350.00);