Junction Tables - Necessary, Useful, or Neither?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi there

I've designed some web applications that are fairly small scale (thousands
of users) but my MySQL tables are indexed well and they all run quickly and

Today I decided to pick up a book on MySQL to learn more about what I don't
know about it... and the book suggests using "Junction Tables" to record
many to many relationships.  I've never used them before (or been aware of
them) and I'm wondering what people's opinions on them were?  I just don't
see their particular usefulness in anything i've created so far - can that
be true or am I just not getting something?


Re: Junction Tables - Necessary, Useful, or Neither?

Good Man wrote:
Quoted text here. Click to load it

Also called Bridge, Link and Composite tables they are used to
convert a many-to-many relationship into one-to-many
relationships.  This is done because relational database
management systems don't work well, if at all, with many-to-many


Re: Junction Tables - Necessary, Useful, or Neither?

On Tue, 04 Oct 2005 00:07:37 -0500, in mailing.database.mysql Good Man

Quoted text here. Click to load it


Books             Authors
-------           ------
BookID     /----- AuthorID
Title      |      Name

This allows for a book written by a single author.

Books         Links             Authors
-------       -----             ------
BookID ------ fkBookID       /-- AuthorID
Title         fkAuthorID ---/   Name

This allows for a book to be published with one or more authors.
jnorthau@yourpantsyahoo.com.au  : Remove your pants to reply

Re: Junction Tables - Necessary, Useful, or Neither?

Quoted text here. Click to load it

My reader totally killed this example's formatting.  :(  Very sad.

But as far as the relationships go-yes, i use them to model
many-to-many relationships.  For ((another)) example, a user / groups
database.  There can be many users and many groups, and every group can
have any number of members in it, and any member can ((if they meet the
right requirements ;) )) be a member of many different groups.  I have
a seperate table between users and groups so that i don't have to
double-store the data ((that is, keeping either group data in the user
data tables or user data in the group data tables)) and so that i don't
store negatives: only users with a group are in the "Junction" table,
and likewise for groups with a user.

Just another example.  :)


Site Timeline