Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Aaron Marton
Aaron Marton
13,070 Points

relational database

You have a relational database for a school. In this database there is a students table and a class table. This data would connect in which type of relationship?

Please explain to me why is this a many-to-many relationship between the two tables.

1 Answer

jamesjones21
jamesjones21
9,260 Points

As stated, there are many students to many classes, so there are more than one student taking more than one class hence many to many. So for a clearer picture, each class within the Classes table will have an id, then within the Students table there will be a column with classes, with multiple id separated by a comma. I'm a student and I have classes 4,6,7,10:

Which 4 = Maths, 6 = English, 7 = Science and 10 Physical Education.

Aaron Marton
Aaron Marton
13,070 Points

I see. Thank you for your help.

jamesjones21
jamesjones21
9,260 Points

no problem at all, could you please mark this down as the best answer if it has helped you understand a little better? As this will help me out beneficially :)