From the course: Relational Databases Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Many-to-many relationships

Many-to-many relationships

From the course: Relational Databases Essential Training

Start my 1-month free trial

Many-to-many relationships

- The third and final type of relationship that you can create is a many-to-many relationship. If you've been following along then it's probably no surprise that a many-to-many relationship is created between two columns where neither of them have a unique constraint applied. In theory this is what a many-to-many relationship looks like in a design diagram. Here we have a database that keeps track of class schedules for a university. Each student can be enrolled in zero to multiple classes and each class can have between zero and many students. I've noted the optionality and cardinality here so we can clearly see the need for a many-to-many relationship based on the cardinality of N at both ends. However, there isn't a good way to relate the tables together based (mumbles) the columns that we have. To create the relationship according to the cardinality we would need a non-unique column in each table. The…

Contents