CompTIA DataSys+ (DS0-001)Database FundamentalsMedium

A database architect is designing a schema for a new online learning platform. They need to represent that a 'Student' can enroll in multiple 'Courses', and a 'Course' can have multiple 'Students' enrolled. Which type of relationship best describes this scenario?

  1. AMany-to-One
  2. BOne-to-One
  3. COne-to-Many
  4. DMany-to-Many
Show answer & explanation

Correct answer: D. Many-to-Many

A Many-to-Many relationship exists when one record in table A can relate to multiple records in table B, and one record in table B can relate to multiple records in table A. In this case, a student can enroll in many courses, and a course can have many students.

Why the other options are wrong

  • A. Many-to-One is the inverse of One-to-Many, meaning many students can take one course, but each student can only take one course, which is incorrect.
  • B. One-to-One means one student takes exactly one course, and one course has exactly one student, which is incorrect.
  • C. One-to-Many means one student can take many courses, but each course can only have one student, which is incorrect.

Many-to-Many Relationship

A type of database relationship where one record in table A can be linked to multiple records in table B, and one record in table B can be linked to multiple records in table A.

  • Requires an intermediary (junction/associative) table to resolve in a relational database.
  • The junction table typically contains foreign keys to both related tables.
  • Common in real-world scenarios like products and orders, students and courses.

Memory trick: Many-to-Many means 'Many' on 'Both' sides.

More Database Fundamentals questions