What considerations should be made when working with IDs in a database, especially when deleting entries?

When working with IDs in a database, especially when deleting entries, it is important to consider the potential impact on related data. Before deleting a record, ensure that any related data (such as foreign key constraints) is properly handled to avoid orphaned records. Additionally, consider implementing soft deletes instead of hard deletes to maintain data integrity.

// Example of soft delete in PHP using a database query
$id = 123; // ID of the record to be deleted
$query = "UPDATE table_name SET deleted_at = NOW() WHERE id = $id";
// Execute the query to perform a soft delete