Create the students table
Let's create the table that stores our students. Open:
text
database/migrations/001_initial_library.sql
sql
CREATE TABLE IF NOT EXISTS students (
student_id INT AUTO_INCREMENT PRIMARY KEY,
student_first_name VARCHAR(50) NOT NULL,
student_last_name VARCHAR(50) NOT NULL,
student_course VARCHAR(50) NOT NULL,
student_created_at TIMESTAMP NOT NULL
DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_general_ci;
AUTO_INCREMENT setting means MySQL generates the ID automatically:
text
1
2
3
4
5
...
Sign in to save your progress permanently.
Progress is saved in your browser session
Step 5 of 19