Advertisement
Guest User

SCRIPT TABLAS COMUNA

a guest
Sep 12th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. CREATE TABLE IF NOT EXISTS artista (
  2. cuit INT PRIMARY KEY,
  3. descripcion VARCHAR(50) NOT NULL,
  4. telefono INT NOT NULL,
  5. email VARCHAR(50),
  6. actividad VARCHAR(50) NOT NULL,
  7. nombre_comercial VARCHAR(50) NOT NULL,
  8. nombre VARCHAR(50) NOT NULL,
  9. apellido VARCHAR(50) NOT NULL
  10. ) ENGINE = InnoDB;
  11.  
  12. create table if not exists evento (
  13. nro INT AUTO_INCREMENT PRIMARY KEY,
  14. descripcion VARCHAR(50) NOT NULL,
  15. fecha_hora_ini DATETIME NOT NULL,
  16. fecha_hora_fin DATETIME NOT NULL
  17. ) ENGINE = InnoDB;
  18.  
  19. create table if not exists jurado (
  20. dni INT PRIMARY KEY,
  21. nombre VARCHAR(50) NOT NULL,
  22. apellido VARCHAR(50) NOT NULL,
  23. especialidades VARCHAR(50) NOT NULL,
  24. telefono VARCHAR(50) NOT NULL
  25. ) ENGINE = InnoDB;
  26.  
  27. create table if not exists lugar (
  28. codigo INT PRIMARY KEY,
  29. nombre VARCHAR(50) NOT NULL,
  30. direccion VARCHAR(50) NOT NULL,
  31. url_gps VARCHAR(50)
  32. ) ENGINE = InnoDB;
  33.  
  34. create table if not exists persona (
  35. dni INT PRIMARY KEY,
  36. nombre VARCHAR(50) NOT NULL,
  37. apellido VARCHAR(50) NOT NULL,
  38. telefono VARCHAR(50),
  39. email VARCHAR(50),
  40. fecha_nac DATE NOT NULL
  41. ) ENGINE = InnoDB;
  42.  
  43. create table if not exists recurso (
  44. codigo INT PRIMARY KEY AUTO_INCREMENT,
  45. descripcion VARCHAR(100) NOT NULL
  46. ) ENGINE = InnoDB;
  47.  
  48. create table if not exists tipo_competencia (
  49. codigo INT AUTO_INCREMENT PRIMARY KEY,
  50. descripcion VARCHAR(100) NOT NULL,
  51. reglas TEXT
  52. ) ENGINE = InnoDB;
  53.  
  54. create table if not exists valor_diario (
  55. codigo_recurso INT NOT NULL,
  56. fecha_desde DATE NOT NULL,
  57. valor INT NOT NULL,
  58. PRIMARY KEY(codigo_recurso, fecha_desde),
  59. CONSTRAINT fk_valordiario_recurso
  60. FOREIGN KEY(codigo_recurso)
  61. REFERENCES recurso(codigo)
  62. on update cascade
  63. on delete restrict
  64. ) Engine = InnoDB;
  65.  
  66. create table if not exists alquiler (
  67. nro_evento int,
  68. codigo_recurso int,
  69. cantidad int not null,
  70. primary key (nro_evento,codigo_recurso),
  71. constraint fk_alquiler_recurso
  72. foreign key(codigo_recurso)
  73. references recurso(codigo)
  74. on update cascade
  75. on delete restrict,
  76. constraint fk_alquiler_evento
  77. foreign key(nro_evento)
  78. references evento(nro)
  79. on update cascade
  80. on delete restrict) engine = InnoDB;
  81.  
  82. #####Ver los unsigned
  83.  
  84. create table if not exists organizador (
  85. nro_evento int,
  86. dni_persona int,
  87. primary key(nro_evento,dni_persona),
  88. constraint fk_organizador_evento
  89. foreign key (nro_evento)
  90. references evento(nro)
  91. on update cascade
  92. on delete restrict,
  93. constraint fk_organizador_persona
  94. foreign key (dni_persona)
  95. references persona (dni)
  96. on update cascade
  97. on delete restrict) engine = InnoDB;
  98.  
  99. create table if not exists participante (
  100. dni_persona int,
  101. nro_evento int,
  102. codigo_tipo_competencia int,
  103. fecha_hora_inscripcion datetime not null,
  104. primary key (dni_persona,nro_evento,codigo_tipo_competencia),
  105.  
  106. constraint fk_participante_competencia
  107. foreign key(nro_evento,codigo_tipo_competencia)
  108. references competencia(nro_evento, codigo_tipo_competencia)
  109. on update cascade
  110. on delete restrict,
  111.  
  112. constraint fk_participante_persona
  113. foreign key (dni_persona)
  114. references persona(dni)
  115. on update cascade
  116. on delete restrict) engine = InnoDB;
  117.  
  118. create table if not exists competencia (
  119. nro_evento int,
  120. codigo_tipo_competencia int,
  121. descripcion varchar(50) not null,
  122. fecha_hora_ini datetime not null,
  123. fecha_hora_fin_est datetime not null,
  124. premios text not null,
  125. costo_inscripcion int not null,
  126. dni_jurado int not null,
  127. primary key(nro_evento, codigo_tipo_competencia),
  128. constraint fk_competencia_evento
  129. foreign key (nro_evento)
  130. references evento(nro)
  131. on update cascade
  132. on delete restrict,
  133. constraint fk_competencia_jurado
  134. foreign key (dni_jurado)
  135. references jurado(dni)
  136. on update cascade
  137. on delete restrict,
  138. constraint fk_competencia_tipoCompetencia
  139. foreign key (codigo_tipo_competencia)
  140. references tipo_competencia(codigo)
  141. on update cascade
  142. on delete restrict) engine = InnoDB;
  143.  
  144. create table if not exists espectaculo (
  145.  
  146. nro_espectaculo int,
  147. nombre varchar(50) not null,
  148. fecha_hora_ini datetime not null,
  149. fecha_hora_fin datetime not null,
  150. costo_cont int not null,
  151. nro_evento int unsigned not null,
  152. cuit_artista int unsigned,
  153. codigo_lugar int unsigned,
  154. primary key (nro_espectaculo, nro_evento),
  155.  
  156. constraint fk_espectaculo_evento
  157. foreign key (nro_evento)
  158. references evento(nro)
  159. on update cascade
  160. on delete restrict,
  161.  
  162. constraint fk_espectaculo_artista
  163. foreign key (cuit_artista)
  164. references artista(cuit)
  165. on update cascade
  166. on delete restrict,
  167.  
  168. constraint fk_espectaculo_lugar
  169. foreign key (codigo_lugar)
  170. references lugar(codigo)
  171. on update cascade
  172. on delete restrict) engine = InnoDB;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement