At 16:51, 19990722, Denis Voitenko wrote:
>Gee. I haven't started and the idea was proclaimed dead before it arrived
>:-) What is wrong with my design? I basically need to keen the following
>who varchar(8) <- person
>said varchar(255) <- what the person said
>but I want to be able to list the thread in two way:
>1. new messages on top
>2. new messages on bottom
>and that's why I decided to create an id fied that would have numbers 1-25
>so I could order them in decreasing or increasing order.
>What is wrong with that? I am really interested in what you've got to say.
Well, I think the problem is pointed out by your original request - to
keep all of the ids in the range 1 to 25. That's not how standard
relational databases work. It's better to work with the system, than
try to force the system to act a certain way.
What you really want to encode is the ordering of the messages (when
they were written, relative to each other). A timestamp is ideal for
this: its value is automatic, just like an auto_increment key, and
the values will always be appropriate.
Another benefit of using a timestamp is that, say you change your mind
and you want to keep all messages that are less than a week old, instead
of only keeping 25. It's no trouble to do that if you're using a
timestamp. It's impossible if you're not keeping that information.
For your simple application, a single table with three fields will be
fine. If later on you want to do something more complicated, you
might be interested in using several tables. Then an ID field will
become important. But, at that point, you'll need to be doing some
major changes anyway, so you're not hurt if you don't have one now.