Suppose I have an application A with a database. Now I want to add another application B, which should track the changes in the database of application A. Application B should do some calculations when the data has been changed. There is no direct connection between both applications. Both can only see the database.
The main problem: some data changes in the database. How can I run some C # code to make these changes?
To give some incentive for answers, I mention some approaches that I am currently considering:
- Make a request B to poll changes in interest tables. Advantage: simple approach. Disadvantage: a lot of traffic, especially when many tables are involved.
- Enter triggers that will fire on specific events. When they shoot they should write some entry in the "event table". Only Appendix B needs to poll this "event table". Advantage: less traffic. Disadvantage: the logic is placed in the database as triggers. (This is not a question of the “viciousness” of triggers. Its design is a question that makes it a Flaw.)
- Get rid of the polling approach and use the SqlDependency class to receive notification of changes. Advantage: (Maybe?) Less traffic than a polling approach. Disadvantage: no database independent. (I know OracleDependency in ODP.NET, but what about other databases?)
Which approach is more favorable? Maybe I missed an advantage in these approaches? Perhaps there are some other approaches that I don't think about?
Edit 1: Database independence is a factor for ... call them ... "sales people." I can use SqlDependency or OracleDependency. For DB2 or other databases, I can return to the polling method. It is simply a matter of value and benefit, which I want to at least think about, so I can discuss it.
Theo lendndff
source share