-- Fix Foreign Key Constraint for Registration
-- Make employee_id nullable and remove foreign key constraint for registration records

USE face_recognition_db;

-- Drop the foreign key constraint
ALTER TABLE employee_faces 
DROP FOREIGN KEY IF EXISTS employee_faces_ibfk_1;

-- Make employee_id nullable
ALTER TABLE employee_faces 
MODIFY COLUMN employee_id INT NULL;

-- Optionally, add a new foreign key that allows NULL
-- But for registration, we'll keep it without foreign key constraint
-- ALTER TABLE employee_faces 
-- ADD CONSTRAINT employee_faces_ibfk_1 
-- FOREIGN KEY (employee_id) REFERENCES employees(id) ON DELETE CASCADE;

-- Verify
DESCRIBE employee_faces;

