# Part 6 - Database

  • Create the correct migrations and Eloquent models for the following database schema
  • Add relationships between the Eloquent models

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: 11/12/2022, 2:48:52 PM