I can make the timestamp just an INDEX of course which will stop the 'duplicate' problem.
No, no auto_increment on this table, it's not appropriate in this situation.
I need to order by date entered and the primary key
id INT NOT BULL,
auth INT NOT NULL,
date TIMESTAMP NOT NULL,
text TEXT NOT NULL
PRIMARY KEY(id)
is what I have now...
Nick
A TIMESTAMP column is useful for recording the date and time of an INSERT or UPDATE operation because it is automatically set to the date and time of the most recent operation if you don't give it a value yourself.
The way to have a timestamp for created/inserted is to have two cols. The first one is created and the second one is last modified. If I remember correctly mysql only updates the second timestamp column on update.
So, what do you think about making it an index in the above situation Jatar?
Is it over kill? - I'd typically have to get all entries with id=n order by date
Unless you tell me something I've not thought of I think i'll actually leave it, I can always add one and benchmark it later I guess...
Thanks!
Nick
If I remember correctly mysql only updates the second timestamp column on update.
I believe it's only the first timestamp that will be updated ;)
http://www.mysql.com/doc/en/DATETIME.html
If you have multiple TIMESTAMP columns, only the first one is updated automatically.
And Nick, "NOT BULL"? ...is that a way of filtering junk from the database? ;)