What is the best way to handle database table ids, if entries of that table are expected to be created and deleted frequently? Basically, most entries are temporary over a timespan of a few days. However, entries might stay in the table for an arbitrary amount of time as well.
Using an integer or long id with Auto Increment might be problematic after a certain time, when the maximum key value is reached. Considering a large user base, where most users will probably create a dozen or more entries each day, this might happen sooner than expected...
Therefore the question. Is there some mechanism with MySQL or another database to get looping ids or any other solution to handle this problem with good performance?
Btw. this is in context of a Ruby on Rails application. I was thinking about having nested ids, i.e. make an entry unique on user_id and user_entry_id. But I don't know, how well this approach is supported by rails.
Edit: I see I should have done some calculation on how likely it is that the id range will run out anytime soon. I guess I don't have to worry about that problem anytime soon. Still happy, if people can report some experiences related to that problems. If anybody ever had problems with that....