Advertisement
Hatkat

Base de datos - PROYECTO

Jan 17th, 2024
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 4.43 KB | None | 0 0
  1. create database circo;
  2. use circo;
  3.  
  4. create table usuario(
  5.     idUsuario smallint not null auto_increment,
  6.     nombreUsuario varchar(50) not null,
  7.     apellidoUsuario varchar(50) not null,
  8.     cedulaUsuario varchar(10) not null,
  9.     edadUsuario date not null,
  10.     userUsuario varchar(50) not null,
  11.     passwordUsuario varchar(50) not null,
  12.     Primary key(idUsuario)
  13. );
  14.  
  15. create table direccion(
  16.     idDireccion smallint not null auto_increment,
  17.     nombreDireccion varchar(50) not null,
  18.     Primary key(idDireccion)
  19. );
  20. INSERT INTO direccion (nombreDireccion) VALUES
  21.     ('Malecón Simón Bolívar'),
  22.     ('Cdla. Kennedy'),
  23.     ('Urdesa Central'),
  24.     ('Sauces 8'),
  25.     ('La Alborada'),
  26.     ('Centro de Guayaquil'),
  27.     ('Los Ceibos');
  28.  
  29.  
  30. create table evento(
  31.     idEvento smallint not null auto_increment,
  32.     nombreEvento varchar(50) not null,
  33.     fechaEvento date not null,
  34.     horaInicioEvento time not null,
  35.     cantidadPersonasEvento smallint not null,
  36.     idDireccion smallint not null,
  37.     Primary key(idEvento),
  38.     foreign key(idDireccion) references direccion(idDireccion)
  39.     on delete restrict
  40.     on update cascade
  41. );
  42. INSERT INTO evento (nombreEvento, fechaEvento, horaInicioEvento, cantidadPersonasEvento, idDireccion) VALUES
  43.     ('Malabarismo', '2024-02-05', '18:00:00', 500, 1),
  44.     ('Payaso Show', '2024-02-08', '15:30:00', 300, 2),
  45.     ('Acrobacias Estelar', '2024-03-12', '15:45:00', 700, 3),
  46.     ('Magia Mística', '2024-03-15', '17:00:00', 200, 4),
  47.     ('Un Show de Circo', '2024-03-18', '10:15:00', 300, 5),
  48.     ('Circo Infantil Aventuras', '2024-01-22', '14:00:00', 200, 6),
  49.     ('Trapecistas Show', '2024-03-25', '16:30:00', 300, 7),
  50.     ('Circo Emoción', '2024-03-28', '15:00:00', 450, 1),
  51.     ('Show Circo', '2024-03-29', '11:00:00', 180, 3),
  52.     ('Circo Musical', '2024-04-26', '13:30:00', 200, 2);
  53.  
  54.  
  55. create table localidad(
  56.     idLocalidad smallint not null auto_increment,
  57.     nombreLocalidad varchar(50) not null,
  58.     precioLocalidad float not null,
  59.     Primary key(idLocalidad)
  60. );
  61. INSERT INTO localidad (nombreLocalidad, precioLocalidad) VALUES
  62.     ('Platea VIP', 30.50),
  63.     ('Platea Preferencial', 25.00),
  64.     ('Tribuna Central', 20.00),
  65.     ('Tribuna Lateral', 15.50),
  66.     ('Palco VIP', 40.00),
  67.     ('Palco Lateral', 35.00),
  68.     ('Gradas Frontales', 18.00),
  69.     ('Gradas Laterales', 16.50),
  70.     ('Gradas Superiores', 22.00),
  71.     ('Gradas Inferiores', 12.00);
  72.  
  73. create table eventoLocalidad(
  74.     idEventoLocalidad smallint not null auto_increment,
  75.     idEvento smallint not null,
  76.     idLocalidad smallint not null,
  77.     cantidadPorEventoLocalidad smallint not null,
  78.     Primary key(idEventoLocalidad),
  79.     foreign key(idEvento) references evento(idEvento)
  80.     on delete restrict
  81.     on update cascade,
  82.     foreign key(idLocalidad) references localidad(idLocalidad)
  83.     on delete restrict
  84.     on update cascade
  85. );
  86. INSERT INTO eventoLocalidad (idEvento, idLocalidad, cantidadPorEventoLocalidad) VALUES
  87.     (1, 1, 200),
  88.     (1, 2, 150),
  89.     (1, 3, 150),
  90.     (2, 4, 100),
  91.     (2, 5, 200),
  92.     (3, 6, 250),
  93.     (3, 7, 450),
  94.     (4, 8, 120),
  95.     (4, 9, 80),  
  96.     (5, 10, 300),
  97.     (6, 1, 150),
  98.     (6, 2, 50),
  99.     (7, 3, 180),
  100.     (7, 4, 120),
  101.     (8, 5, 250),
  102.     (8, 6, 200),
  103.     (9, 7, 100),
  104.     (9, 8, 80),
  105.     (10, 9, 120),
  106.     (10, 10, 80);
  107.  
  108. create table descuento(
  109.     idDescuento  smallint not null auto_increment,
  110.     tipoDescuento varchar(100) not null,
  111.     porcentajeDescuento smallint not null,
  112.     Primary key(idDescuento)
  113. );
  114. INSERT INTO descuento (tipoDescuento, porcentajeDescuento)
  115. VALUES ('Edad', 5);
  116. INSERT INTO descuento (tipoDescuento, porcentajeDescuento)
  117. VALUES ('Discapacidad', 10);
  118.  
  119. create table entrada(
  120.     idEntrada smallint not null auto_increment,
  121.     idEvento smallint not null,
  122.     cantidadPersonasEntrada smallint not null,
  123.     Primary key(idEntrada),
  124.     foreign key(idEvento) references evento(idEvento)
  125.     on delete restrict
  126.     on update cascade
  127. );
  128.  
  129. create table factura(
  130.     idFactura smallint not null auto_increment,
  131.     fechaFactura date not null,
  132.     idUsuario smallint not null,
  133.     idEntrada smallint not null,
  134.     descripcionFactura text not null,
  135.     totalFactura float not null,
  136.     Primary key(idFactura),
  137.     foreign key(idUsuario) references usuario(idUsuario)
  138.     on delete restrict
  139.     on update cascade,
  140.     foreign key(idEntrada) references entrada(idEntrada)
  141.     on delete restrict
  142.     on update cascade
  143. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement