While trying to create a new table, MySQL is giving me an error I cannot explain.
CREATE TABLE Products (
id INT NOT NULL,
PRIMARY KEY(id)
);
CREATE TABLE WarehouseMovements (
time DATETIME NOT NULL,
product1 INT NOT NULL,
product2 INT NOT NULL,
FOREIGN KEY WarehouseMovements(product1) REFERENCES Products(id),
FOREIGN KEY WarehouseMovements(product2) REFERENCES Products(id)
);
This fails with ERROR 1061 (42000): Duplicate key name 'WarehouseMovements'
. If I remove the foreign key constraints this succeeds, but I want to make sure product1 and product2 are actually pointing to somewhere.
Default engine is InnoDB.
What's wrong with the query?