Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    76

    Unanswered: sales transaction table design

    Can't remember which is the best way....

    Does transaction table have a PK?!

    table details:
    order_no - fk (from orders table)
    company - fk (from orders table)
    product fk (from stock table)
    whse fk (from stock table)
    qty
    price


    should i have a unique_no column so that there is a pk?!

    Thanks!

  2. #2
    Join Date
    Dec 2005
    Location
    Tilburg, Netherlands
    Posts
    73
    Yes, or declare a PK using a combination from the current fields ... but given the circomstances that doesn't seem like a good option.

    If you want to guarantee that you can pinpoint a certain record in the table you need a PK. Otherwise (without a PK) there is no technical guarantee. Maybe a functional guarantee, but specs change during a period of time.

    Gr,
    Yveau

    > SELECT * FROM users WHERE clue > 0;
    Empty set (0.00 sec)


  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    i would say no, do not create a surrogate key for the primary key kere

    make the primary key the combination of the 4 foreign keys, as it confers the uniqueness that you want

    a surrogate key would be better if this table were to have child tables -- but really, there's no chance of that in this particular scenario
    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
  •