CREATE TABLE IF NOT EXISTS product_relations ( product_id INT NOT NULL, related_product_id INT NOT NULL, PRIMARY KEY (product_id, related_product_id), FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE, FOREIGN KEY (related_product_id) REFERENCES products(id) ON DELETE CASCADE );