What are the best practices for normalizing database structures when working with time-based data in PHP and MySQL?

When working with time-based data in PHP and MySQL, it is important to normalize the database structure to efficiently store and retrieve the data. One common approach is to use a separate table for time-based data, with a foreign key linking it to the main table. This helps in organizing the data and prevents redundancy.

// Create a table for time-based data
$query = "CREATE TABLE IF NOT EXISTS time_data (
            id INT AUTO_INCREMENT PRIMARY KEY,
            main_id INT,
            timestamp DATETIME,
            data VARCHAR(255),
            FOREIGN KEY (main_id) REFERENCES main_table(id)
          )";
mysqli_query($connection, $query);