How do I prepare my database to handle many-to-many relation?
Wayne L Johnson
posted 13 years ago
Perhaps the most common method is to create a third table where you store foreign keys into the two tables in the relationship. So if you have STUDENT and CLASS tables, and you want to manage them in a many-to-many relationship, do something like this:
You could add a primary key to the "STUDENT_CLASS" key that is separate from the StudentID/ClassID combination, and possibly have other information (DateCreated, etc). But using a join table like this is the most common approach.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads