MySQL table structure, do I need a primary key? -


i'm creating table in mysql using innodb. table contain measurements several locations. data should stored is:

  • monitor_id - id of monitor (indexed)
  • time - time of measurement, resolution in seconds (indexed)
  • value - current value

in time, there might many million new rows every day.

my questions are:

  1. do need primary key? sake of application don't need pk, database might? if so, bad idea use bigint?

  2. is bad idea store time mysql datetime? or should use integer store unix_timestamp? matter in long run? column indexed.

  1. yep. better have id pk. autoincrement (bigint ok)
  2. int better highload. less data store (& index) more logic in app (not in queries).

Comments