Storing/Accessing values in many to many relationship

I have two database collections in a M:N relationship. I can associate records from one collection with records in the other collection, but how do I add values for a specific association?

Here are more details on a problem that I am encoutering: Students collection is in MN relationship with Courses colleciton. Students have student properties and Courses have course properties. How can I store the final grade of a specific student for a specific course?

Thanks!

Hi @byu777,

You will have to use a separate table (collection) for that, you can’t simply use m2m relationship. In your case it could be “Enrolments” collection, which have:

  • relation to Students (1 student - many enrolments)
  • relation to Courses (1 course - many enrolments)
  • payload: grade, date, comments, etc.

Best,
Victor.

1 Like

Thanks @Victor!

How do I show data from Enrolments collection and Students collection or Courses collection at the same time. The Simple List only allows data from one collection to be displayed at any one time. Is there a way to “join” two collections in Adalo?

Thanks!
Ben

Hi Ben @byu777,

You don’t need to do “joins” in Adalo manually - it kind of takes care about it.

  • you create a collection “Enrolments” with the relationships from above
  • you add any list and set it to display “Enrolments”
  • inside the list you can display property values using Magic Text
  • and these values could be taken not only from Enrolments, but also from linked collections. So if you’d like to display a first name for a student, you will use a relationship Current Enrolment → Student → First name.

In the screenshot below I’m using a list of Images, but I display User-Owner Full name as a subtitle:

Best regards, Victor.

2 Likes

Thanks @Victor!! Your solution works!

Best regards,
Ben

1 Like