Thanks.
(I don't know where I was coming from with the JOIN stuff, should have gone
to bed hours ago)

However, you don't think I should have the "ab_id" column, which would be the
standard serial primary key for a table.  Does a junction entity table not
need it's own record ids? Technically, it shouldn't, but does good db form
require it? or is a junction entity normalization table exempt from that?

thanks again
--Dylan Shea

"Carsten H. Pedersen" wrote:

> >  I'm afraid this borders on sql/db question material vs. specific mysql
> > material, but it stems from what I've read in the O'Reilly mysql book.
> >
> > If I have a db, which has two tables that have about 15 fields each.
> >
> <cut>
> > and they have a many to many relationship between them.  Should I
> > a. Create a normalized junction entity.?
>
> Yes.
>
> > table_ab
> > ab_id
> > a_id
> > b_id
>
> Almost right: You don't need an ab_id column. You should,
> however, in most cases make the key (a_id, b_id) UNIQUE.
>
> > or do I
> > b. Just do a JOIN between the tables?
>
> Not unless you have very little data in your tables or
> a lot of patience when doing queries. Besides, It won't
> do exactly what you need anyway so you'd end up doing
> some post-analysis.
>
> > If choice a., how do I do the indexing so that searches for b_id based
> > on a a_id value are fast, and vice-versa?
>
> By indexing both a_id and b_id.
>
> / Carsten
> --
> Carsten H. Pedersen
> keeper and maintainer of the bitbybit.dk MySQL FAQ
> http://www.bitbybit.dk/mysqlfaq


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to