Recommendation about the implementation of a voting process

Поиск
Список
Период
Сортировка
От JORGE MALDONADO
Тема Recommendation about the implementation of a voting process
Дата
Msg-id CAAY=A79aTSyxz7HoNkj0UADD=5ODnCyhstnV12dUe-++D9SRzg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Recommendation about the implementation of a voting process  (amul sul <sul_amul@yahoo.co.in>)
Список pgsql-novice
Hi,

We have an information system for the World Wide Web already running and we need to include a new functionality which should allow users to vote for certain events. This means that users will be able to (for example) click a button to vote. 

This might imply 2 things:
(1) The insertion of a record to a DB table containing data like the event ID the user is voting, the username and timestamp.
(2) Update a counter for the event the user is voting each time a user votes (each event would have its own counter).

Our main concern is how to implement the process of showing the events information in real time. We need to display the events in descending order, showing those with more votes first.

We see at least 2 options to achieve this goal: 
(a) To use a SELECT statement with COUNT and GROUP BY.
(b) To display the counter that I mentioned in point (2) above.

How reliable it is to use a counter? Is there any risk that the PostgreSQL DB does not update such a counter?

I know that using option (a) will provide the correct results without any doubt, but it also means more process for the DB.

What do you recommend?

Respectfully,
Jorge Maldonado

В списке pgsql-novice по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: numeric data type upper limit.
Следующее
От: amul sul
Дата:
Сообщение: Re: Recommendation about the implementation of a voting process