--
-- Host: localhost    Database: nomina_db
-- ------------------------------------------------------


--
-- Table structure for table `empleados`
--

CREATE TABLE `empleados` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nombre` varchar(120) NOT NULL,
  `cedula` varchar(60) DEFAULT NULL,
  `salario` decimal(12,2) NOT NULL DEFAULT '0.00',
  `moneda` varchar(6) NOT NULL DEFAULT 'USD',
  `creado_en` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `empleados`
--


--
-- Table structure for table `nomina_detalle`
--

CREATE TABLE `nomina_detalle` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nomina_id` int(11) NOT NULL,
  `empleado_id` int(11) NOT NULL,
  `dias_trabajados` decimal(6,2) NOT NULL DEFAULT '0.00',
  `horas_extras` decimal(6,2) NOT NULL DEFAULT '0.00',
  `descuento` decimal(12,2) NOT NULL DEFAULT '0.00',
  `total` decimal(12,2) NOT NULL DEFAULT '0.00',
  PRIMARY KEY (`id`),
  KEY `nomina_id` (`nomina_id`),
  KEY `empleado_id` (`empleado_id`),
  CONSTRAINT `nomina_detalle_ibfk_1` FOREIGN KEY (`nomina_id`) REFERENCES `nominas` (`id`) ON DELETE CASCADE,
  CONSTRAINT `nomina_detalle_ibfk_2` FOREIGN KEY (`empleado_id`) REFERENCES `empleados` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `nomina_detalle`
--


--
-- Table structure for table `nominas`
--

CREATE TABLE `nominas` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `periodo` varchar(7) NOT NULL,
  `fecha` date NOT NULL,
  `vacaciones_global` decimal(12,2) NOT NULL DEFAULT '0.00',
  `bono_desc_global` decimal(12,2) NOT NULL DEFAULT '0.00',
  `metodo_pago` enum('C','E','T') NOT NULL DEFAULT 'E',
  `creado_en` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `nominas`
--


--
-- Table structure for table `pagos`
--

CREATE TABLE `pagos` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `monto` decimal(12,2) NOT NULL,
  `detalle` varchar(255) DEFAULT NULL,
  `metodo` enum('C','E','T') NOT NULL DEFAULT 'E',
  `creado_en` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `pagos`
--


--
-- Dumping events for database 'nomina_db'
--

--
-- Dumping routines for database 'nomina_db'
--


