Advertisement
kuroshan1104

KARDEX_DB

Feb 4th, 2025
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 3.82 KB | Source Code | 0 0
  1. SET FOREIGN_KEY_CHECKS=0;
  2.  
  3. -- ----------------------------
  4. -- Table structure for documentos
  5. -- ----------------------------
  6. DROP TABLE IF EXISTS `documentos`;
  7. CREATE TABLE `documentos` (
  8.   `idDocumento` int(11) NOT NULL AUTO_INCREMENT,
  9.   `nombreDocumento` varchar(50) NOT NULL,
  10.   PRIMARY KEY (`idDocumento`)
  11. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  12.  
  13. -- ----------------------------
  14. -- Table structure for entidades
  15. -- ----------------------------
  16. DROP TABLE IF EXISTS `entidades`;
  17. CREATE TABLE `entidades` (
  18.   `idEntidad` int(11) NOT NULL AUTO_INCREMENT,
  19.   `tipoEntidad` enum('USUARIO','EMPRESA') NOT NULL,
  20.   `tipoDocumento` enum('DNI','RUC') NOT NULL,
  21.   `numeroDocumento` varchar(11) NOT NULL,
  22.   `nomEntidad` varchar(50) DEFAULT NULL,
  23.   `fechaRegistro` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  24.   PRIMARY KEY (`idEntidad`),
  25.   UNIQUE KEY `numeroDocumento` (`numeroDocumento`)
  26. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  27.  
  28. -- ----------------------------
  29. -- Table structure for equivalencias
  30. -- ----------------------------
  31. DROP TABLE IF EXISTS `equivalencias`;
  32. CREATE TABLE `equivalencias` (
  33.   `idEquivalencia` int(11) NOT NULL AUTO_INCREMENT,
  34.   `idProducto` int(11) NOT NULL,
  35.   `idUnidadSuperior` int(11) NOT NULL,
  36.   `idUnidadInferior` int(11) NOT NULL,
  37.   `cantidadEquivalente` int(11) NOT NULL,
  38.   PRIMARY KEY (`idEquivalencia`),
  39.   KEY `idProducto` (`idProducto`),
  40.   KEY `idUnidadSuperior` (`idUnidadSuperior`),
  41.   KEY `idUnidadInferior` (`idUnidadInferior`),
  42.   CONSTRAINT `equivalencias_ibfk_1` FOREIGN KEY (`idProducto`) REFERENCES `productos` (`idProducto`),
  43.   CONSTRAINT `equivalencias_ibfk_2` FOREIGN KEY (`idUnidadSuperior`) REFERENCES `unidadesproducto` (`idUnidad`),
  44.   CONSTRAINT `equivalencias_ibfk_3` FOREIGN KEY (`idUnidadInferior`) REFERENCES `unidadesproducto` (`idUnidad`)
  45. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  46.  
  47. -- ----------------------------
  48. -- Table structure for movimientos
  49. -- ----------------------------
  50. DROP TABLE IF EXISTS `movimientos`;
  51. CREATE TABLE `movimientos` (
  52.   `idMovimiento` int(11) NOT NULL AUTO_INCREMENT,
  53.   `tipoMovimiento` enum('ENTRADA','SALIDA') NOT NULL,
  54.   `idProducto` int(11) NOT NULL,
  55.   `cantidad` int(11) NOT NULL,
  56.   `idDocumento` int(11) DEFAULT NULL,
  57.   `numeroDocumento` varchar(50) DEFAULT NULL,
  58.   `proveedor` varchar(20) DEFAULT NULL,
  59.   `fechaMovimiento` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  60.   PRIMARY KEY (`idMovimiento`),
  61.   KEY `idProducto` (`idProducto`),
  62.   KEY `idDocumento` (`idDocumento`),
  63.   CONSTRAINT `movimientos_ibfk_1` FOREIGN KEY (`idProducto`) REFERENCES `productos` (`idProducto`),
  64.   CONSTRAINT `movimientos_ibfk_2` FOREIGN KEY (`idDocumento`) REFERENCES `documentos` (`idDocumento`)
  65. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  66.  
  67. -- ----------------------------
  68. -- Table structure for productos
  69. -- ----------------------------
  70. DROP TABLE IF EXISTS `productos`;
  71. CREATE TABLE `productos` (
  72.   `idProducto` int(11) NOT NULL AUTO_INCREMENT,
  73.   `codigoProducto` varchar(10) NOT NULL,
  74.   `nombreProducto` varchar(100) NOT NULL,
  75.   `idUnidadBase` int(11) NOT NULL,
  76.   `stockInicial` int(11) NOT NULL,
  77.   `fechaRegistro` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  78.   PRIMARY KEY (`idProducto`),
  79.   UNIQUE KEY `codigoProducto` (`codigoProducto`),
  80.   KEY `idUnidadBase` (`idUnidadBase`),
  81.   CONSTRAINT `productos_ibfk_1` FOREIGN KEY (`idUnidadBase`) REFERENCES `unidadesproducto` (`idUnidad`)
  82. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  83.  
  84. -- ----------------------------
  85. -- Table structure for unidadesproducto
  86. -- ----------------------------
  87. DROP TABLE IF EXISTS `unidadesproducto`;
  88. CREATE TABLE `unidadesproducto` (
  89.   `idUnidad` int(11) NOT NULL AUTO_INCREMENT,
  90.   `nombreUnidad` varchar(50) NOT NULL,
  91.   PRIMARY KEY (`idUnidad`)
  92. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement