Re: How to properly implement counter?

2011-02-10 Thread Paul Bagwell
Imageboard: - When user creates new post, its counter is computed by (section_biggest + 1). - When user deletes a post, nothing happens to section counter: Post [id:55, pid:1] created Post [id:71, pid:2] created Post [id:71, pid:2] deleted Post [id:89, pid:3] created - Has separate counters for ea

Re: How to properly implement counter?

2011-02-10 Thread Paul Bagwell
Model I've described is just an example. In the real world, I'm developing imageboard (chan). This is anonymous forum with sections. Each section needs to have its own post counter. It is very typical for all modern chans (wakaba, kusaba etc.). Wakaba just creates separate table for each section,

How to properly implement counter?

2011-02-10 Thread Paul Bagwell
I got models: - Post (id, thread_id, text, pid) - Thread (id, name, last_pid) PID is the number of post in thread. So it needs to be unique to each thread. Like: Thread 1 : [1, 2, 3, 4, 5] Thread 2 : [1, 2, 3, 4, 5, 6, 7] And the "last_pid" field of thread is cache of pid of last post in post_se