What are the advantages and disadvantages of using a database versus a log file for creating a track history from a Shoutcast server using PHP?

When creating a track history from a Shoutcast server using PHP, using a database to store the track information has the advantage of allowing for easier querying, sorting, and filtering of the data. It also provides a more structured and organized way to store the information. However, using a database may introduce additional overhead and complexity compared to simply writing the track information to a log file.

// Using a database to store track history
// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "track_history";

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Store track information in the database
$track = "Track Name";
$artist = "Artist Name";
$timestamp = date('Y-m-d H:i:s');

$sql = "INSERT INTO tracks (track, artist, timestamp) VALUES ('$track', '$artist', '$timestamp')";

if ($conn->query($sql) === TRUE) {
    echo "Track information stored successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();