Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SET FOREIGN_KEY_CHECKS=0;
- -- ----------------------------
- -- Table structure for documentos
- -- ----------------------------
- DROP TABLE IF EXISTS `documentos`;
- CREATE TABLE `documentos` (
- `idDocumento` int(11) NOT NULL AUTO_INCREMENT,
- `nombreDocumento` varchar(50) NOT NULL,
- PRIMARY KEY (`idDocumento`)
- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
- -- ----------------------------
- -- Table structure for entidades
- -- ----------------------------
- DROP TABLE IF EXISTS `entidades`;
- CREATE TABLE `entidades` (
- `idEntidad` int(11) NOT NULL AUTO_INCREMENT,
- `tipoEntidad` enum('USUARIO','EMPRESA') NOT NULL,
- `tipoDocumento` enum('DNI','RUC') NOT NULL,
- `numeroDocumento` varchar(11) NOT NULL,
- `nomEntidad` varchar(50) DEFAULT NULL,
- `fechaRegistro` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`idEntidad`),
- UNIQUE KEY `numeroDocumento` (`numeroDocumento`)
- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
- -- ----------------------------
- -- Table structure for equivalencias
- -- ----------------------------
- DROP TABLE IF EXISTS `equivalencias`;
- CREATE TABLE `equivalencias` (
- `idEquivalencia` int(11) NOT NULL AUTO_INCREMENT,
- `idProducto` int(11) NOT NULL,
- `idUnidadSuperior` int(11) NOT NULL,
- `idUnidadInferior` int(11) NOT NULL,
- `cantidadEquivalente` int(11) NOT NULL,
- PRIMARY KEY (`idEquivalencia`),
- KEY `idProducto` (`idProducto`),
- KEY `idUnidadSuperior` (`idUnidadSuperior`),
- KEY `idUnidadInferior` (`idUnidadInferior`),
- CONSTRAINT `equivalencias_ibfk_1` FOREIGN KEY (`idProducto`) REFERENCES `productos` (`idProducto`),
- CONSTRAINT `equivalencias_ibfk_2` FOREIGN KEY (`idUnidadSuperior`) REFERENCES `unidadesproducto` (`idUnidad`),
- CONSTRAINT `equivalencias_ibfk_3` FOREIGN KEY (`idUnidadInferior`) REFERENCES `unidadesproducto` (`idUnidad`)
- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
- -- ----------------------------
- -- Table structure for movimientos
- -- ----------------------------
- DROP TABLE IF EXISTS `movimientos`;
- CREATE TABLE `movimientos` (
- `idMovimiento` int(11) NOT NULL AUTO_INCREMENT,
- `tipoMovimiento` enum('ENTRADA','SALIDA') NOT NULL,
- `idProducto` int(11) NOT NULL,
- `cantidad` int(11) NOT NULL,
- `idDocumento` int(11) DEFAULT NULL,
- `numeroDocumento` varchar(50) DEFAULT NULL,
- `proveedor` varchar(20) DEFAULT NULL,
- `fechaMovimiento` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`idMovimiento`),
- KEY `idProducto` (`idProducto`),
- KEY `idDocumento` (`idDocumento`),
- CONSTRAINT `movimientos_ibfk_1` FOREIGN KEY (`idProducto`) REFERENCES `productos` (`idProducto`),
- CONSTRAINT `movimientos_ibfk_2` FOREIGN KEY (`idDocumento`) REFERENCES `documentos` (`idDocumento`)
- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
- -- ----------------------------
- -- Table structure for productos
- -- ----------------------------
- DROP TABLE IF EXISTS `productos`;
- CREATE TABLE `productos` (
- `idProducto` int(11) NOT NULL AUTO_INCREMENT,
- `codigoProducto` varchar(10) NOT NULL,
- `nombreProducto` varchar(100) NOT NULL,
- `idUnidadBase` int(11) NOT NULL,
- `stockInicial` int(11) NOT NULL,
- `fechaRegistro` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- PRIMARY KEY (`idProducto`),
- UNIQUE KEY `codigoProducto` (`codigoProducto`),
- KEY `idUnidadBase` (`idUnidadBase`),
- CONSTRAINT `productos_ibfk_1` FOREIGN KEY (`idUnidadBase`) REFERENCES `unidadesproducto` (`idUnidad`)
- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
- -- ----------------------------
- -- Table structure for unidadesproducto
- -- ----------------------------
- DROP TABLE IF EXISTS `unidadesproducto`;
- CREATE TABLE `unidadesproducto` (
- `idUnidad` int(11) NOT NULL AUTO_INCREMENT,
- `nombreUnidad` varchar(50) NOT NULL,
- PRIMARY KEY (`idUnidad`)
- ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement