Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is how I have designed:


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

(MySQL with PHP)

share|improve this question
Is date type datetime? – Jack Douglas Sep 28 '11 at 12:04
@JackDouglas, yes, it is datetime – ilhan Sep 28 '11 at 12:07
You might be interested in this thread:… – Derek Downey Sep 28 '11 at 12:32

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.

share|improve this answer
+1 for InnoDB info and smaller index observation. BTW Option 1 would be great for MyISAM since you could auto_increment visitorID sequentially within visitedprofileID. – RolandoMySQLDBA Sep 28 '11 at 14:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.