I have a table
Invoice(PosId,InvoiceId,Name,...)
with PK: (PosId, InvoiceId)
and a detail table
InvoiceEntry(PosId, InvoiceId, EntryId, Product, Price)
- The cardinality of
PosId
is 10 range: [1...10] - The cardinality of
InvoiceId
is 1,000,000 range [1...999999]
When doing joins both PosId
and InvoiceId
are always used. (There is no usecase where someone would use only one of the two columns when querying)
Does the cardinality of each column play a role on which one of the two I should pick as the first column of the primary key?