Create a Course model to store course data and establish relationships between instructors, students, and projects. This model will be essential for managing course information and linking it to the projects and users (instructors/students).
Key Elements:
Course Attributes:
Name: String, required (e.g., "SOEN 341").
Description: Text, optional, provides additional details about the course.
Instructor ID: Foreign key linking the course to the User model.
Associations:
Instructor:
A course belongs_to an instructor.
The association will be established by adding a foreign_key: instructor_id in the Course model.
Students:
A course has_many students through an enrollment or membership system.
Use a join table (courses_students) or a CourseMembership model to associate students with multiple courses.
Projects:
A course has_many projects.
Each project will be linked to a course by a course_id foreign key.
Evaluations:
A course has_many evaluations through projects.
Evaluations will be indirectly linked to courses via projects.
Validations:
Name: Must be present and unique within the scope of the instructor (i.e., an instructor cannot have two courses with the same name).
Description: Optional, but has a character limit to prevent overly long descriptions.
Technical Details:
Generate a migration to create the courses table with the following fields:
name (string)
description (text)
instructor_id (foreign key)
Ensure that associations with instructors, students, and projects are set up properly in both the Course model and other related models (User, Project).
don't forget to replace 'course_name' from teams to 'project_id' to link a team -> project -> course.
Description:
Create a
Course
model to store course data and establish relationships between instructors, students, and projects. This model will be essential for managing course information and linking it to the projects and users (instructors/students).Key Elements:
Course Attributes:
User
model.Associations:
belongs_to
an instructor.foreign_key: instructor_id
in theCourse
model.has_many
students through an enrollment or membership system.courses_students
) or aCourseMembership
model to associate students with multiple courses.has_many
projects.course_id
foreign key.has_many
evaluations through projects.Validations:
Technical Details:
courses
table with the following fields:name
(string)description
(text)instructor_id
(foreign key)Course
model and other related models (User
,Project
).description
to teamscourse_id
to projectsinstructor_id
from users