CREATE DATABASE  IF NOT EXISTS `tienda_moviles_2` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `tienda_moviles_2`;
-- MySQL dump 10.13  Distrib 8.0.36, for Win64 (x86_64)
--
-- Host: localhost    Database: tienda_moviles_2
-- ------------------------------------------------------
-- Server version	8.0.36

/*!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 */;
/*!50503 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `clientes`
--

DROP TABLE IF EXISTS `clientes`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `clientes` (
  `id_cliente` int NOT NULL AUTO_INCREMENT,
  `nombre_cliente` varchar(25) NOT NULL,
  `apellido_cliente` varchar(50) NOT NULL,
  `cif_cliente` varchar(10) NOT NULL,
  `id_poblaciones` int NOT NULL,
  PRIMARY KEY (`id_cliente`),
  KEY `clientes_poblacion_id_poblacion` (`id_poblaciones`),
  CONSTRAINT `clientes_poblacion_id_poblacion` FOREIGN KEY (`id_poblaciones`) REFERENCES `poblaciones` (`id_poblaciones`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `clientes`
--

LOCK TABLES `clientes` WRITE;
/*!40000 ALTER TABLE `clientes` DISABLE KEYS */;
INSERT INTO `clientes` VALUES (1,'Bill','Gates','1111111111',1),(2,'Elon ','Musk','2222222222',2),(3,'Jeff','Bezzos','333333333',2),(4,'Tim','Berners','4444444444',2),(5,'Francisco','Fernández','98237768M',7),(6,'María Isabel','Redondo','18780120D',9),(7,'Juan','Medina','95978318O',7),(8,'Rosa María','Santos','91436690N',3),(9,'Alejandro','Guerrero','98147971C',1),(10,'Carmen','Gutiérrez','55309407B',7),(11,'Rafael','Blanco','64176764G',2),(12,'Juana','Ramírez','01027845U',3),(13,'José Luis','Sanz','59667257L',10),(14,'Rosa María','Pérez','17079624F',4),(15,'Rafael','Vázquez','25138048C',3),(16,'María Teresa','Castro','66491162A',10),(17,'José','Garrido','55701019R',2),(18,'Rosa María','Delgado','78079413Q',8),(19,'Daniel','Gil','65753196X',7),(20,'Isabel','Redondo','08981327Y',1),(21,'Miguel Ángel','Domínguez','59975391C',8),(22,'María','Fernández','07863159O',3),(23,'Pedro','Vázquez','55273950J',2),(24,'Ana','Gil','66691115M',3);
/*!40000 ALTER TABLE `clientes` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `facturas`
--

DROP TABLE IF EXISTS `facturas`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `facturas` (
  `id_factura` int NOT NULL AUTO_INCREMENT,
  `id_cliente` int NOT NULL,
  `id_producto` int NOT NULL,
  `cantidad` decimal(8,2) NOT NULL,
  `fecha` date NOT NULL,
  PRIMARY KEY (`id_factura`),
  KEY `id_cliente_factura` (`id_cliente`),
  KEY `id_producto_factura` (`id_producto`),
  CONSTRAINT `id_cliente_factura` FOREIGN KEY (`id_cliente`) REFERENCES `clientes` (`id_cliente`),
  CONSTRAINT `id_producto_factura` FOREIGN KEY (`id_producto`) REFERENCES `productos` (`id_producto`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `facturas`
--

LOCK TABLES `facturas` WRITE;
/*!40000 ALTER TABLE `facturas` DISABLE KEYS */;
INSERT INTO `facturas` VALUES (1,2,3,1.00,'2024-04-02'),(2,3,4,2.00,'2024-04-01'),(3,4,8,4.00,'2024-03-02'),(4,2,5,3.00,'2024-02-02'),(5,3,2,1.00,'2024-04-03'),(6,4,5,2.00,'2024-03-22'),(7,3,3,1.00,'2024-04-02'),(8,1,3,1.00,'2024-04-02'),(9,4,3,1.00,'2024-04-02'),(10,1,3,1.00,'2024-04-02'),(11,1,6,1.00,'2024-04-01'),(12,2,4,1.00,'2024-01-02'),(13,2,3,8.00,'2023-10-02'),(14,18,12,1.00,'2023-12-20'),(15,15,13,2.00,'2023-11-28'),(16,12,5,1.00,'2023-10-06'),(17,14,10,1.00,'2023-12-14'),(18,10,10,1.00,'2023-12-21'),(19,9,10,1.00,'2024-01-05'),(20,9,5,3.00,'2024-01-18');
/*!40000 ALTER TABLE `facturas` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `familia_producto`
--

DROP TABLE IF EXISTS `familia_producto`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `familia_producto` (
  `id_familia_producto` int NOT NULL AUTO_INCREMENT,
  `nombre_familia` varchar(30) NOT NULL,
  PRIMARY KEY (`id_familia_producto`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `familia_producto`
--

LOCK TABLES `familia_producto` WRITE;
/*!40000 ALTER TABLE `familia_producto` DISABLE KEYS */;
INSERT INTO `familia_producto` VALUES (1,'Smartphone Apple'),(2,'Smartphone Android'),(3,'Tablet Apple'),(4,'Tablet Android'),(5,'Otros');
/*!40000 ALTER TABLE `familia_producto` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `poblaciones`
--

DROP TABLE IF EXISTS `poblaciones`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `poblaciones` (
  `id_poblaciones` int NOT NULL AUTO_INCREMENT,
  `nombre_poblacion` varchar(30) NOT NULL,
  PRIMARY KEY (`id_poblaciones`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `poblaciones`
--

LOCK TABLES `poblaciones` WRITE;
/*!40000 ALTER TABLE `poblaciones` DISABLE KEYS */;
INSERT INTO `poblaciones` VALUES (1,'Seattle'),(2,'Barcelona'),(3,'Cornellà'),(4,'Hospitalet de Llobregat'),(5,'El Prat de Llobregat'),(6,'París'),(7,'Roma'),(8,'Berlín'),(9,'Berna'),(10,'Basilea');
/*!40000 ALTER TABLE `poblaciones` ENABLE KEYS */;
UNLOCK TABLES;

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

