Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/06/2014, 07:38
daviss
 
Fecha de Ingreso: agosto-2010
Mensajes: 59
Antigüedad: 13 años, 8 meses
Puntos: 2
Respuesta: Poner clave foránea compuesta en phpmyadmin

Esta es la estructura:
Código:
CREATE TABLE IF NOT EXISTS `tabla1` (
  `clave1` int(11) NOT NULL,
  `clave2` int(11) NOT NULL,
  `otro` int(11) NOT NULL,
  PRIMARY KEY (`clave1`,`clave2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

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

--
-- Estructura de tabla para la tabla `tabla2`
--

CREATE TABLE IF NOT EXISTS `tabla2` (
  `prikey` int(11) NOT NULL,
  `ref1` int(11) NOT NULL,
  `ref2` int(11) NOT NULL,
  PRIMARY KEY (`prikey`),
  KEY `ref1` (`ref1`),
  KEY `ref2` (`ref2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Quise referenciar los campos ref1 y ref2 de la tabla2 a la clave primaria de la tabla1 (clave1 y clave2).
Le puse "Agregar indice" a ref1 y ref2 pero, al momento de relacionarlo en "Vista de relaciones" solo estan las opciones :
Código:
`bdprueba`.`tabla1`.`clave1`
`bdprueba`.`tabla2`.`prikey`
`bdprueba`.`tabla2`.`ref1`
`bdprueba`.`tabla2`.`ref2`
Este problema, no es nuevo aqui hay otro.

Bueno graciass