Results 1 to 6 of 6

Thread: Status tables

  1. #1
    Join Date
    Mar 2008
    Posts
    2

    Unanswered: Status tables

    Hi

    My boss and I have recently started designing a new database, and we've got into a bit of a debate about creating status tables (e.g. order statuses).

    It was my intial instinct to create a separate table for each kind of status (e.g. an OrderStatuses table, a JobStatuses table, etc), however my boss wanted to create one table containing all the statuses, with an extra field for defining what kind of status it is.

    I was just wondering what others thought was the best approach.

    Thanks
    Tom

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    If you create a single table, I don't see a way to setup a decent foreign key constraint between the main entity and the status entity. So it would be possible to insert a Job referencing an OrderStatus.

  3. #3
    Join Date
    Mar 2008
    Posts
    2
    Thanks for the reply, shammat.

    I agree, there would be no constraint there. However, I did just find an article that discusses this, and shows a way of enforcing integrity using a UDF, although I'm not sure I'd want to implement it, as I might occasionally forget to add the constraint. (the article is here: http://www.sqlservercentral.com/arti...server2/1670/).

    I think I've won the argument though.

    Tom

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by tjings
    I think I've won the argument though.

    Tom
    Good. Let us know if rank gets pulled. Slippery slope this.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    I have performance problem related to a "one true status table" design sitting in my inbox right now.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    "one true lookup table" = OTLT

    google for more info and horror stories
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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