What are some best practices for linking non-descriptive file names to more user-friendly names in a MySQL database?

When storing files in a MySQL database, it is common to use non-descriptive file names for efficiency. However, for better user experience, it is recommended to link these non-descriptive file names to more user-friendly names. One way to achieve this is by creating a separate table in the database to store the mapping between the non-descriptive file names and their user-friendly names.

// Assuming you have a table named 'files' with columns 'id', 'file_name', and 'user_friendly_name'
// Create a new table named 'file_mapping' with columns 'id', 'file_name', and 'user_friendly_name'

// Retrieve the non-descriptive file names and their user-friendly names from the 'file_mapping' table
$query = "SELECT file_name, user_friendly_name FROM file_mapping";
$result = mysqli_query($connection, $query);

// Store the mapping in an associative array
$fileMapping = [];
while ($row = mysqli_fetch_assoc($result)) {
    $fileMapping[$row['file_name']] = $row['user_friendly_name'];
}

// Use the mapping to display user-friendly names instead of non-descriptive file names
$query = "SELECT id, file_name FROM files";
$result = mysqli_query($connection, $query);

while ($row = mysqli_fetch_assoc($result)) {
    $userFriendlyName = $fileMapping[$row['file_name']];
    echo "File ID: " . $row['id'] . ", User-Friendly Name: " . $userFriendlyName . "<br>";
}