[thelist] SQL for what I think might be many to many

Ken Kogler ken at kenkogler.com
Fri Apr 19 16:12:01 CDT 2002


What you're describing (some sort if cross-reference table) really is
the best way.

If you've got a many-to-many relationship, then having a table such as
this is the way to do it:

beach 1	condo 4
Beach 1	condo 5
beach 2	condo 12
beach 2	condo 17
beach 3	condo 7

However, if the names are unique enough, I'd suggest not using the IDs,
but the names of the condos and beaches instead. That way you cut down
on the traffic going to the db. In this above table, you'd have to make
your SQL call to get the beaches within walking distance, then you'd
have to make more SQL calls to get the names of the beaches and the
condos based on the ID numbers the first call returned. That can get a
bit slow depending on your DBMS, server setup, and the algorithm used.

HTH,

-Ken


> Is that the best way?




More information about the thelist mailing list