OT: making queues in DB

M

Mitja

I just posted a more theoretical question here, and since this is of more
practical nature, I decided to make a new post. It doesn't have much to do
with Python, it's just a thing I came across when making a CGI-driven
webpage.

I have a games page, on which I would like to display a list of 10 last
downloaded games. Therefore, I'd need a kind of queue in the database. What
is the best way to go about this? Extending each game's entry with a
"timelastdownloaded"-like column is of course an option, but I don't favor
it too much.
 
B

Brian Kelley

Mitja said:
I have a games page, on which I would like to display a list of 10 last
downloaded games. Therefore, I'd need a kind of queue in the database. What
is the best way to go about this? Extending each game's entry with a
"timelastdownloaded"-like column is of course an option, but I don't favor
it too much.

Why not? This seems to be the most reasonable solution, then your sql
statement to the database would be something like:

SELECT * from gametable
ORDER BY timelastdownloaded DESC
limit 10

The order by is a descending order from the current date to the last
date, and the limit 10 gets the last 10.

If you are worried about performance you can modify the select to return
only the games downloaded from the last month or so. Or if the table
gets too large, just delete the earliest entries.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top