DROP TABLE IF EXISTS `productos`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `productos` (
  `id_producto` int NOT NULL AUTO_INCREMENT,
  `nombre_producto` varchar(30) NOT NULL,
  `id_familia_producto` int NOT NULL,
  `precio_producto` decimal(8,2) NOT NULL,
  `iva_producto` decimal(3,2) NOT NULL DEFAULT '0.21',
  `id_proveedor` int NOT NULL,
  stock int DEFAULT '10',
  PRIMARY KEY (`id_producto`),
  KEY `id_productos_familia` (`id_familia_producto`),
  KEY `id_proveedores_productos` (`id_proveedor`),
  CONSTRAINT `id_productos_familia` FOREIGN KEY (`id_familia_producto`) REFERENCES `familia_producto` (`id_familia_producto`),
  CONSTRAINT `id_proveedores_productos` FOREIGN KEY (`id_proveedor`) REFERENCES `proveedores` (`id_proveedor`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

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

LOCK TABLES `productos` WRITE;
/*!40000 ALTER TABLE `productos` DISABLE KEYS */;
INSERT INTO `productos` VALUES 
(1,'IPhone 15 Plus',1,1500.00,0.21,3,10),
(2,'IPhone 14',1,1000.00,0.21,1,10),
(3,'IPhone 12 Plus',1,500.00,0.21,3,10),
(4,'IPhone 15',1,1200.00,0.21,3,10),
(5,'Samsung S24',2,1200.00,0.21,4,10),
(6,'Xiaomi Redmi 12',2,800.00,0.21,1,10),
(7,'Samsung S22 Pro',2,1000.00,0.21,1,10),
(8,'Ipad 2022',3,500.00,0.21,3,10),
(9,'Apple Watch',5,650.00,0.21,3,10),
(10,'Samsung Smart TV',5,980.50,0.21,4,10),
(11,'Samsung Galaxy Tab S9',4,880.00,0.21,10,10),
(12,'Macbook Pro M3',5,2500.00,0.21,11,10),
(13,'Macbook Pro M2',5,2000.00,0.21,6,10),
(14,'Macbook Pro M1',5,1500.00,0.21,3,10),
(15,'Xiaomi Pad',4,420.00,0.21,11,10),
(16,'Xiaomi 12',2,690.00,0.21,5,10),
(17,'Samsung A14',2,170.00,0.21,1,10),
(18,'Huawei P30',2,530.00,0.21,6,10),
(19,'Samsung Galaxy Tab S9 Pro',4,1200.00,0.21,6,10),
(20,'Oppo A52',2,450.00,0.21,6,10),
(21,'Oppo A52',2,500.00,0.21,11,10),
(22,'Oppo A52',2,500.00,0.21,11, 10);
/*!40000 ALTER TABLE `productos` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `proveedores`
--

DROP TABLE IF EXISTS `proveedores`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `proveedores` (
  `id_proveedor` int NOT NULL AUTO_INCREMENT,
  `nombre_proveedor` varchar(30) NOT NULL,
  `id_poblaciones` int NOT NULL,
  PRIMARY KEY (`id_proveedor`),
  KEY `id_poblaciones_proveedor` (`id_poblaciones`),
  CONSTRAINT `id_poblaciones_proveedor` FOREIGN KEY (`id_poblaciones`) REFERENCES `poblaciones` (`id_poblaciones`)
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `proveedores`
--

LOCK TABLES `proveedores` WRITE;
/*!40000 ALTER TABLE `proveedores` DISABLE KEYS */;
INSERT INTO `proveedores` VALUES (1,'Amazon',1),(2,'Ali Express',2),(3,'Apple Store',1),(4,'Samsung Store',2),(5,'Xiaomi',1),(6,'Media Markt',2),(7,'Bueno, bonito, barato',5),(8,'Lidl',8),(9,'Aldi',8),(10,'Worten',8),(11,'El Corte Inglés',2),(12,'Phone House',2),(13,'Mobile House',8),(14,'Movistar',2),(15,'Vodafone',3),(16,'O2',3),(17,'PC Componentes',4),(18,'FNAC',6),(19,'Miravia',6),(20,'Jazztel',8);
/*!40000 ALTER TABLE `proveedores` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!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 */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2024-04-05 10:07:40
