What are some best practices for structuring MySQL databases for storing race results data?

When structuring MySQL databases for storing race results data, it is important to design a schema that efficiently stores and retrieves information such as race name, date, location, participants, and results. One common approach is to have separate tables for races, participants, and results, with appropriate relationships defined between them using foreign keys. This allows for easy querying and updating of race data while maintaining data integrity.

CREATE TABLE races (
    race_id INT PRIMARY KEY AUTO_INCREMENT,
    race_name VARCHAR(50) NOT NULL,
    race_date DATE NOT NULL,
    race_location VARCHAR(50) NOT NULL
);

CREATE TABLE participants (
    participant_id INT PRIMARY KEY AUTO_INCREMENT,
    race_id INT,
    participant_name VARCHAR(50) NOT NULL,
    participant_age INT,
    FOREIGN KEY (race_id) REFERENCES races(race_id)
);

CREATE TABLE results (
    result_id INT PRIMARY KEY AUTO_INCREMENT,
    race_id INT,
    participant_id INT,
    finish_time TIME,
    FOREIGN KEY (race_id) REFERENCES races(race_id),
    FOREIGN KEY (participant_id) REFERENCES participants(participant_id)
);