Part 5 - Database

  • Create the correct migrations and Eloquent models for the following database schema:

Database model

REMARKS

  • The many side of the relationship always holds the foreign key
    • A programme can have multiple students subscribed -> programme_id is defined in students table
  • A student can enroll in multiple courses AND a course can be followed by multiple students. This is a many-to-many relationship which we have to implement by using an associative table student_courses.
    • If you use the command php artisan make:model StudentCourse -m, the corresponding database table will be named student_courses. According to the naming conventions, we also advice to use studentcourses() as the associated Eloquent hasMany relationship method.
Last Updated: 10/13/2020, 8:24:21 PM