Creacion de la base de datos

This commit is contained in:
Christopher Alessandro Rodriguez Salazar 2025-03-05 07:30:31 -06:00
parent 4980b76fb3
commit 48f29f64b1
1 changed files with 48 additions and 0 deletions

48
BookTicketDB.sql Normal file
View File

@ -0,0 +1,48 @@
CREATE DATABASE bookticket;
USE bookticket;
CREATE TABLE conciertos (
id INT auto_increment primary key,
nombre varchar(50) not null,
fecha date not null
);
CREATE TABLE asientos (
id INT AUTO_INCREMENT PRIMARY KEY,
numasiento INT UNIQUE NOT NULL,
precio_base DECIMAL(10,2) NOT NULL
);
-- Tabla de boletos (relaciona cada asiento con un concierto específico)
CREATE TABLE boleto (
id INT AUTO_INCREMENT PRIMARY KEY,
id_asiento INT NOT NULL,
idevento INT NOT NULL,
status ENUM('disponible', 'vendido') DEFAULT 'disponible',
fechaVenta DATE NULL,
FOREIGN KEY (id_asiento) REFERENCES asientos(id),
FOREIGN KEY (idevento) REFERENCES conciertos(id)
);
INSERT INTO conciertos (nombre, fecha) VALUES
('Concierto Rock', '2025-06-15'),
('Festival de Jazz', '2025-07-20'),
('Pop Night', '2025-08-10');
INSERT INTO asientos (numasiento, precio_base) VALUES
(1, 120.00), (2, 140.00), (3, 150.00), (4, 140.00), (5, 120.00),
(6, 100.00), (7, 120.00), (8, 130.00), (9, 120.00), (10, 100.00),
(11, 80.00), (12, 100.00), (13, 110.00), (14, 100.00), (15, 80.00),
(16, 60.00), (17, 80.00), (18, 90.00), (19, 80.00), (20, 60.00);
INSERT INTO boleto (id_asiento, idevento) VALUES
-- Concierto Rock
(1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1), (7, 1), (8, 1), (9, 1), (10, 1),
(11, 1), (12, 1), (13, 1), (14, 1), (15, 1), (16, 1), (17, 1), (18, 1), (19, 1), (20, 1),
-- Festival de Jazz
(1, 2), (2, 2), (3, 2), (4, 2), (5, 2), (6, 2), (7, 2), (8, 2), (9, 2), (10, 2),
(11, 2), (12, 2), (13, 2), (14, 2), (15, 2), (16, 2), (17, 2), (18, 2), (19, 2), (20, 2),
-- Pop Night
(1, 3), (2, 3), (3, 3), (4, 3), (5, 3), (6, 3), (7, 3), (8, 3), (9, 3), (10, 3),
(11, 3), (12, 3), (13, 3), (14, 3), (15, 3), (16, 3), (17, 3), (18, 3), (19, 3), (20, 3);