What are some potential database structures for creating an interactive school timetable in PHP?

To create an interactive school timetable in PHP, you can use a database structure that includes tables for classes, teachers, rooms, and schedule. Each class can have multiple teachers and be assigned to a specific room at a certain time. The schedule table can store the timetable information such as class ID, teacher ID, room ID, day, and time slot.

// Create a MySQL database and tables for classes, teachers, rooms, and schedule

// Connect to MySQL
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "school_timetable";

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

// Create tables
$sql = "CREATE TABLE classes (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(50) NOT NULL
)";

$conn->query($sql);

$sql = "CREATE TABLE teachers (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(50) NOT NULL
)";

$conn->query($sql);

$sql = "CREATE TABLE rooms (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(50) NOT NULL
)";

$conn->query($sql);

$sql = "CREATE TABLE schedule (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    class_id INT(6) UNSIGNED,
    teacher_id INT(6) UNSIGNED,
    room_id INT(6) UNSIGNED,
    day VARCHAR(10) NOT NULL,
    time_slot VARCHAR(10) NOT NULL,
    FOREIGN KEY (class_id) REFERENCES classes(id),
    FOREIGN KEY (teacher_id) REFERENCES teachers(id),
    FOREIGN KEY (room_id) REFERENCES rooms(id)
)";

$conn->query($sql);

// Close the connection
$conn->close();