SQLTeam.com | Weblogs | Forums

Composite Primary Key- Can someone elaborate or explain?


#1

Hello all!

I am new here, but also learning SQL right now. I was reading in my book reviewing for a quiz over book terms, but I noticed a term referred to as a composite primary key. I know the what, but why is it called a composite primary key?

My book says a composite primary key has "two or more columns"... If the number of columns were "composite" wouldn't the number 2 not be even in the picture here? Wouldn't the number of columns only be composite numbers?
I guess I am trying to understand why it's called that. Is this term just one of those "because that's how it is", or is there meaning or a story behind this one?


#2

To me a composite primary key has more than one column. That's it.

I might have InvoiceID which is unique, that's a one-part PKey on my InvoiceHeader table.

But my InvoiceItems table has the InvoiceID, which JOINs to the InvoiceHeader, but also an Item column, and to uniquely reference a row in InvoiceItem table I need InvoiceID, Item - that's a composite, or multi-part, key.