text: -- phpMyAdmin SQL Dump
  -- version 4.8.3
  -- https://www.phpmyadmin.net/
  --
  -- Servidor: 127.0.0.1
  -- Tiempo de generación: 22-10-2018 a las 19:32:55
  -- Versión del servidor: 10.1.36-MariaDB
  -- Versión de PHP: 7.2.10
  
  SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  SET AUTOCOMMIT = 0;
  START TRANSACTION;
  SET time_zone = "+00:00";
  
  
  /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
  /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
  /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
  /*!40101 SET NAMES utf8mb4 */;
  
  --
  -- Base de datos: `dbproyectolaravel`
  --
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `articulo`
  --
  
  CREATE TABLE `articulo` (
    `idarticulo` int(11) NOT NULL,
    `idcategoria` int(11) NOT NULL,
    `codigo` varchar(50) COLLATE utf8_spanish2_ci DEFAULT NULL,
    `nombre` varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
    `stock` int(11) NOT NULL,
    `descripcion` varchar(512) COLLATE utf8_spanish2_ci DEFAULT NULL,
    `imagen` varchar(50) COLLATE utf8_spanish2_ci DEFAULT NULL,
    `estado` varchar(20) COLLATE utf8_spanish2_ci NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `categoria`
  --
  
  CREATE TABLE `categoria` (
    `idcategoria` int(11) NOT NULL,
    `nombre` varchar(50) COLLATE utf8_spanish2_ci NOT NULL,
    `descripcion` varchar(256) COLLATE utf8_spanish2_ci DEFAULT NULL,
    `condicion` tinyint(1) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci;
  
  --
  -- Volcado de datos para la tabla `categoria`
  --
  
  INSERT INTO `categoria` (`idcategoria`, `nombre`, `descripcion`, `condicion`) VALUES
  (14, 'Cuadernos', 'Grandes', 1);
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `detalle_ingreso`
  --
  
  CREATE TABLE `detalle_ingreso` (
    `iddetalle_ingreso` int(11) NOT NULL,
    `idingreso` int(11) NOT NULL,
    `idarticulo` int(11) NOT NULL,
    `cantidad` int(11) NOT NULL,
    `precio_compra` decimal(11,2) NOT NULL,
    `precio_venta` decimal(11,2) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci;
  
  --
  -- Disparadores `detalle_ingreso`
  --
  DELIMITER $$
  CREATE TRIGGER `tr_updStockIngreso` AFTER INSERT ON `detalle_ingreso` FOR EACH ROW BEGIN
  	UPDATE articulo SET stock = stock + NEW.cantidad 
  	WHERE articulo.idarticulo = NEW.idarticulo;
  END
  $$
  DELIMITER ;
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `detalle_venta`
  --
  
  CREATE TABLE `detalle_venta` (
    `iddetalle_venta` int(11) NOT NULL,
    `idventa` int(11) NOT NULL,
    `idarticulo` int(11) NOT NULL,
    `cantidad` int(11) NOT NULL,
    `precio_venta` decimal(11,2) NOT NULL,
    `descuento` decimal(11,2) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci;
  
  --
  -- Disparadores `detalle_venta`
  --
  DELIMITER $$
  CREATE TRIGGER `tr_updStockVenta` AFTER INSERT ON `detalle_venta` FOR EACH ROW BEGIN
  	UPDATE articulo SET stock = stock - NEW.cantidad 
  	WHERE articulo.idarticulo = NEW.idarticulo;
  END
  $$
  DELIMITER ;
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `ingreso`
  --
  
  CREATE TABLE `ingreso` (
    `idingreso` int(11) NOT NULL,
    `idproveedor` int(11) NOT NULL,
    `tipo_comprobante` varchar(20) COLLATE utf8_spanish2_ci NOT NULL,
    `serie_comprobante` varchar(7) COLLATE utf8_spanish2_ci DEFAULT NULL,
    `num_comprobante` varchar(10) COLLATE utf8_spanish2_ci NOT NULL,
    `fecha_hora` datetime NOT NULL,
    `impuesto` decimal(4,2) NOT NULL,
    `estado` varchar(20) COLLATE utf8_spanish2_ci NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `migrations`
  --
  
  CREATE TABLE `migrations` (
    `migration` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `batch` int(11) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  --
  -- Volcado de datos para la tabla `migrations`
  --
  
  INSERT INTO `migrations` (`migration`, `batch`) VALUES
  ('2014_10_12_000000_create_users_table', 1),
  ('2014_10_12_100000_create_password_resets_table', 1);
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `password_resets`
  --
  
  CREATE TABLE `password_resets` (
    `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `token` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `persona`
  --
  
  CREATE TABLE `persona` (
    `idpersona` int(11) NOT NULL,
    `tipo_persona` varchar(20) COLLATE utf8_spanish2_ci NOT NULL,
    `nombre` varchar(100) COLLATE utf8_spanish2_ci NOT NULL,
    `tipo_documento` varchar(20) COLLATE utf8_spanish2_ci DEFAULT NULL,
    `num_documento` varchar(15) COLLATE utf8_spanish2_ci DEFAULT NULL,
    `direccion` varchar(70) COLLATE utf8_spanish2_ci DEFAULT NULL,
    `telefono` varchar(15) COLLATE utf8_spanish2_ci DEFAULT NULL,
    `email` varchar(50) COLLATE utf8_spanish2_ci DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci;
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `users`
  --
  
  CREATE TABLE `users` (
    `id` int(10) UNSIGNED NOT NULL,
    `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `password` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
    `remember_token` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
  
  --
  -- Volcado de datos para la tabla `users`
  --
  
  INSERT INTO `users` (`id`, `name`, `email`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
  (6, 'Diego', 'diego@gmail.com', '$2y$10$6LUuZLLmF6rq785GuWxXAOPGMujcOxalNVpQZOWaaobsOnHo3Pi6y', NULL, '2018-10-04 18:28:43', '2018-10-04 18:28:43'),
  (7, 'Mario', 'mario@gmail.com', '$2y$10$gOqOA1BfmSn8tewL4M7k0.iutwoPpiifBa5XZPrUS2bErgLjiNRM2', NULL, '2018-10-22 18:27:21', '2018-10-22 18:27:21'),
  (8, 'Angel', 'angel@gmail.com', '$2y$10$VxsQB7MzWv0i7zjwoKChIesqaPG//8TFSeKGvglhNVSSuBRfKSKqm', NULL, '2018-10-22 18:27:49', '2018-10-22 18:27:49'),
  (9, 'Cruz', 'cruz@gmail.com', '$2y$10$MOjC1tG1L1DUNvrNDH/UD.8SFj8unLRPmhtKbbJFUpnMnGwRlTrnG', NULL, '2018-10-22 18:28:11', '2018-10-22 18:28:11');
  
  -- --------------------------------------------------------
  
  --
  -- Estructura de tabla para la tabla `venta`
  --
  
  CREATE TABLE `venta` (
    `idventa` int(11) NOT NULL,
    `idcliente` int(11) NOT NULL,
    `tipo_comprobante` varchar(20) COLLATE utf8_spanish2_ci NOT NULL,
    `serie_comprobante` varchar(7) COLLATE utf8_spanish2_ci NOT NULL,
    `num_comprobante` varchar(10) COLLATE utf8_spanish2_ci NOT NULL,
    `fecha_hora` datetime NOT NULL,
    `impuesto` decimal(4,2) NOT NULL,
    `total_venta` decimal(11,2) NOT NULL,
    `estado` varchar(20) COLLATE utf8_spanish2_ci NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish2_ci;
  
  --
  -- Índices para tablas volcadas
  --
  
  --
  -- Indices de la tabla `articulo`
  --
  ALTER TABLE `articulo`
    ADD PRIMARY KEY (`idarticulo`),
    ADD KEY `fk_articulo_categoria_idx` (`idcategoria`);
  
  --
  -- Indices de la tabla `categoria`
  --
  ALTER TABLE `categoria`
    ADD PRIMARY KEY (`idcategoria`);
  
  --
  -- Indices de la tabla `detalle_ingreso`
  --
  ALTER TABLE `detalle_ingreso`
    ADD PRIMARY KEY (`iddetalle_ingreso`),
    ADD KEY `fk_detalle_ingreso_idx` (`idingreso`),
    ADD KEY `fk_detalle_ingreso_articulo_idx` (`idarticulo`);
  
  --
  -- Indices de la tabla `detalle_venta`
  --
  ALTER TABLE `detalle_venta`
    ADD PRIMARY KEY (`iddetalle_venta`),
    ADD KEY `fk_detalle_venta_articulo_idx` (`idarticulo`),
    ADD KEY `fk_detalle_venta_idx` (`idventa`);
  
  --
  -- Indices de la tabla `ingreso`
  --
  ALTER TABLE `ingreso`
    ADD PRIMARY KEY (`idingreso`),
    ADD KEY `fk_ingreso_persona_idx` (`idproveedor`);
  
  --
  -- Indices de la tabla `password_resets`
  --
  ALTER TABLE `password_resets`
    ADD KEY `password_resets_email_index` (`email`),
    ADD KEY `password_resets_token_index` (`token`);
  
  --
  -- Indices de la tabla `persona`
  --
  ALTER TABLE `persona`
    ADD PRIMARY KEY (`idpersona`);
  
  --
  -- Indices de la tabla `users`
  --
  ALTER TABLE `users`
    ADD PRIMARY KEY (`id`),
    ADD UNIQUE KEY `users_email_unique` (`email`);
  
  --
  -- Indices de la tabla `venta`
  --
  ALTER TABLE `venta`
    ADD PRIMARY KEY (`idventa`),
    ADD KEY `fk_venta_cliente_idx` (`idcliente`);
  
  --
  -- AUTO_INCREMENT de las tablas volcadas
  --
  
  --
  -- AUTO_INCREMENT de la tabla `articulo`
  --
  ALTER TABLE `articulo`
    MODIFY `idarticulo` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT de la tabla `categoria`
  --
  ALTER TABLE `categoria`
    MODIFY `idcategoria` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
  
  --
  -- AUTO_INCREMENT de la tabla `detalle_ingreso`
  --
  ALTER TABLE `detalle_ingreso`
    MODIFY `iddetalle_ingreso` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT de la tabla `detalle_venta`
  --
  ALTER TABLE `detalle_venta`
    MODIFY `iddetalle_venta` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT de la tabla `ingreso`
  --
  ALTER TABLE `ingreso`
    MODIFY `idingreso` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT de la tabla `persona`
  --
  ALTER TABLE `persona`
    MODIFY `idpersona` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- AUTO_INCREMENT de la tabla `users`
  --
  ALTER TABLE `users`
    MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
  
  --
  -- AUTO_INCREMENT de la tabla `venta`
  --
  ALTER TABLE `venta`
    MODIFY `idventa` int(11) NOT NULL AUTO_INCREMENT;
  
  --
  -- Restricciones para tablas volcadas
  --
  
  --
  -- Filtros para la tabla `articulo`
  --
  ALTER TABLE `articulo`
    ADD CONSTRAINT `fk_articulo_categoria` FOREIGN KEY (`idcategoria`) REFERENCES `categoria` (`idcategoria`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Filtros para la tabla `detalle_ingreso`
  --
  ALTER TABLE `detalle_ingreso`
    ADD CONSTRAINT `fk_detalle_ingreso` FOREIGN KEY (`idingreso`) REFERENCES `ingreso` (`idingreso`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_detalle_ingreso_articulo` FOREIGN KEY (`idarticulo`) REFERENCES `articulo` (`idarticulo`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Filtros para la tabla `detalle_venta`
  --
  ALTER TABLE `detalle_venta`
    ADD CONSTRAINT `fk_detalle_venta` FOREIGN KEY (`idventa`) REFERENCES `venta` (`idventa`) ON DELETE NO ACTION ON UPDATE NO ACTION,
    ADD CONSTRAINT `fk_detalle_venta_articulo` FOREIGN KEY (`idarticulo`) REFERENCES `articulo` (`idarticulo`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Filtros para la tabla `ingreso`
  --
  ALTER TABLE `ingreso`
    ADD CONSTRAINT `fk_ingreso_persona` FOREIGN KEY (`idproveedor`) REFERENCES `persona` (`idpersona`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  
  --
  -- Filtros para la tabla `venta`
  --
  ALTER TABLE `venta`
    ADD CONSTRAINT `fk_venta_cliente` FOREIGN KEY (`idcliente`) REFERENCES `persona` (`idpersona`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  COMMIT;
  
  /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  