--
-- Host: localhost    Database: db_restaurante
-- ------------------------------------------------------


--
-- Table structure for table `categorias`
--

CREATE TABLE `categorias` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_negocio` int DEFAULT NULL,
  `nombre` varchar(50) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id_negocio` (`id_negocio`),
  CONSTRAINT `categorias_ibfk_1` FOREIGN KEY (`id_negocio`) REFERENCES `negocios` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `categorias`
--


--
-- Table structure for table `configuracion`
--

CREATE TABLE `configuracion` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_negocio` int DEFAULT NULL,
  `url_cloudflare` varchar(255) DEFAULT NULL,
  `logo_negocio` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `id_negocio` (`id_negocio`),
  CONSTRAINT `configuracion_ibfk_1` FOREIGN KEY (`id_negocio`) REFERENCES `negocios` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `configuracion`
--


--
-- Table structure for table `detalle_pedidos`
--

CREATE TABLE `detalle_pedidos` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_pedido` int DEFAULT NULL,
  `id_producto` int DEFAULT NULL,
  `cantidad` int DEFAULT NULL,
  `precio_unitario` decimal(10,2) DEFAULT NULL,
  `subtotal` decimal(10,2) NOT NULL,
  `notas` text,
  PRIMARY KEY (`id`),
  KEY `id_pedido` (`id_pedido`),
  KEY `id_producto` (`id_producto`),
  CONSTRAINT `detalle_pedidos_ibfk_1` FOREIGN KEY (`id_pedido`) REFERENCES `pedidos` (`id`) ON DELETE CASCADE,
  CONSTRAINT `detalle_pedidos_ibfk_2` FOREIGN KEY (`id_producto`) REFERENCES `productos` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `detalle_pedidos`
--

INSERT INTO `detalle_pedidos` VALUES (23,16,7,5,5.00,25.00,'Sin cebolla '),(24,17,7,6,5.00,30.00,'Extra queso'),(25,18,7,2,5.00,10.00,'Extra queso'),(26,19,7,5,5.00,25.00,'Sin queso'),(27,20,8,2,5.00,10.00,'Sin papas'),(28,21,8,2,5.00,10.00,'Sin cebolla '),(29,22,8,2,5.00,10.00,'Sin queso '),(30,23,8,2,5.00,10.00,'Sin queso '),(31,24,8,1,5.00,5.00,'Sin queso '),(32,25,8,1,5.00,5.00,'sin papas'),(33,26,8,1,5.00,5.00,'con extra queso'),(34,27,7,4,5.00,20.00,'sin atun'),(35,28,8,2,5.00,10.00,NULL),(36,29,7,2,5.00,10.00,NULL),(37,30,8,1,5.00,5.00,NULL),(38,31,8,1,5.00,5.00,NULL),(39,32,8,1,5.00,5.00,NULL),(40,33,8,1,5.00,5.00,NULL),(41,34,7,1,5.00,5.00,NULL),(42,34,8,1,5.00,5.00,NULL),(43,35,8,1,5.00,5.00,NULL),(44,36,8,1,5.00,5.00,NULL),(45,37,8,1,5.00,5.00,NULL),(46,38,7,1,5.00,5.00,NULL),(47,39,7,1,5.00,5.00,NULL),(48,40,7,1,5.00,5.00,NULL),(49,40,8,1,5.00,5.00,NULL),(50,41,7,1,5.00,5.00,NULL),(51,41,8,1,5.00,5.00,NULL),(52,42,8,1,5.00,5.00,NULL),(53,43,7,1,5.00,5.00,NULL),(54,43,8,1,5.00,5.00,NULL);

--
-- Table structure for table `gastos`
--

CREATE TABLE `gastos` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_negocio` int NOT NULL,
  `descripcion` varchar(255) NOT NULL,
  `monto` decimal(10,2) NOT NULL,
  `fecha` date NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `gastos`
--

INSERT INTO `gastos` VALUES (1,1,'Compramos gaseosas',5.80,'2026-01-13');

--
-- Table structure for table `inventario`
--

CREATE TABLE `inventario` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_negocio` int DEFAULT NULL,
  `ingrediente` varchar(100) DEFAULT NULL,
  `cantidad_actual` decimal(10,2) DEFAULT NULL,
  `unidad_medida` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `id_negocio` (`id_negocio`),
  CONSTRAINT `inventario_ibfk_1` FOREIGN KEY (`id_negocio`) REFERENCES `negocios` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `inventario`
--

INSERT INTO `inventario` VALUES (1,1,'Carne',5.00,'Kg'),(2,1,'carne',-2.00,'kg'),(3,1,'carne',1.00,'kg'),(4,1,'leche',2.00,'Lt');

--
-- Table structure for table `negocios`
--

