0

This is how I have designed:

visitorID
visitedprofileID
datetime

Is it a good idea to add an ID (primary key) to the table, I mean recordID (primary key).

(MySQL with PHP)

Derek Downey
  • 23,568
  • 11
  • 79
  • 104
ilhan
  • 3,039
  • 5
  • 21
  • 13

1 Answers1

1

I think your two choices here are:

  1. make the (visitorID,visitedprofileID) combination a primary key

  2. add a recordID as primary key

If the table is InnoDB (or it will be in the future for Foreign Key usage), I would go with the second option. Given the way InnoDB handles indexing by adding the primary key to secondary indexes for lookup, if you ever wanted to add an index on datetime, the single field would result in a smaller index.

Derek Downey
  • 23,568
  • 11
  • 79
  • 104