How to get notified of changes on a read only table? (I.e., Price drop notifications.)
Posted
by
mirthlab
on Stack Overflow
See other posts from Stack Overflow
or by mirthlab
Published on 2010-12-26T22:54:46Z
Indexed on
2010/12/26
23:54 UTC
Read the original article
Hit count: 189
Let's say I have these tables/models:
Product
- id
- last_updated_date
- name
- price
User
- id
- name
Wishlist
- id
- user_id
- product_id
The Product table has a few million records and is being updated automatically each night via a data import (inserting into a new table, dropping the old one). I basically have read-only access to that table/model.
If a product is on a user's wishlist and the price drops, I'd like to be able to notify that user. What methods can be used to do this?
I have a couple of ideas:
Keep track of the Product.last_updated_date in the wishlist model and periodically poll the product table to see if it has been updated. This sounds like a horrible/non-scaleable solution.
Some sort of Postgres View or Function that triggers when the Product table is updated? I'm new to postgres so I'm not yet sure if this is even possible.
Something amazing that you will suggest that I haven't thought of :)
Any help in the right direction is greatly appreciated!
© Stack Overflow or respective owner