Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.85 KB | None | 0 0
  1. /*==============================================================*/
  2. /* DBMS name: MySQL 5.0 */
  3. /* Created on: 12/07/2011 04:44:08 p.m. */
  4. /*==============================================================*/
  5.  
  6.  
  7. drop table if exists ASUNTO;
  8.  
  9. drop table if exists CASO;
  10.  
  11. drop table if exists CEDULA;
  12.  
  13. drop table if exists CLIENTE;
  14.  
  15. drop table if exists DEPARTAMENTO;
  16.  
  17. drop table if exists DIRECCION;
  18.  
  19. drop table if exists ESTUDIANTE;
  20.  
  21. drop table if exists MUNICIPIO;
  22.  
  23. drop table if exists NACIONALIDAD;
  24.  
  25. drop table if exists SEGUIMIENTOS;
  26.  
  27. drop table if exists TELEFONO;
  28.  
  29. drop table if exists TIPO;
  30.  
  31. /*==============================================================*/
  32. /* Table: ASUNTO */
  33. /*==============================================================*/
  34. create table ASUNTO
  35. (
  36. ID_ASUNTO int unsigned not null auto_increment,
  37. ASUNTO varchar(50),
  38. primary key (ID_ASUNTO)
  39. );
  40.  
  41. /*==============================================================*/
  42. /* Table: CASO */
  43. /*==============================================================*/
  44. create table CASO
  45. (
  46. ID_CASO int unsigned not null auto_increment,
  47. NO_CARNE int unsigned,
  48. ID_ASUNTO tinyint,
  49. ID_TIPO_CASO tinyint,
  50. FECHA_INICIO date,
  51. FECHA_FENECIDO date,
  52. DESCRIPCION_CASO varchar(254),
  53. NO_FOLIO smallint,
  54. OBSERVACIONES nvarchar(254),
  55. MEMORIAL tinyint,
  56. primary key (ID_CASO)
  57. );
  58.  
  59. /*==============================================================*/
  60. /* Table: CEDULA */
  61. /*==============================================================*/
  62. create table CEDULA
  63. (
  64. ID_CEDULADPI int unsigned not null auto_increment,
  65. NO_CARNE int,
  66. NO_ORDEN char(4),
  67. NO_REGISTRO int,
  68. EXTENDIDA varchar(40),
  69. NO_DPI bigint,
  70. primary key (ID_CEDULADPI)
  71. );
  72.  
  73. /*==============================================================*/
  74. /* Table: CLIENTE */
  75. /*==============================================================*/
  76. create table CLIENTE
  77. (
  78. ID_CLIENTE int unsigned not null auto_increment,
  79. NOMBRE_CLIENTE varchar(50),
  80. APELLIDO_CLIENTE varchar(50),
  81. FECHA_NACIMIENTO date,
  82. ESTADO_CIVIL tinyint,
  83. SABE_FIRMAR tinyint,
  84. primary key (ID_CLIENTE)
  85. );
  86.  
  87. /*==============================================================*/
  88. /* Table: DEPARTAMENTO */
  89. /*==============================================================*/
  90. create table DEPARTAMENTO
  91. (
  92. ID_DEPARTAMENTO int unsigned not null auto_increment,
  93. NOMBRE_DEPARTAMENTO varchar(60),
  94. primary key (ID_DEPARTAMENTO)
  95. );
  96.  
  97. /*==============================================================*/
  98. /* Table: DIRECCION */
  99. /*==============================================================*/
  100. create table DIRECCION
  101. (
  102. ID_DIRECCION int unsigned not null auto_increment,
  103. ID_MUNICIPIO tinyint,
  104. ID_CLIENTE int,
  105. NO_CARNE int,
  106. DIRECCION varchar(80),
  107. ZONA tinyint,
  108. TIPO tinyint,
  109. primary key (ID_DIRECCION)
  110. );
  111.  
  112. /*==============================================================*/
  113. /* Table: ESTUDIANTE */
  114. /*==============================================================*/
  115. create table ESTUDIANTE
  116. (
  117. NO_CARNE int unsigned not null,
  118. ID_NACIONALIDAD tinyint,
  119. NO_BUFETE int,
  120. NOMBRE_ESTUDIANTE varchar(50),
  121. APELLIDOS_ESTUDIANTE varchar(50),
  122. FECHA_NACIMIENTO date,
  123. ESTADO_CIVIL tinyint,
  124. primary key (NO_CARNE)
  125. );
  126.  
  127. /*==============================================================*/
  128. /* Table: MUNICIPIO */
  129. /*==============================================================*/
  130. create table MUNICIPIO
  131. (
  132. ID_MUNICIPIO int unsigned not null auto_increment,
  133. ID_DEPARTAMENTO tinyint,
  134. NOMBRE_MUNICIPIO varchar(50),
  135. primary key (ID_MUNICIPIO)
  136. );
  137.  
  138. /*==============================================================*/
  139. /* Table: NACIONALIDAD */
  140. /*==============================================================*/
  141. create table NACIONALIDAD
  142. (
  143. ID_NACIONALIDAD int unsigned not null auto_increment,
  144. NACIONALIDAD varchar(50),
  145. primary key (ID_NACIONALIDAD)
  146. );
  147.  
  148. /*==============================================================*/
  149. /* Table: SEGUIMIENTOS */
  150. /*==============================================================*/
  151. create table SEGUIMIENTOS
  152. (
  153. ID_SEGUIMIENTO int unsigned not null auto_increment,
  154. ID_CASO int,
  155. FECHA date,
  156. COMENTARIO varchar(255),
  157. primary key (ID_SEGUIMIENTO)
  158. );
  159.  
  160. /*==============================================================*/
  161. /* Table: TELEFONO */
  162. /*==============================================================*/
  163. create table TELEFONO
  164. (
  165. ID_TEL int unsigned not null auto_increment,
  166. NO_CARNE int,
  167. ID_CLIENTE int,
  168. TELEFONO varchar(8),
  169. TIPO tinyint,
  170. primary key (ID_TEL)
  171. );
  172.  
  173. /*==============================================================*/
  174. /* Table: TIPO */
  175. /*==============================================================*/
  176. create table TIPO
  177. (
  178. ID_TIPO_CASO int unsigned not null auto_increment,
  179. TIPO varchar(50),
  180. primary key (ID_TIPO_CASO)
  181. );
  182.  
  183. alter table CASO add constraint FK_REFERENCE_21 foreign key (NO_CARNE)
  184. references ESTUDIANTE (NO_CARNE) on delete restrict on update restrict;
  185.  
  186. alter table CASO add constraint FK_REFERENCE_22 foreign key (ID_ASUNTO)
  187. references ASUNTO (ID_ASUNTO) on delete restrict on update restrict;
  188.  
  189. alter table CASO add constraint FK_REFERENCE_23 foreign key (ID_TIPO_CASO)
  190. references TIPO (ID_TIPO_CASO) on delete restrict on update restrict;
  191.  
  192. alter table CEDULA add constraint FK_REFERENCE_3 foreign key (NO_CARNE)
  193. references ESTUDIANTE (NO_CARNE) on delete restrict on update restrict;
  194.  
  195. alter table DIRECCION add constraint FK_REFERENCE_4 foreign key (ID_MUNICIPIO)
  196. references MUNICIPIO (ID_MUNICIPIO) on delete restrict on update restrict;
  197.  
  198. alter table DIRECCION add constraint FK_REFERENCE_6 foreign key (ID_CLIENTE)
  199. references CLIENTE (ID_CLIENTE) on delete restrict on update restrict;
  200.  
  201. alter table DIRECCION add constraint FK_REFERENCE_7 foreign key (NO_CARNE)
  202. references ESTUDIANTE (NO_CARNE) on delete restrict on update restrict;
  203.  
  204. alter table ESTUDIANTE add constraint FK_REFERENCE_1 foreign key (ID_NACIONALIDAD)
  205. references NACIONALIDAD (ID_NACIONALIDAD) on delete restrict on update restrict;
  206.  
  207. alter table MUNICIPIO add constraint FK_REFERENCE_5 foreign key (ID_DEPARTAMENTO)
  208. references DEPARTAMENTO (ID_DEPARTAMENTO) on delete restrict on update restrict;
  209.  
  210. alter table SEGUIMIENTOS add constraint FK_REFERENCE_24 foreign key (ID_CASO)
  211. references CASO (ID_CASO) on delete restrict on update restrict;
  212.  
  213. alter table TELEFONO add constraint FK_REFERENCE_10 foreign key (ID_CLIENTE)
  214. references CLIENTE (ID_CLIENTE) on delete restrict on update restrict;
  215.  
  216. alter table TELEFONO add constraint FK_REFERENCE_2 foreign key (NO_CARNE)
  217. references ESTUDIANTE (NO_CARNE) on delete restrict on update restrict;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement