Secondary Keys Question

infonote
Member Posts: 233
Hi,
I have been reading posts for a while but never posted.
I have just started going over C/SIDE dev I chapters and have a newbie question regarding Secondary keys.
Are the Secondary keys in Navision unique?
E.g. primary key is Serial No which is obviously unique.
Must the secondary key also be unique?
Thanks in advance.
I have been reading posts for a while but never posted.
I have just started going over C/SIDE dev I chapters and have a newbie question regarding Secondary keys.
Are the Secondary keys in Navision unique?
E.g. primary key is Serial No which is obviously unique.
Must the secondary key also be unique?
Thanks in advance.
Blog: http://www.kaizenlog.com
0
Comments
-
Belias wrote:Secondary keys are generally crated for ordering, grouping and performance purposes, so secondary keys mustn't be uniques...(they CAN be by the way)...
Thanks.Blog: http://www.kaizenlog.com0 -
Navision always adds primary key at the end of all secondary keys.0
-
lubost wrote:Navision always adds primary key at the end of all secondary keys.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
infonote wrote:Are the Secondary keys in Navision unique?
No because the doesn't not have a property to make the key unique. So even if you wanted to make a secondary key unique, you would not be able to do it.
Yes because NAV internally makes sure that all primary key fields are also included. So looking at the Sales Header table, which has DocType and DocNo as the primary key, when you add a key for SelltoCustomer, inside the object NAV will add both primary key fields to the key. You don't see this in the actual key design, but it is done behind the scenes. It is still technically not a unique key constraint though, because you can have the same combination of secondary key field combination more than once in the table.
On SQL Server, you can see this clearly by looking at the indexes. You'll see the primary key fields added to the corresponding index, and the index is defined to be a unique index. Now when you define the index that you want SQL Server to use in the SQLIndex property, then NAV does NOT add the primary key fields to the index, and the Unique constraint is not set.0 -
DenSter wrote:Now when you define the index that you want SQL Server to use in the SQLIndex property, then NAV does NOT add the primary key fields to the index, and the Unique constraint is not set.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Then that part gets hidden somehow, because I don't believe you can see those fields in the index designer (I'd have to verify that though). I'm pretty sure if you specifically set the SQLIndex without any/all of the primary key fields, it gets created into a non-unique index on SQL Server. If you leave the SQLIndex blank, the key gets created as a unique index, and THEN SQL Server adds the primary key fields to the index.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions