CREATE TABLE IF NOT EXISTS product_attributes ( id INT AUTO_INCREMENT PRIMARY KEY, product_id INT NOT NULL, attribute_key_id INT NOT NULL, value TEXT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE, FOREIGN KEY (attribute_key_id) REFERENCES attribute_keys(id) ON DELETE CASCADE, UNIQUE KEY `product_attribute` (product_id, attribute_key_id) );