data integrity

From: Jelle Ouwerkerk <jelle(at)openface(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: data integrity
Date: 2001-11-05 21:06:06
Message-ID: Pine.NEB.4.10.10111051540400.8225-100000@abnormal.openface.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi

I'm using postgresql to manage a web site.

Problem: How are people dealing with data integrity issues such as stale
data when writing web-based apps? For instance:

The value of X is 7.

Step (1) User A selects X.
Step (2) User B selects X.
Step (3) User A updates X to 8.
Step (4) User B updates X to 10 under the assumption that X is still 7.

In some scenarios, user B should be prevented from updating.

Solutions (that I'm considering):

(1) Timestamp: Have a timestamp for every row in every table, which
automatically changes when a row is inserted or updated, or

(2) Cache: Similarly, cache the user's selected data on the server side
(every tuple from the original select) and compare when the user attempts
to update, or

(3) Squash: modify only those fields in the row that need updating
(instead of the entire row) and whatever happens happens.

Has anyone solved this 'stale data' problem before?

Does this fall into a family of problems that has an existing (trivial)
solution? Also, is it the responsibility of the application server to deal
with the scenario above or should the application itself be responsible?

Thanks in advance

...Jelle

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Crucius, Wesley 2001-11-05 21:51:57 database crash?
Previous Message Tom Lane 2001-11-05 20:33:03 Re: Daylight Savings Time