Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,057
    Thanks
    25
    Thanked 0 Times in 0 Posts

    Is a Sort Column okay?

    I just finished adding Section, Dimension, and SubSection columns to my database.

    When I start joining the tables in various ways, I am not getting things in the order I want.

    Would it be okay to add a column called "sort" and manually assign a "Sort Order #" so I have something on which to run my ORDER BY against?

    For example, I want things in this order...
    Code:
    Featured Finance
    Business Structure
    Store Type
    Offering
    Accounting

    Also, if it is okay to do this for one table, would it be a major deal to do it on several tables, e.g. my Section, Dimension, and SubSection tables?

    Sincerely,


    Debbie

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,155
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    Sure. I do this all the time.

    But take a hint from the olden days of when BASIC had line numbers and most people numbered their lines in increments of 10 ( 10, 20, 30, ... ).

    Do that with your ordering column.

    Now, if you change your mind about one number, you don't have to shuffle all the numbers around.

    Say you had, indeed,
    10
    20
    30
    40
    and you decided the 30 really should be before 20. So just change 30 to 15.
    10
    15
    20
    40
    Presto.

    (Heck, I can remember numbering by 100 on occasion.)
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,057
    Thanks
    25
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    Sure. I do this all the time.
    That's good, because while I love my new Data Model, I found out pretty quickly last night that my "Natural Keys" in the junction tables were very short lived as far as simplifying my queries...


    But take a hint from the olden days of when BASIC had line numbers and most people numbered their lines in increments of 10 ( 10, 20, 30, ... ).

    Do that with your ordering column.

    Now, if you change your mind about one number, you don't have to shuffle all the numbers around.

    Say you had, indeed,
    10
    20
    30
    40
    and you decided the 30 really should be before 20. So just change 30 to 15.
    10
    15
    20
    40
    Presto.

    (Heck, I can remember numbering by 100 on occasion.)
    Thanks for the tip!

    Sincerely,


    Debbie


  •  

    Posting Permissions

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