db design from matrix-table

  • Hello,

    I need some designhelp with table/tables.

    I have an excel matrix as the picture. rows are km, and columns are distance. fields are prices.

    Indata from user is km and distance. How can i return price to user? Not sure how to design table/s

  • CREATE TABLE tbl (km INT NOT NULL, distance INT NOT NULL, price INT NOT NULL, PRIMARY KEY (km,distance));

  • ok thats one way of doing it 🙂

  • Thats probably the best way to do it. Except that I'd make "Distance" a range, that is, two int columns: MinDistance, MaxDistance. (change it in the PK too).

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply