Reputation: 89
I'm creating a table in MySQL using Innodb. The table will contain measurements from several locations. Roughly the data that should be stored is:
In time, there might be many million new rows every day.
My questions are:
Do I need a Primary Key? For the sake of my application I don't need a PK, but the database might? If so, is it a bad idea to use BigInt?
Is it a bad idea to store the time as a MySQL DateTime? Or should I use a integer to store a unix_timestamp? Does it really matter in the long run? This column will be indexed.
Upvotes: 0
Views: 236
Reputation: 31
As a beginner my solution would be to use a combination of the existing columns as a primary key. So long as you use enough columns which varies enough that every row becomes unique.
In this case you might need all 3 columns to be used as primary identifiers in order for it to work out. But it would save you from having to create an entire column just for the sake of a primary since you seemed worried about space.
Upvotes: 1
Reputation: 3072
Doc Says
The primary key for a table represents the column or set of columns that you use in your most vital queries. It has an associated index, for fast query performance. Query performance benefits from the NOT NULL optimization, because it cannot include any NULL values. With the InnoDB storage engine, the table data is physically organized to do ultra-fast lookups and sorts based on the primary key column or columns.
Upvotes: 1
Reputation: 3784
Upvotes: 1