Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Many to Many Association Tables - Is it customary to put additional columns in these tables?

We've encountered the following situation in our database. We have table 'A' and table 'B' which have a M2M relationship. The association table is named 'AB' and contains a FK column to table 'A' and a FK column to table 'B'. Now we've identified a need to store additional data about this association. For example, a date when the association occurred, and who made the association etc. We've decided to put these additional columns in the 'AB' association table. However, something tells me this is frowned upon by database purists. On the other hand, it makes no sense to us to create yet an additional table to store this associated data.

What's the prevailing thought on this?

like image 340
Randy Minder Avatar asked Mar 24 '10 14:03

Randy Minder


1 Answers

I see nothing wrong with that at all. If the information is regarding the association itself it seems the absolute correct place to store it.

If you would create a new table to store this in, it would just relate to the associaton table anyways one to one. This essentially would just be extending the association table.

like image 175
Gratzy Avatar answered Oct 01 '22 00:10

Gratzy