0

I have a table in my database that consists of two foreign keys, which together are still not unique, but adding a time/date to them would make them unique. Is it a good idea to use those three columns together as the primary key or should I just create a new column and use a separate primary key?

user4181107
  • 321
  • 2
  • 17

2 Answers2

1

Adding a timestamp to artificially create a composite primary key from other 2 columns is not a good idea IMO because you can have HW fast enough to generate two identical composite keys in your database.

Instead, you may check your database for a surrogate key generator (usually some sort of sequence) in this case.

Leo
  • 6,480
  • 4
  • 37
  • 52
0

NO: adding a `time based value to build a primary key can not valid as you can understand from here.

It is better to create a primary key of its own to your table.

Community
  • 1
  • 1