First thing create the new students table to hold the clean data - I'm going to call it new. It will have exactly the same structure as the existing table except that the unique_key should have a unique index to prevent this happening again.
$sql1 = "INSERT INTO new
SELECT MIN(id), student_first_name, student_last_name, email, application_date, modification_date, unique_key
FROM student
GROUP BY id, student_first_name, student_last_name, email, application_date, modification_date, unique_key":
Check it when you're done. The data should be correct but check it anyway.
Now, to clean up related tables you do this: (I'm going to sue a tabel called example)
$sql = "UPDATE example e INNER JOIN students s ON (e.student_id=s.id)
INNER JOIN new n ON (s.id=n.id)
SET e.student_id=n.id)";
// or you could use
$sql = "UPDATE example e INNER JOIN students s ON (e.student_id=s.id)
INNER JOIN new n ON (s.unique_key=n.unique_key)
SET e.student_id=n.id)";
That will update the related table with the id from the clean data no matter what id it had from the dirty table.