TicketMerc/Interfaz/conticket.sql

28 lines
1.0 KiB
SQL

CREATE DATABASE IF NOT EXISTS conticket;
USE conticket;
drop table asientos;
DELETE FROM asientos;
ALTER TABLE asientos AUTO_INCREMENT = 1;
-- Tabla para almacenar los asientos
CREATE TABLE asientos (
id INT AUTO_INCREMENT PRIMARY KEY,
artista VARCHAR(50) NOT NULL, -- Nombre del artista/concierto
dia INT NOT NULL, -- Día del evento (22, 23, 24)
asiento VARCHAR(10) NOT NULL, -- Identificador del asiento (ej: 1A, 2B)
estado ENUM('disponible', 'vendido') DEFAULT 'disponible' -- Estado del asiento
);
-- Tabla para registrar las ventas
CREATE TABLE ventas (
id INT AUTO_INCREMENT PRIMARY KEY,
asiento_id INT NOT NULL, -- ID del asiento vendido
fecha_venta DATETIME DEFAULT CURRENT_TIMESTAMP, -- Fecha y hora de la venta
precio DECIMAL(10, 2) NOT NULL, -- Precio del boleto
FOREIGN KEY (asiento_id) REFERENCES asientos(id)
);
INSERT INTO ventas (asiento_id, fecha_venta, precio) VALUES
(1, '2023-10-01 10:00:00', 100),
(2, '2023-10-02 11:00:00', 150),
(3, '2023-10-03 12:00:00', 200);