Advertisement
Guest User

Untitled

a guest
Aug 15th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. use master
  2. go
  3. create database Taller_Mecanico
  4. go
  5. use Taller_Mecanico
  6. SET DATEFORMAT DMY
  7. go
  8.  
  9. create table Hojap(
  10. id_hoja varchar(4) primary key not null,
  11. concepto varchar(50) not null,
  12. cantidad varchar(50) not null,
  13. id_rep varchar(4) not null,
  14. id_mec varchar(4) not null)
  15. go
  16.  
  17. create table Repuesto(
  18. id_rep varchar(4) primary key not null,
  19. descripcion varchar(50) not null,
  20. costo_unit money not null,
  21. precio_unit money not null)
  22. go
  23.  
  24. create table Factura(
  25. n_fact varchar(4) primary key not null,
  26. fecha date not null,
  27. imp_pesos money not null,
  28. imp_dol money not null,
  29. Rfc varchar(10) not null,
  30. id_hoja varchar(4) not null)
  31. go
  32.  
  33. create table Mecanico(
  34. id_mec varchar(4) primary key not null,
  35. nombre varchar(50) not null,
  36. direccion varchar(50) not null,
  37. telef numeric(9) not null,
  38. costo_hora money not null)
  39. go
  40.  
  41. create table Cliente(
  42. Rfc varchar(10) primary key not null,
  43. nombre varchar(50) not null,
  44. direccion varchar(50) not null,
  45. telef numeric(9) not null)
  46. go
  47.  
  48. create table Vehiculo(
  49. matricula varchar(6) primary key not null,
  50. modelo varchar(50) not null,
  51. color varchar(50) not null,
  52. fecha_ent date not null,
  53. hora_ent time not null,
  54. Rfc varchar(10) not null,
  55. id_mec varchar(4) not null)
  56. go
  57.  
  58.  
  59. alter table Factura
  60. add constraint FK_Hojap_Factura
  61. foreign key (id_hoja)
  62. references Hojap(id_hoja)
  63. go
  64.  
  65.  
  66. alter table Hojap
  67. add constraint FK_Repuesto_Hojap
  68. foreign key (id_rep)
  69. references Repuesto(id_rep)
  70. go
  71.  
  72.  
  73. alter table Hojap
  74. add constraint FK_Mecanico_Hojap
  75. foreign key (id_mec)
  76. references Mecanico(id_mec)
  77. go
  78.  
  79.  
  80. alter table Factura
  81. add constraint FK_Cliente_Factura
  82. foreign key (Rfc)
  83. references Cliente(Rfc)
  84. go
  85.  
  86.  
  87. alter table Vehiculo
  88. add constraint FK_Cliente_Vehiculo
  89. foreign key (Rfc)
  90. references Cliente(Rfc)
  91. go
  92.  
  93.  
  94. alter table Vehiculo
  95. add constraint FK_Mecanico_Vehiculo
  96. foreign key (id_mec)
  97. references Mecanico(id_mec)
  98. go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement