Thread: user get notification when postgresql database updated
I am using javaScript app and PostgreSQL database. I have car_alert as a table contains id (FK of cars table) and userid (FK of users table) each car has a status ( status column in cars table ). car_alert is updating and having new records (car id and userid ) every time user choose car to be alerted about. my database information is updating every 10 min and the user should get notification message every time status for its car is changed. ( of course every user has choosed his interested cars and inserted them to the car_alert table by car id ) . what is the best method to do that ? -- View this message in context: http://postgresql.1045698.n5.nabble.com/user-get-notification-when-postgresql-database-updated-tp5600187p5600187.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On 28/03/12 12:40, Albert wrote: > I am using javaScript app and PostgreSQL database. I have car_alert as a > table contains id (FK of cars table) and userid (FK of users table) > each car has a status ( status column in cars table ). > > car_alert is updating and having new records (car id and userid ) every time > user choose car to be alerted about. > > my database information is updating every 10 min and the user should get > notification message every time status for its car is changed. ( of course > every user has choosed his interested cars and inserted them to the > car_alert table by car id ) . > > what is the best method to do that ? > Depends on what you mean by "javaScript app" in this context - browser-based or standalone? If the latter, the NOTIFY/LISTEN mechanism may help, see http://www.postgresql.org/docs/9.1/static/sql-notify.html, and if it's in the browser, might as well just poll the server every 10 minutes, that's unlikely to put much load on the server or network and there's not much point doing it more often if the updates only happen every 10 minutes anyway. cheers, Tom
Thanks for your response! it a browser based application. so would you advice me about the best way to poll the database for notifications ? I've been read about DB triggers but still can't tell if it will help me. -- View this message in context: http://postgresql.1045698.n5.nabble.com/user-get-notification-when-postgresql-database-updated-tp5600187p5603197.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
another Q : my app should display notifications to each user depends on his selected cars. can i do that just using ajax and php ? -- View this message in context: http://postgresql.1045698.n5.nabble.com/user-get-notification-when-postgresql-database-updated-tp5600187p5606001.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
On 29 Mar 2012, at 11:43, Albert wrote: > it a browser based application. so would you advice me about the best way to > poll the database for notifications ? > > I've been read about DB triggers but still can't tell if it will help me. The HTTP protocol doesn't have a push mechanism, so you can't notify your browser-based application from your server. Youwill have to poll. Googling for "ajax push" turned up this explanation: http://www.subbu.org/blog/2006/04/dissecting-ajax-server-push Alban Hertroys -- The scale of a problem often equals the size of an ego.