Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/02/2016, 07:26
SwagSwag
 
Fecha de Ingreso: junio-2015
Mensajes: 11
Antigüedad: 8 años, 11 meses
Puntos: 0
Problema con duplicate key (?)

Pues eso, básicamente al insertar la útlima tabla de muchos a muchos me sale el siguiente mensaje:

Error
consulta SQL:


CREATE TABLE jugador_equipo(
id_jugador INT,
id_equipo INT,
PRIMARY KEY(id_jugador, id_equipo),
CONSTRAINT fk_id_jugador FOREIGN KEY (id_jugador) REFERENCES jugador(id),
CONSTRAINT fk_id_equipo FOREIGN KEY (id_equipo) REFERENCES equipo(id)
)
MySQL ha dicho: Documentación

#1005 - Can't create table `myequipo`.`jugador_equipo` (errno: 121 "Duplicate key on write or update") (Detalles…)

Cosa que no entiendo para nada...

La bbdd es esta:

Código SQL:
Ver original
  1. CREATE DATABASE myequipo;
  2.  
  3. USE myequipo;
  4.  
  5. CREATE TABLE competicion(
  6.     id INT PRIMARY KEY AUTO_INCREMENT,
  7.     nombre VARCHAR(50)
  8.     );
  9.  
  10. CREATE TABLE jugador(
  11.     id INT PRIMARY KEY AUTO_INCREMENT,
  12.     nombre VARCHAR(50),
  13.     apellidos VARCHAR(50),
  14.     ciudad VARCHAR(50),
  15.     altura VARCHAR(4),
  16.     peso VARCHAR(3),
  17.     posicion VARCHAR(50),
  18.     id_competicion INT,
  19.     CONSTRAINT fk_id_competicion FOREIGN KEY (id_competicion) REFERENCES competicion(id)
  20.     );
  21.        
  22. CREATE TABLE equipo(
  23.     id INT PRIMARY KEY AUTO_INCREMENT,
  24.     nombre VARCHAR(50),
  25.     ciudad VARCHAR(50),
  26.     nombreEstadio VARCHAR(50)
  27.     );
  28.    
  29. CREATE TABLE usuario(
  30.     id INT PRIMARY KEY AUTO_INCREMENT,
  31.     nombre VARCHAR(50),
  32.     contrasena VARCHAR(50),
  33.     edad INT,
  34.     email VARCHAR(100),
  35.     id_equipo INT,
  36.     CONSTRAINT fk_id_equipo FOREIGN KEY (id_equipo) REFERENCES equipo(id)
  37.     );
  38.    
  39. CREATE TABLE estadisticas(
  40.     id INT PRIMARY KEY AUTO_INCREMENT,
  41.     puntos INT,
  42.     rebotes INT,
  43.     asistencias INT,
  44.     robos INT,
  45.     tapones INT,
  46.     perdidas INT
  47.     );
  48.    
  49. CREATE TABLE jugador_estadisticas(
  50.     id_jugador INT,
  51.     id_estadisticas INT,
  52.     PRIMARY KEY(id_jugador, id_estadisticas),
  53.     CONSTRAINT fk_id_jugador FOREIGN KEY (id_jugador) REFERENCES jugador(id),
  54.     CONSTRAINT fk_id_estadisticas FOREIGN KEY (id_estadisticas) REFERENCES estadisticas(id)
  55.     );
  56.    
  57. CREATE TABLE jugador_equipo(
  58.     id_jugador INT,
  59.     id_equipo INT,
  60.     PRIMARY KEY(id_jugador, id_equipo),
  61.     CONSTRAINT fk_id_jugador FOREIGN KEY (id_jugador) REFERENCES jugador(id),
  62.     CONSTRAINT fk_id_equipo FOREIGN KEY (id_equipo) REFERENCES equipo(id)
  63.     );