SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    using a joining table vs a straight index on a column?

    Is there a guideline for when one is more appropriate/efficient when designing your schema? In my example, I have a forum with threads organized by category. I have a threads table which contains a category ID. I need to be able to select all threads, threads from a set of category IDs, and threads from a single category ID.

    Does it matter if I have a threads table with an index on the column cat_id, or if I use a joining table called thread_categories with two columns thread_id, cat_id?

    Thanks.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    You'd need a thread_categories table if a thread can belong to more than one category.
    There's absolutely no need to create such a table to speed up a selection of threads by one or more categories.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2008
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    makes sense, thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •