List:General Discussion« Previous MessageNext Message »
From:Thimble Smith Date:July 22 1999 8:40pm
Subject:Re: auto_increment question
View as plain text  
At 16:12, 19990722, Denis Voitenko wrote:
>id int(2) auto_increment
>who varchar(8)
>message varchar(255)
>
>I want to keep only 25 records in the table all the time

If you're just keeping the id in order to know which rows to
keep, then it's not an id, it's a "position" or "relevance".
Instead of using an auto_increment key, you'd be better off
using a timestamp.  Then it's simple to keep only the most
recent 25.

If, on the other hand, you're using the id as an id, then you
definitely DON'T want the behaviour you're requesting.  After
you delete some messages and "rearrange" your ids, then you've
lost all the information that the ID held.  That is, if you have
another table that references your Messages table by the id, then
once you rearrange ids, those references are bad.

Either way, I think your design is broken in a fundamental way.  If
you need more help, give us the complete picture of what you're
trying to do.

Tim
Thread
auto_increment questionDenis Voitenko22 Jul
  • Re: auto_increment questionNem W Schlecht22 Jul
    • Re: auto_increment questionDenis Voitenko23 Jul
      • Re: auto_increment questionThimble Smith23 Jul
    • Re: auto_increment questionDenis Voitenko23 Jul
      • Re: auto_increment questionThimble Smith23 Jul
      • Re: auto_increment questionBill Gerrard23 Jul
        • timestamp (before: auto_increment question)Denis Voitenko23 Jul
          • Re: timestamp (before: auto_increment question)Thimble Smith23 Jul
          • Re: timestamp (before: auto_increment question)Paul DuBois23 Jul
  • Re: auto_increment questionPaul DuBois22 Jul