DROP DATABASE IF EXISTS roadfy_db;

CREATE DATABASE roadfy_db
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;

USE roadfy_db;

START TRANSACTION;


-- Base de datos: `roadfy_db`
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `items_inventario`
--

CREATE TABLE IF NOT EXISTS `items_inventario` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `negocio_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `llanta_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `cantidad` int NOT NULL DEFAULT '0',
  `precio` float NOT NULL COMMENT 'Precio en PEN (Soles)',
  `creado_en` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  `actualizado_en` datetime(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_negocio_llanta` (`negocio_id`,`llanta_id`),
  KEY `idx_negocio_id` (`negocio_id`),
  KEY `idx_llanta_id` (`llanta_id`),
  KEY `idx_negocio_llanta` (`negocio_id`,`llanta_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `items_inventario`
--

INSERT INTO `items_inventario` (`id`, `negocio_id`, `llanta_id`, `cantidad`, `precio`, `creado_en`, `actualizado_en`) VALUES
('inv-biz-1-tire-14', 'biz-1', 'tire-14', 25, 180, '2025-11-26 12:14:18.365549', '2025-11-26 12:14:18.365549'),
('inv-biz-1-tire-15', 'biz-1', 'tire-15', 30, 210, '2025-11-26 12:14:18.369405', '2025-11-26 12:14:18.369405'),
('inv-biz-1-tire-16', 'biz-1', 'tire-16', 15, 350, '2025-11-26 12:14:18.372963', '2025-11-26 12:14:18.372963'),
('inv-biz-1-tire-17', 'biz-1', 'tire-17', 20, 420, '2025-11-26 12:14:18.376475', '2025-11-26 12:14:18.376475'),
('inv-biz-1-tire-18', 'biz-1', 'tire-18', 18, 580, '2025-11-26 12:14:18.379823', '2025-11-26 12:14:18.379823'),
('inv-biz-1-tire-19', 'biz-1', 'tire-19', 10, 650, '2025-11-26 12:14:18.382456', '2025-11-26 12:14:18.382456'),
('inv-biz-2-tire-20', 'biz-2', 'tire-20', 15, 380, '2025-11-26 12:14:18.385614', '2025-11-26 12:14:18.385614'),
('inv-biz-2-tire-21', 'biz-2', 'tire-21', 20, 450, '2025-11-26 12:14:18.388054', '2025-11-26 12:14:18.388054'),
('inv-biz-2-tire-22', 'biz-2', 'tire-22', 12, 290, '2025-11-26 12:14:18.390960', '2025-11-26 12:14:18.390960'),
('inv-biz-2-tire-23', 'biz-2', 'tire-23', 12, 310, '2025-11-26 12:14:18.393754', '2025-11-26 12:14:18.393754'),
('inv-biz-2-tire-24', 'biz-2', 'tire-24', 8, 1200, '2025-11-26 12:14:18.396620', '2025-11-26 12:14:18.396620'),
('inv-biz-2-tire-25', 'biz-2', 'tire-25', 14, 550, '2025-11-26 12:14:18.399036', '2025-11-26 12:14:18.399036'),
('inv-biz-2-tire-5', 'biz-2', 'tire-5', 20, 320, '2025-11-26 13:48:43.509498', '2025-11-26 13:48:43.509498'),
('inv-biz-2-tire-7', 'biz-2', 'tire-7', 10, 720, '2025-11-26 13:48:43.522518', '2025-11-26 13:48:43.522518'),
('inv-biz-3-tire-10', 'biz-3', 'tire-10', 18, 480, '2025-11-26 13:48:43.488396', '2025-11-26 13:48:43.488396'),
('inv-biz-3-tire-26', 'biz-3', 'tire-26', 18, 320, '2025-11-26 12:14:18.401525', '2025-11-26 12:14:18.401525'),
('inv-biz-3-tire-27', 'biz-3', 'tire-27', 15, 410, '2025-11-26 12:14:18.404064', '2025-11-26 12:14:18.404064'),
('inv-biz-3-tire-28', 'biz-3', 'tire-28', 10, 750, '2025-11-26 12:14:18.407274', '2025-11-26 12:14:18.407274'),
('inv-biz-3-tire-29', 'biz-3', 'tire-29', 30, 190, '2025-11-26 12:14:18.410192', '2025-11-26 12:14:18.410192'),
('inv-biz-3-tire-30', 'biz-3', 'tire-30', 22, 250, '2025-11-26 12:14:18.412736', '2025-11-26 12:14:18.412736'),
('inv-biz-3-tire-31', 'biz-3', 'tire-31', 12, 620, '2025-11-26 12:14:18.415417', '2025-11-26 12:14:18.415417'),
('inv-biz-3-tire-8', 'biz-3', 'tire-8', 15, 520, '2025-11-26 13:48:43.528861', '2025-11-26 13:48:43.528861'),
('inv-biz-5-tire-1', 'biz-5', 'tire-1', 25, 350, '2025-11-26 12:14:18.428735', '2025-11-26 12:14:18.428735'),
('inv-biz-5-tire-11', 'biz-5', 'tire-11', 10, 620, '2025-11-26 12:14:18.433613', '2025-11-26 12:14:18.433613'),
('inv-biz-5-tire-12', 'biz-5', 'tire-12', 6, 890, '2025-11-26 13:48:43.495730', '2025-11-26 13:48:43.495730'),
('inv-biz-5-tire-13', 'biz-5', 'tire-13', 5, 940, '2025-11-26 12:14:18.420454', '2025-11-26 12:14:18.420454'),
('inv-biz-5-tire-2', 'biz-5', 'tire-2', 10, 490, '2025-11-26 12:14:18.418014', '2025-11-26 12:14:18.418014'),
('inv-biz-5-tire-21', 'biz-5', 'tire-21', 18, 440, '2025-11-26 12:14:18.426457', '2025-11-26 12:14:18.426457'),
('inv-biz-5-tire-22', 'biz-5', 'tire-22', 20, 285, '2025-11-26 12:14:18.435816', '2025-11-26 12:14:18.435816'),
('inv-biz-5-tire-26', 'biz-5', 'tire-26', 15, 315, '2025-11-26 12:14:18.431168', '2025-11-26 12:14:18.431168'),
('inv-biz-5-tire-3', 'biz-5', 'tire-3', 15, 570, '2025-11-26 12:14:18.423348', '2025-11-26 12:14:18.423348'),
('inv-biz-5-tire-4', 'biz-5', 'tire-4', 8, 850, '2025-11-26 13:48:43.503277', '2025-11-26 13:48:43.503277'),
('inv-biz-5-tire-6', 'biz-5', 'tire-6', 12, 680, '2025-11-26 13:48:43.515833', '2025-11-26 13:48:43.515833'),
('inv-biz-5-tire-9', 'biz-5', 'tire-9', 14, 460, '2025-11-26 12:14:18.437729', '2025-11-26 12:14:18.437729');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `llantas`
--

CREATE TABLE IF NOT EXISTS `llantas` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `marca_id` int DEFAULT NULL,
  `modelo_id` int DEFAULT NULL,
  `tipo_id` int DEFAULT NULL,
  `marca` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `modelo` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `ancho` int NOT NULL COMMENT 'Ancho en mm (ej: 205)',
  `relacion_aspecto` int NOT NULL COMMENT 'Relación de aspecto (ej: 55)',
  `diametro` int NOT NULL COMMENT 'Diámetro en pulgadas (ej: 16)',
  `tipo` enum('Pista / Carretera (H/T)','Uso Mixto (A/T)','Todo Terreno (M/T)','Deportiva (UHP)') COLLATE utf8mb4_unicode_ci NOT NULL,
  `url_imagen` text COLLATE utf8mb4_unicode_ci,
  `creado_en` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  `actualizado_en` datetime(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  KEY `idx_marca` (`marca`),
  KEY `idx_tipo` (`tipo`),
  KEY `idx_tamano` (`ancho`,`relacion_aspecto`,`diametro`),
  KEY `idx_marca_id` (`marca_id`),
  KEY `idx_modelo_id` (`modelo_id`),
  KEY `idx_tipo_id` (`tipo_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `llantas`
--

INSERT INTO `llantas` (`id`, `marca_id`, `modelo_id`, `tipo_id`, `marca`, `modelo`, `ancho`, `relacion_aspecto`, `diametro`, `tipo`, `url_imagen`, `creado_en`, `actualizado_en`) VALUES
('tire-1', 7, 9, 1, 'Goodyear', 'Eagle Sport', 205, 55, 16, 'Pista / Carretera (H/T)', 'https://i.imgur.com/N18vIYk.png', '2025-11-26 12:14:16.417121', '2025-11-26 13:37:04.974764'),
('tire-10', 6, 8, 2, 'Firestone', 'Destination A/T2', 245, 75, 16, 'Uso Mixto (A/T)', 'https://i.imgur.com/fiuWW4A.png', '2025-11-26 12:14:16.444073', '2025-11-26 13:37:04.974764'),
('tire-11', 5, 6, 2, 'Dunlop', 'Grandtrek AT20', 265, 60, 18, 'Uso Mixto (A/T)', 'https://i.imgur.com/pAEbiBh.png', '2025-11-26 12:14:16.446865', '2025-11-26 13:37:04.974764'),
('tire-12', 14, 28, 2, 'Pirelli', 'Scorpion All Terrain Plus', 275, 55, 20, 'Uso Mixto (A/T)', 'https://i.imgur.com/pAEbiBh.png', '2025-11-26 12:14:16.449528', '2025-11-26 13:37:04.974764'),
('tire-13', 13, 25, 4, 'Michelin', 'Pilot Sport 4S', 255, 35, 19, 'Deportiva (UHP)', 'https://i.imgur.com/ZOu9Slb.png', '2025-11-26 12:14:16.452629', '2025-11-26 13:37:04.974764'),
('tire-14', 8, 16, 1, 'Habilead', 'RS01 Taxi', 185, 70, 13, 'Pista / Carretera (H/T)', 'https://i.imgur.com/g8n23vY.png', '2025-11-26 12:14:16.455355', '2025-11-26 13:37:04.974764'),
('tire-15', 8, 17, 1, 'Habilead', 'H202', 195, 65, 15, 'Pista / Carretera (H/T)', 'https://i.imgur.com/g8n23vY.png', '2025-11-26 12:14:16.480893', '2025-11-26 13:37:04.974764'),
('tire-16', 10, 20, 4, 'Kapsen', 'Sport Max S2000', 215, 45, 17, 'Deportiva (UHP)', 'https://i.imgur.com/g8n23vY.png', '2025-11-26 12:14:16.490395', '2025-11-26 13:37:04.974764'),
('tire-17', 10, 21, 2, 'Kapsen', 'Practical Max RS21', 225, 65, 17, 'Uso Mixto (A/T)', 'https://i.imgur.com/g8n23vY.png', '2025-11-26 12:14:16.494008', '2025-11-26 13:37:04.974764'),
('tire-18', 8, 18, 2, 'Habilead', 'RS23 A/T', 265, 60, 18, 'Uso Mixto (A/T)', 'https://i.imgur.com/g8n23vY.png', '2025-11-26 12:14:16.496965', '2025-11-26 13:37:04.974764'),
('tire-19', 10, 22, 3, 'Kapsen', 'Practical Max RS25 M/T', 235, 85, 16, 'Todo Terreno (M/T)', 'https://i.imgur.com/g8n23vY.png', '2025-11-26 12:14:16.499612', '2025-11-26 13:37:04.974764'),
('tire-2', 13, 26, 2, 'Michelin', 'Defender LTX M/S', 215, 60, 17, 'Uso Mixto (A/T)', 'https://i.imgur.com/NfScKO2.png', '2025-11-26 12:14:16.420043', '2025-11-26 13:37:04.974764'),
('tire-20', 15, 30, 4, 'Triangle', 'TR968', 225, 45, 17, 'Deportiva (UHP)', 'https://i.imgur.com/g8n23vY.png', '2025-11-26 12:14:16.502325', '2025-11-26 13:37:04.974764'),
('tire-21', 2, 2, 1, 'Bridgestone', 'Dueler H/T 684 II', 195, 80, 15, 'Pista / Carretera (H/T)', 'https://i.imgur.com/oAPe43X.png', '2025-11-26 12:14:16.505218', '2025-11-26 13:37:04.974764'),
('tire-22', 5, 7, 4, 'Dunlop', 'Direzza DZ102', 195, 50, 15, 'Deportiva (UHP)', 'https://i.imgur.com/WbGziKF.png', '2025-11-26 12:14:16.508811', '2025-11-26 13:37:04.974764'),
('tire-23', 5, 7, 4, 'Dunlop', 'Direzza DZ102', 205, 55, 15, 'Deportiva (UHP)', 'https://i.imgur.com/WbGziKF.png', '2025-11-26 12:14:16.512141', '2025-11-26 14:05:42.000000'),
('tire-24', 4, 5, 3, 'Doupro', 'ST986 Traccion/Minera', 12, 0, 20, 'Todo Terreno (M/T)', 'https://i.imgur.com/g8n23vY.png', '2025-11-26 12:14:16.514931', '2025-11-26 13:37:04.974764'),
('tire-25', 13, 27, 2, 'Michelin', 'Latitude Cross', 235, 75, 15, 'Uso Mixto (A/T)', 'https://i.imgur.com/iU3m8v7.png', '2025-11-26 12:14:16.517681', '2025-11-26 13:37:04.974764'),
('tire-26', 7, 10, 4, 'Goodyear', 'Eagle Sport 2', 185, 60, 15, 'Deportiva (UHP)', 'https://i.imgur.com/N18vIYk.png', '2025-11-26 12:14:16.520994', '2025-11-26 13:37:04.974764'),
('tire-27', 7, 11, 1, 'Goodyear', 'Cargo Marathon 2', 195, 70, 15, 'Pista / Carretera (H/T)', 'https://i.imgur.com/N18vIYk.png', '2025-11-26 12:14:16.524843', '2025-11-26 13:37:04.974764'),
('tire-28', 7, 12, 4, 'Goodyear', 'Eagle F1 Asymmetric 6', 215, 45, 18, 'Deportiva (UHP)', 'https://i.imgur.com/ZOu9Slb.png', '2025-11-26 12:14:16.527533', '2025-11-26 13:37:04.974764'),
('tire-29', 7, 13, 1, 'Goodyear', 'G28', 155, 0, 12, 'Pista / Carretera (H/T)', 'https://i.imgur.com/N18vIYk.png', '2025-11-26 12:14:16.530056', '2025-11-26 13:37:04.974764'),
('tire-3', 2, 3, 1, 'Bridgestone', 'Alenza AS Ultra', 225, 50, 18, 'Pista / Carretera (H/T)', 'https://i.imgur.com/N18vIYk.png', '2025-11-26 12:14:16.422652', '2025-11-26 13:37:04.974764'),
('tire-30', 7, 14, 1, 'Goodyear', 'Assurance Maxlife', 165, 60, 14, 'Pista / Carretera (H/T)', 'https://i.imgur.com/N18vIYk.png', '2025-11-26 12:14:16.532066', '2025-11-26 13:37:04.974764'),
('tire-31', 1, 1, 2, 'Blackhawk', 'HA01 AT', 235, 65, 17, 'Uso Mixto (A/T)', 'https://i.imgur.com/pAEbiBh.png', '2025-11-26 12:14:16.533811', '2025-11-26 13:37:04.974764'),
('tire-4', 14, 29, 4, 'Pirelli', 'P Zero', 245, 40, 19, 'Deportiva (UHP)', 'https://i.imgur.com/ZOu9Slb.png', '2025-11-26 12:14:16.426544', '2025-11-26 13:37:04.974764'),
('tire-5', 7, 15, 1, 'Goodyear', 'Assurance WeatherReady', 195, 65, 15, 'Pista / Carretera (H/T)', 'https://i.imgur.com/N18vIYk.png', '2025-11-26 12:14:16.430026', '2025-11-26 13:37:04.974764'),
('tire-6', 9, 19, 4, 'Hankook', 'Ventus V12 evo2', 235, 45, 18, 'Deportiva (UHP)', 'https://i.imgur.com/ZOu9Slb.png', '2025-11-26 12:14:16.432977', '2025-11-26 13:37:04.974764'),
('tire-7', 12, 24, 3, 'Maxxis', 'Razr MT', 265, 70, 17, 'Todo Terreno (M/T)', 'https://images.unsplash.com/photo-1624413155375-399b8d03957b?q=80&w=400&h=400&fit=crop', '2025-11-26 12:14:16.435427', '2025-11-26 13:37:04.974764'),
('tire-8', 3, 4, 2, 'Continental', 'CrossContact LX25', 225, 65, 17, 'Uso Mixto (A/T)', 'https://i.imgur.com/pAEbiBh.png', '2025-11-26 12:14:16.437736', '2025-11-26 13:37:04.974764'),
('tire-9', 11, 23, 1, 'Kumho', 'Crugen HT51', 265, 65, 18, 'Pista / Carretera (H/T)', 'https://i.imgur.com/N18vIYk.png', '2025-11-26 12:14:16.440396', '2025-11-26 13:37:04.974764');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `marcas_llanta`
--

CREATE TABLE IF NOT EXISTS `marcas_llanta` (
  `id` int NOT NULL AUTO_INCREMENT,
  `nombre` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `pais_origen` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `creado_en` datetime DEFAULT (now()),
  PRIMARY KEY (`id`),
  UNIQUE KEY `ix_marcas_llanta_nombre` (`nombre`)
) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `marcas_llanta`
--

INSERT INTO `marcas_llanta` (`id`, `nombre`, `pais_origen`, `creado_en`) VALUES
(1, 'Blackhawk', NULL, '2025-11-26 13:36:46'),
(2, 'Bridgestone', NULL, '2025-11-26 13:36:46'),
(3, 'Continental', NULL, '2025-11-26 13:36:46'),
(4, 'Doupro', NULL, '2025-11-26 13:36:46'),
(5, 'Dunlop', NULL, '2025-11-26 13:36:46'),
(6, 'Firestone', NULL, '2025-11-26 13:36:46'),
(7, 'Goodyear', NULL, '2025-11-26 13:36:46'),
(8, 'Habilead', NULL, '2025-11-26 13:36:46'),
(9, 'Hankook', NULL, '2025-11-26 13:36:46'),
(10, 'Kapsen', NULL, '2025-11-26 13:36:46'),
(11, 'Kumho', NULL, '2025-11-26 13:36:46'),
(12, 'Maxxis', NULL, '2025-11-26 13:36:46'),
(13, 'Michelin', NULL, '2025-11-26 13:36:46'),
(14, 'Pirelli', NULL, '2025-11-26 13:36:46'),
(15, 'Triangle', NULL, '2025-11-26 13:36:46');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `modelos_llanta`
--

CREATE TABLE IF NOT EXISTS `modelos_llanta` (
  `id` int NOT NULL AUTO_INCREMENT,
  `marca_id` int NOT NULL,
  `nombre` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `descripcion` text COLLATE utf8mb4_unicode_ci,
  `creado_en` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_marca_modelo` (`marca_id`,`nombre`),
  KEY `idx_marca_id` (`marca_id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `modelos_llanta`
--

INSERT INTO `modelos_llanta` (`id`, `marca_id`, `nombre`, `descripcion`, `creado_en`) VALUES
(1, 1, 'HA01 AT', NULL, '2025-11-26 13:37:04.969283'),
(2, 2, 'Dueler H/T 684 II', NULL, '2025-11-26 13:37:04.969283'),
(3, 2, 'Alenza AS Ultra', NULL, '2025-11-26 13:37:04.969283'),
(4, 3, 'CrossContact LX25', NULL, '2025-11-26 13:37:04.969283'),
(5, 4, 'ST986 Traccion/Minera', NULL, '2025-11-26 13:37:04.969283'),
(6, 5, 'Grandtrek AT20', NULL, '2025-11-26 13:37:04.969283'),
(7, 5, 'Direzza DZ102', NULL, '2025-11-26 13:37:04.969283'),
(8, 6, 'Destination A/T2', NULL, '2025-11-26 13:37:04.969283'),
(9, 7, 'Eagle Sport', NULL, '2025-11-26 13:37:04.969283'),
(10, 7, 'Eagle Sport 2', NULL, '2025-11-26 13:37:04.969283'),
(11, 7, 'Cargo Marathon 2', NULL, '2025-11-26 13:37:04.969283'),
(12, 7, 'Eagle F1 Asymmetric 6', NULL, '2025-11-26 13:37:04.969283'),
(13, 7, 'G28', NULL, '2025-11-26 13:37:04.969283'),
(14, 7, 'Assurance Maxlife', NULL, '2025-11-26 13:37:04.969283'),
(15, 7, 'Assurance WeatherReady', NULL, '2025-11-26 13:37:04.969283'),
(16, 8, 'RS01 Taxi', NULL, '2025-11-26 13:37:04.969283'),
(17, 8, 'H202', NULL, '2025-11-26 13:37:04.969283'),
(18, 8, 'RS23 A/T', NULL, '2025-11-26 13:37:04.969283'),
(19, 9, 'Ventus V12 evo2', NULL, '2025-11-26 13:37:04.969283'),
(20, 10, 'Sport Max S2000', NULL, '2025-11-26 13:37:04.969283'),
(21, 10, 'Practical Max RS21', NULL, '2025-11-26 13:37:04.969283'),
(22, 10, 'Practical Max RS25 M/T', NULL, '2025-11-26 13:37:04.969283'),
(23, 11, 'Crugen HT51', NULL, '2025-11-26 13:37:04.969283'),
(24, 12, 'Razr MT', NULL, '2025-11-26 13:37:04.969283'),
(25, 13, 'Pilot Sport 4S', NULL, '2025-11-26 13:37:04.969283'),
(26, 13, 'Defender LTX M/S', NULL, '2025-11-26 13:37:04.969283'),
(27, 13, 'Latitude Cross', NULL, '2025-11-26 13:37:04.969283'),
(28, 14, 'Scorpion All Terrain Plus', NULL, '2025-11-26 13:37:04.969283'),
(29, 14, 'P Zero', NULL, '2025-11-26 13:37:04.969283'),
(30, 15, 'TR968', NULL, '2025-11-26 13:37:04.969283');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `negocios_llantas`
--

CREATE TABLE IF NOT EXISTS `negocios_llantas` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nombre` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `direccion` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `telefono` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `horarios` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `calificacion` float NOT NULL DEFAULT '0',
  `cantidad_resenas` int NOT NULL DEFAULT '0',
  `descripcion` text COLLATE utf8mb4_unicode_ci,
  `url_mapa_google` text COLLATE utf8mb4_unicode_ci,
  `url_imagen` text COLLATE utf8mb4_unicode_ci,
  `redes_sociales` json DEFAULT NULL COMMENT 'JSON: {facebook, instagram, tiktok, whatsapp}',
  `creado_en` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  `actualizado_en` datetime(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  KEY `idx_nombre` (`nombre`),
  KEY `idx_calificacion` (`calificacion`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `negocios_llantas`
--

INSERT INTO `negocios_llantas` (`id`, `nombre`, `direccion`, `telefono`, `email`, `horarios`, `calificacion`, `cantidad_resenas`, `descripcion`, `url_mapa_google`, `url_imagen`, `redes_sociales`, `creado_en`, `actualizado_en`) VALUES
('biz-1', 'Multillantas Johnny', 'Av. Centenario 1369, Huaraz', '943627557', 'johnny@gmail.com', 'L-S 8:00 AM - 6:00 PM', 4.7, 0, 'Especialistas en llantas Kapsen y Habilead. Ofrecemos los mejores precios y servicio de enllante y balanceo computarizado para todo tipo de vehículo.', 'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d62959.69722708384!2d-77.60441907832029!3d-9.5103732!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x91a90d6f473f41c7%3A0x43b7466a94040b18!2sMULTILLANTAS%20JOHNNY!5e0!3m2!1ses!2spe!4v1764184645172!5m2!1ses!2spe', 'https://i.imgur.com/ETbYoEk.jpeg', '{\"facebook\": \"https://www.facebook.com/share/1EMuuUWjkA/\", \"whatsapp\": \"https://wa.me/51943627557\"}', '2025-11-26 12:14:16.389314', '2025-11-26 16:11:54.321140'),
('biz-2', 'Serviruedas', 'Av. Centenario N°1452, Huaraz', '900000123', 'serviruedas@gmail.com', 'L-V 9:00 AM - 7:00 PM, S 9:00 AM - 2:00 PM', 4.8, 0, 'Distribuidor autorizado de las mejores marcas. Ofrecemos instalación gratuita por la compra de 4 llantas. Asesoramiento personalizado.', 'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3934.9880741776647!2d-77.5322944!3d-9.509765!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x91a90dadcecc9833%3A0x1aa3d95a5fc35c40!2sLLANTAS%20SERVIRUEDAS%20HUARAZ!5e0!3m2!1ses!2spe!4v1764184579304!5m2!1ses!2spe', 'https://i.imgur.com/fcHG2LI.jpeg', '{\"facebook\": \"https://www.facebook.com/share/1A2A7SyHx1/\", \"whatsapp\": \"https://wa.me/51943627730\"}', '2025-11-26 12:14:16.396729', '2025-11-26 16:20:18.453953'),
('biz-3', 'Pimentel - Llantas y servicios', 'Av. Centenario cuadra 30 S/N Vichay', '940271489', 'pimentel@gmail.com', 'L-S 8:30 AM - 6:30 PM', 4.3, 0, 'Venta de llantas, aros, baterías y más. Contamos con equipos de última generación y los mejores profesionales a su servicio.', 'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2014741.3788542578!2d-78.88296814540479!3d-9.50509789452329!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x91a913d98a414423%3A0xcc056efc1c749ede!2sAlfredo%20Pimentel%20Sevilla%20Huaraz!5e0!3m2!1ses!2spe!4v1764184675910!5m2!1ses!2spe', 'https://i.imgur.com/ST4EiQR.jpeg', '{\"facebook\": \"https://www.facebook.com/share/1GPPiGQiSU/\", \"whatsapp\": \"https://wa.me/51940271489\"}', '2025-11-26 12:14:16.400053', '2025-11-26 16:12:01.943753'),
('biz-5', 'Llantas Import Plaza Norte', 'Av. Centenario s/n, Independencia, Huaraz', '936020551', 'plazanorte@gmail.com', 'L-S 9:00 AM - 5:00 PM', 4.6, 0, 'Importadores directos de las mejores marcas. Calidad y garantía a tu alcance.', 'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3934.9986961168893!2d-77.53492392553714!3d-9.50884169985126!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x91a90d9f4d772e6b%3A0xb94fb573fabcbc66!2sLlantas%20Import%20Plaza%20Norte!5e0!3m2!1ses!2spe!4v1764184702812!5m2!1ses!2spe', 'https://i.imgur.com/gsJZey2.jpeg', '{\"facebook\": \"https://www.facebook.com/share/19pP7QGSDX/\", \"whatsapp\": \"https://wa.me/51936020551\"}', '2025-11-26 12:14:16.402882', '2025-11-26 16:12:03.604786');

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `resenas`
--

CREATE TABLE IF NOT EXISTS `resenas` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `negocio_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `usuario_id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `nombre_usuario` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `avatar_usuario` text COLLATE utf8mb4_unicode_ci,
  `calificacion` int NOT NULL COMMENT 'Calificación de 1 a 5',
  `comentario` text COLLATE utf8mb4_unicode_ci,
  `creado_en` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  KEY `idx_negocio_id` (`negocio_id`),
  KEY `idx_usuario_id` (`usuario_id`)
) ;

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `tipos_llanta`
--

CREATE TABLE IF NOT EXISTS `tipos_llanta` (
  `id` int NOT NULL AUTO_INCREMENT,
  `nombre` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
  `descripcion` text COLLATE utf8mb4_unicode_ci,
  `creado_en` datetime DEFAULT (now()),
  PRIMARY KEY (`id`),
  UNIQUE KEY `ix_tipos_llanta_nombre` (`nombre`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Volcado de datos para la tabla `tipos_llanta`
--

INSERT INTO `tipos_llanta` (`id`, `nombre`, `descripcion`, `creado_en`) VALUES
(1, 'Pista / Carretera (H/T)', 'Llantas diseñadas para uso en carretera y ciudad', '2025-11-26 13:36:46'),
(2, 'Uso Mixto (A/T)', 'Llantas todo terreno para uso mixto', '2025-11-26 13:36:46'),
(3, 'Todo Terreno (M/T)', 'Llantas para terreno difícil y off-road', '2025-11-26 13:36:46'),
(4, 'Deportiva (UHP)', 'Llantas de alto rendimiento para vehículos deportivos', '2025-11-26 13:36:46');

--
-- Restricciones para tablas volcadas
--

--
-- Filtros para la tabla `items_inventario`
--
ALTER TABLE `items_inventario`
  ADD CONSTRAINT `items_inventario_ibfk_1` FOREIGN KEY (`negocio_id`) REFERENCES `negocios_llantas` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `items_inventario_ibfk_2` FOREIGN KEY (`llanta_id`) REFERENCES `llantas` (`id`) ON DELETE CASCADE;

--
-- Filtros para la tabla `resenas`
--
ALTER TABLE `resenas`
  ADD CONSTRAINT `resenas_ibfk_1` FOREIGN KEY (`negocio_id`) REFERENCES `negocios_llantas` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `resenas_ibfk_2` FOREIGN KEY (`usuario_id`) REFERENCES `usuarios` (`id`) ON DELETE CASCADE;
COMMIT;