CREATE TABLE `negocios` (
  `id` int NOT NULL AUTO_INCREMENT,
  `nombre_negocio` varchar(100) NOT NULL,
  `id_dueno_unico` varchar(50) DEFAULT NULL,
  `email_dueno` varchar(100) DEFAULT NULL,
  `url_slug` varchar(50) DEFAULT NULL,
  `fecha_registro` datetime DEFAULT CURRENT_TIMESTAMP,
  `fecha_vencimiento` date DEFAULT NULL,
  `estado` enum('activo','suspendido') DEFAULT 'activo',
  PRIMARY KEY (`id`),
  UNIQUE KEY `id_dueno_unico` (`id_dueno_unico`),
  UNIQUE KEY `url_slug` (`url_slug`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `negocios`
--

INSERT INTO `negocios` VALUES (0,'ADMINISTRACION CENTRAL',NULL,NULL,NULL,'2026-01-11 17:58:01',NULL,'activo'),(1,'Restaurante Ejemplo',NULL,NULL,NULL,'2026-01-11 17:58:01',NULL,'activo');

--
-- Table structure for table `notificaciones`
--

CREATE TABLE `notificaciones` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_negocio` int NOT NULL,
  `mesa` int NOT NULL,
  `mensaje` text NOT NULL,
  `fecha` datetime DEFAULT CURRENT_TIMESTAMP,
  `leido` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `notificaciones`
--

INSERT INTO `notificaciones` VALUES (1,1,1,'La Mesa 1 solicita la cuenta.','2026-01-13 12:56:56',1),(2,1,1,'La Mesa 1 solicita la cuenta.','2026-01-13 13:40:28',1);

--
-- Table structure for table `pedidos`
--

CREATE TABLE `pedidos` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_negocio` int DEFAULT NULL,
  `id_usuario` int DEFAULT NULL,
  `id_mesa` int NOT NULL,
  `estado` varchar(50) DEFAULT 'recibido',
  `total` decimal(10,2) DEFAULT '0.00',
  `fecha_hora` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `id_negocio` (`id_negocio`),
  CONSTRAINT `pedidos_ibfk_1` FOREIGN KEY (`id_negocio`) REFERENCES `negocios` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=44 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `pedidos`
--

INSERT INTO `pedidos` VALUES (16,1,1,2,'finalizado',25.00,'2026-01-12 22:12:36'),(17,1,1,22,'finalizado',30.00,'2026-01-13 01:31:35'),(18,1,1,2,'finalizado',10.00,'2026-01-13 02:14:13'),(19,1,1,1,'finalizado',25.00,'2026-01-13 02:33:54'),(20,1,1,2,'finalizado',10.00,'2026-01-13 02:37:46'),(21,1,0,1,'finalizado',10.00,'2026-01-13 02:49:40'),(22,1,0,2,'finalizado',10.00,'2026-01-13 02:55:21'),(23,1,0,2,'finalizado',10.00,'2026-01-13 03:13:04'),(24,1,11,1,'finalizado',5.00,'2026-01-13 13:58:43'),(25,1,12,1,'finalizado',5.00,'2026-01-13 14:04:58'),(26,1,12,5,'finalizado',5.00,'2026-01-13 14:07:35'),(27,1,12,3,'finalizado',20.00,'2026-01-13 14:08:48'),(28,1,NULL,1,'finalizado',10.00,'2026-01-13 17:29:59'),(29,1,NULL,1,'finalizado',10.00,'2026-01-13 17:33:03'),(30,1,NULL,1,'finalizado',5.00,'2026-01-13 17:40:31'),(31,1,NULL,1,'finalizado',5.00,'2026-01-13 17:43:38'),(32,1,NULL,1,'finalizado',5.00,'2026-01-13 17:48:11'),(33,1,NULL,1,'finalizado',5.00,'2026-01-13 17:56:48'),(34,1,NULL,1,'finalizado',10.00,'2026-01-13 17:58:19'),(35,1,NULL,1,'finalizado',5.00,'2026-01-13 18:23:50'),(36,1,11,1,'finalizado',5.00,'2026-01-13 18:36:45'),(37,1,11,1,'finalizado',5.00,'2026-01-13 18:39:10'),(38,1,11,1,'finalizado',5.00,'2026-01-13 18:40:00'),(39,1,11,1,'finalizado',5.00,'2026-01-13 18:41:30'),(40,1,12,1,'finalizado',10.00,'2026-01-30 02:23:54'),(41,1,12,1,'finalizado',10.00,'2026-01-30 16:45:32'),(42,1,12,1,'finalizado',5.00,'2026-01-30 16:45:49'),(43,1,12,1,'finalizado',10.00,'2026-02-04 19:34:35');

--
-- Table structure for table `productos`
--

CREATE TABLE `productos` (
  `id` int NOT NULL AUTO_INCREMENT,
  `id_negocio` int DEFAULT NULL,
  `id_categoria` int DEFAULT NULL,
  `nombre` varchar(100) NOT NULL,
  `descripcion` text,
  `precio` decimal(10,2) NOT NULL,
  `tiempo_coccion` int DEFAULT NULL,
  `imagen` varchar(255) DEFAULT NULL,
  `disponible` tinyint(1) DEFAULT '1',
  PRIMARY KEY (`id`),
  KEY `id_negocio` (`id_negocio`),
  KEY `id_categoria` (`id_categoria`),
  CONSTRAINT `productos_ibfk_1` FOREIGN KEY (`id_negocio`) REFERENCES `negocios` (`id`) ON DELETE CASCADE,
  CONSTRAINT `productos_ibfk_2` FOREIGN KEY (`id_categoria`) REFERENCES `categorias` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `productos`
--

INSERT INTO `productos` VALUES (7,1,NULL,'Platillo de pasta','Pasta y queso ',5.00,NULL,'prod_1768315198_1.jpg',1),(8,1,NULL,'Hamburguesa especial','Hamburguesa del mes',5.00,NULL,'1768257965_1.jpg',1);


