Ver Mensaje Individual
  #15 (permalink)  
Antiguo 12/12/2014, 06:29
gralf
 
Fecha de Ingreso: noviembre-2014
Mensajes: 76
Antigüedad: 10 años, 1 mes
Puntos: 0
Respuesta: no se como restringir entrada de datos

vaya pues debe ser un error mio, si que exporta las fk, ya lo tengo arreglado


Código MySQL:
Ver original
  1. -- phpMyAdmin SQL Dump
  2. -- version 2.10.3
  3. -- http://www.phpmyadmin.net
  4. --
  5. -- Host: localhost
  6. -- Generation Time: Dec 12, 2014 at 01:21 PM
  7. -- Server version: 5.5.28
  8. -- PHP Version: 5.3.26
  9.  
  10. SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
  11.  
  12. --
  13. -- Database: `stocklentesbrujuleando3`
  14. --
  15.  
  16. -- --------------------------------------------------------
  17.  
  18. --
  19. -- Table structure for table `cilindro`
  20. --
  21.  
  22. CREATE TABLE `cilindro` (
  23.   `id_cil` int(2) NOT NULL AUTO_INCREMENT,
  24.   `cilindro` decimal(5,2) NOT NULL,
  25.   PRIMARY KEY (`id_cil`)
  26.  
  27. -- --------------------------------------------------------
  28.  
  29. --
  30. -- Table structure for table `esfera`
  31. --
  32.  
  33. CREATE TABLE `esfera` (
  34.   `id_esf` int(5) NOT NULL AUTO_INCREMENT,
  35.   `esfera` decimal(5,2) NOT NULL,
  36.   PRIMARY KEY (`id_esf`)
  37.  
  38. -- --------------------------------------------------------
  39.  
  40. --
  41. -- Table structure for table `item`
  42. --
  43.  
  44. CREATE TABLE `item` (
  45.   `id_item` int(5) NOT NULL AUTO_INCREMENT,
  46.   `id_rx` int(2) NOT NULL,
  47.   `id_lente` int(2) NOT NULL,
  48.   `movimiento_id_mov` int(5) unsigned DEFAULT NULL,
  49.   PRIMARY KEY (`id_item`),
  50.   KEY `fk_item_lentes1_idx` (`id_lente`),
  51.   KEY `fk_item_rx1_idx` (`id_rx`)
  52.  
  53. -- --------------------------------------------------------
  54.  
  55. --
  56. -- Table structure for table `lentes`
  57. --
  58.  
  59. CREATE TABLE `lentes` (
  60.   `id_lente` int(2) NOT NULL AUTO_INCREMENT,
  61.   `lente` varchar(25) NOT NULL,
  62.   `desc` varchar(45) NOT NULL,
  63.   `Abbe` int(2) NOT NULL,
  64.   `densidad` varchar(15) NOT NULL,
  65.   `geometría` varchar(15) NOT NULL,
  66.   `id_item` int(5) NOT NULL,
  67.   PRIMARY KEY (`id_lente`),
  68.   UNIQUE KEY `tipo` (`lente`),
  69.   KEY `fk_lentes_item_idx` (`id_item`)
  70.  
  71. -- --------------------------------------------------------
  72.  
  73. --
  74. -- Table structure for table `movimiento`
  75. --
  76.  
  77. CREATE TABLE `movimiento` (
  78.   `venta` int(5) unsigned DEFAULT NULL,
  79.   `compra` int(5) unsigned DEFAULT NULL,
  80.   `taller` int(5) unsigned DEFAULT NULL,
  81.   `regula_mas` int(5) unsigned DEFAULT NULL,
  82.   `regula_menos` int(5) unsigned DEFAULT NULL,
  83.   `id_item` int(5) NOT NULL,
  84.   `id_lente` int(2) DEFAULT NULL,
  85.   `id_cilindro` int(2) DEFAULT NULL,
  86.   `id_esfera` int(5) DEFAULT NULL,
  87.   PRIMARY KEY (`id_mov`),
  88.   KEY `fk_movimiento_cilindro1_idx` (`id_cilindro`),
  89.   KEY `fk_movimiento_esfera1_idx` (`id_esfera`),
  90.   KEY `fk_movimiento_lentes1` (`id_lente`),
  91.   KEY `fk_salida_item1_idx` (`id_item`)
  92.  
  93. -- --------------------------------------------------------
  94.  
  95. --
  96. -- Table structure for table `rx`
  97. --
  98.  
  99. CREATE TABLE `rx` (
  100.   `Id_rx` int(2) NOT NULL AUTO_INCREMENT,
  101.   `id_cil` int(2) NOT NULL,
  102.   `id_esf` int(5) NOT NULL,
  103.   PRIMARY KEY (`Id_rx`),
  104.   KEY `fk_rx_cilindro1_idx` (`id_cil`),
  105.   KEY `fk_rx_esfera1_idx` (`id_esf`)
  106.  
  107. --
  108. -- Constraints for dumped tables
  109. --
  110.  
  111. --
  112. -- Constraints for table `item`
  113. --
  114. ALTER TABLE `item`
  115.   ADD CONSTRAINT `fk_item_lentes1` FOREIGN KEY (`id_lente`) REFERENCES `lentes` (`id_lente`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  116.   ADD CONSTRAINT `fk_item_rx1` FOREIGN KEY (`id_rx`) REFERENCES `rx` (`Id_rx`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  117.  
  118. --
  119. -- Constraints for table `movimiento`
  120. --
  121. ALTER TABLE `movimiento`
  122.   ADD CONSTRAINT `fk_movimiento_cilindro1` FOREIGN KEY (`id_cilindro`) REFERENCES `cilindro` (`id_cil`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  123.   ADD CONSTRAINT `fk_movimiento_esfera1` FOREIGN KEY (`id_esfera`) REFERENCES `esfera` (`id_esf`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  124.   ADD CONSTRAINT `fk_movimiento_lentes1` FOREIGN KEY (`id_lente`) REFERENCES `lentes` (`id_lente`) ON DELETE NO ACTION ON UPDATE NO ACTION;
  125.  
  126. --
  127. -- Constraints for table `rx`
  128. --
  129.   ADD CONSTRAINT `fk_rx_cilindro1` FOREIGN KEY (`id_cil`) REFERENCES `cilindro` (`id_cil`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  130.   ADD CONSTRAINT `fk_rx_esfera1` FOREIGN KEY (`id_esf`) REFERENCES `esfera` (`id_esf`) ON DELETE NO ACTION ON UPDATE NO ACTION;




pero sigo pudiendo meter un movimiento.id_item 4000 y este id no existe en la tabla item