Subject | Re: transactions and timestamps |
---|---|
Author | Adam |
Post date | 2005-08-01T23:22:34Z |
Lutz,
The main problem is your approach will not work in a simultaneous
transaction environment.
We have a similar task where the database needs to alert offsite
nodes of changes made. I will show you an example of how we would do
it to a customer table
Customer
(
ID,
Name,
etc
)
Then create a CustomerChanged table. Every device is assigned a
unique number (and this is enforced via MAC address matching)
CustomerChanged
(
DeviceID,
CustomerID
)
You then put triggers on the insert / update of the Customer table,
and if the fields of interest have been changed, then a record is
inserted into the CustomerChanged table for every device that needs
to know about that customer.
When the offsite device phones home, It collects the CustomerIDs of
interest and re-queries those customers. Not a total replication
solution, but certainly does the job here.
Just be warned that if you use delete triggers that insert that
customerid, you will not be allowed to delete a record because it
would violate the foreign key constraint. We would never delete such
information anyway, it would be instead allocated an end date.
Adam
The main problem is your approach will not work in a simultaneous
transaction environment.
We have a similar task where the database needs to alert offsite
nodes of changes made. I will show you an example of how we would do
it to a customer table
Customer
(
ID,
Name,
etc
)
Then create a CustomerChanged table. Every device is assigned a
unique number (and this is enforced via MAC address matching)
CustomerChanged
(
DeviceID,
CustomerID
)
You then put triggers on the insert / update of the Customer table,
and if the fields of interest have been changed, then a record is
inserted into the CustomerChanged table for every device that needs
to know about that customer.
When the offsite device phones home, It collects the CustomerIDs of
interest and re-queries those customers. Not a total replication
solution, but certainly does the job here.
Just be warned that if you use delete triggers that insert that
customerid, you will not be allowed to delete a record because it
would violate the foreign key constraint. We would never delete such
information anyway, it would be instead allocated an end date.
Adam