Options

Primary and seconary keys

randrewsrandrews Member Posts: 135
I have a table Value Entry with primary key "Entry No."
I want to sort table by "Posting Date", "Item No.","Entry No."
But adding key "Entry No." in secondary key is impossible (primary is in secondary automaticaly).
So question:
Sorting by key "Posting Date", "Item No." will sort by "Posting Date", then by "Item No." and then by primary key? Or it will not be sorted by primary key?

Comments

  • DenSterDenSter Member Posts: 8,307
    Whenever you create a new key, Navision adds the primary key fields to the end of it.

    So to answer your question: yes :D
  • randrewsrandrews Member Posts: 135
    Thanks.
    I thought so, but to insure.. :)


    Thanks.
  • eromeineromein Member Posts: 589
    Every record in Navision should be (needs to be) unique. So even if you are using a sec. key, Navision puts the prim. key at the end to handle the records.

    So again, yes... :wink:
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
  • RobertMoRobertMo Member Posts: 484
    To be exact, when creating secondary key, Navision adds the fields that are part of primary key at the end, which you haven't added them manually, of course in the same order they are in Primary Key.
    For example a Sales Line table, where Primary Key is
    Document Type,Document No.,Line No.
    
    And you add a secondary key:
    Document No.,Type,No.
    
    this key is acctually extended to:
    Document No.,Type,No.,Document Type,Line No.
    
    That's how the secondary keys (indexes) are kept unique.
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • DenSterDenSter Member Posts: 8,307
    So now you have three versions of the same answer :)
Sign In or Register to comment.