bubble_chart StackLab

Database Migration

19 steps · pending Not started · person_outline Guest
arrow_back Back

Create the students table

Let's create the table that stores our students. Open:

code text
database/migrations/001_initial_library.sql
Add:
code 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;
The AUTO_INCREMENT setting means MySQL generates the ID automatically:
code text
1
2
3
4
5
...
You don't have to manually assign these numbers.

login Sign in to save your progress permanently. info Progress is saved in your browser session
format_list_numbered Step 5 of 19