>
> Hi.
> What is the better way to store the last record for a translation???
> I.E:
> The data for the last product vendding.
> What is better:
> a) Create a field in "product" table and create a Trigger
> (before insert or update into vendding table) to alter this field.
> b) Create a view or function that check the all venddings
> (in vendding table) for the specified product and return the
> last vendding information?
>
You could also use "computed field" approach described here (see Tip):
http://www.postgresql.org/docs/8.0/interactive/xfunc-sql.html#AEN29483
This allows you to do just what seems simpler and change later on.
No need to touch any other SQL code.
Keep in mind that when using triggers, every update generates a dead
tuple
both in products table and in all indexes. You need to VACUUM and
REINDEX
regularly. Been there, done that.
Tambet