SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member josephman1988's Avatar
    Join Date
    Mar 2005
    0 Post(s)
    0 Thread(s)

    Advice on lookup tables and inconstancy

    Hey guys,

    Simple question really, I've googled it but couldn't get a straight answer.
    Basically I wanna know, what are the advantages and disadvantages of having a lookup table for .. pretty much any tables, because I want to keep my tables consistent.

    I have a news table, then i have a games table, then I have a category table.
    I have a lookup table that puts the news article into a 'game' and a 'category'.
    Without even thinking about it, I added comments to be allowed on each article and made a table 'news_comments' with a 'news_Id) foreign key in it, rather then having a seperate lookup table to join the 2, but after thought, its mixed up now isn't it, lookup tables for some tables, and foreign keys on the actual data row.

    What's your preference, am I being too much of a perfectionist, and over complicating things?

    Thanks in advanced for any input!
    "Ah the USB, the only rectangular device
    that requires 3 attempts to get right."

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Toronto, Canada
    63 Post(s)
    3 Thread(s)
    sorry, i kinda got lost in your explanation

    i think what you mean by lookup table is what i would call a relationship table -- for instance a table which has news_id,game_id,category_id will relate a news article to a game and a category, so if a news article belongs to more than one game in the same category, you simply add additional "lookup" rows

    this is fine

    then you talk about the news_comments table, which simply refers each comment to the news article it belongs to

    that's fine too, because it's not a many-to-many relationship, you don't need to structure it so that the same comment can be applied to multiple news articles | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Posting Permissions

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