There is one primary key in a TABLE but the key may be made from more than one column. When multiple columns are used it is called a COMPOSITE primary key.
No matter what , a primary key can not be a NULL and must be unique within the table. For a single column primary key a simple auto number will do which results in sequential ID numbers each identifying a single record.
A composite primary key must be unique when all key columns are taken into consideration, In any single column which forms part of the composite primary key you may have duplicate non Null info. An example of a composite key would be a system which uses the current date and a sequential number which is always reset to 1 at the beginning of each day.
4/15/07 1
4/15/07 2
4/15/07 3
4/16/07 1
4/16/07 2
4/16/07 3
As you can see each column has data which is repeated but taken together they form unique row identifiers. Composite keys allow you to create a table of data which self groups/sorts the table without having to run a query..
2007-04-19 15:18:33
·
answer #1
·
answered by MarkG 7
·
0⤊
0⤋
The answer may be different depending on the Database System you are currently working with. As far as database theory goes it is possible to have two primary keys. For example a table describing a wedding of two persons may use both of the person's names and the date (In case they re-marry) and have additional columns to describe other aspects of the event. The actual implementation may be different depending on the database however in access you would select both columns you want to set as the Primary Key at the same time and designate them rather than doing one at a time.
2007-04-19 08:42:24
·
answer #2
·
answered by CatsCradle 3
·
0⤊
0⤋
I'm doing a uni course at the mo and we've just done databasing.
I don't believe it is possible to have two primary keys
2007-04-19 07:18:49
·
answer #3
·
answered by Anonymous
·
0⤊
1⤋
no. if it did they wouldn't be called primary. primary key is the identifying column(s) that would make each record in the table unique. hope this helps.
2007-04-19 07:20:09
·
answer #4
·
answered by betafish 2
·
0⤊
1⤋
Yes, but it's not recommended, as it actually can slow down your queries rather than speed them up....
2007-04-19 07:15:52
·
answer #5
·
answered by davidinark 5
·
0⤊
0⤋