How to update multiple data in different places (table) about record change?

This is not the meta question. I am using SO just as an example.

In StackoverFlow, every answer, every comment, every question, every vote has an effect that creates an icon at a specific point in time. I mean after every action the list of requests is checked.

eg. If Mr. A. voted Mr. B. Answer. So we have to check if this answer answers the Question Answer 100 times, so give the "Mr. B" badge the familiar side, whether Mr. A was added the 100th time to give him the badge.

This means that at least 100 requests / IfElse must be run for each action.

Now my real life example is an application where I get online data from the attendance machine. When the user shows his card to the car. I get this and save it as a record. Now, based on this post, I have several calculations. He is late. He is 3 days late. Is he in the right shift (Day shift / Night shift). It is a holiday today. Is this overtime. Is it early ....... etc. Etc. Etc.

What is the best strategy for this kind of requirement.

Update: Can the SO team guide us on this?

+2


source to share


4 answers


You are using queues and workflows. Thus, you disconnect the moment of updating from the actual notifications, allowing the system to scale. Tense, triggered or similar solutions cannot scale as each update has to wait for all stakeholders to respond to the notification. The design of the processing engine using workflows makes it easy to add steps and notify consumers by modifying data without changing the schema.



For example, see how MSDN uses queues to handle similar issues with MSDN content: Building an MSDN Aggregation System .

+3


source


Could you just use "flags" (other tables, other columns, whatever) to indicate when these special cases occur? This way you will only need one search (in each case) than a ton of searches and / or joins. You can record changes (third day, etc.) Paste.



0


source


Also, what to check depends on the threshold.

eg. Has the person been absent in the last 3 days? This check is only required when the person has been absent for 2 days.

I mean - you don't have to check everything every time.
Also, how much information needs to be updated immediately? SO doesn't update things in real time.

0


source


Maybe you should use two databases with online replication between them - one to get real-time data and nothing else, and second, you can use hard computations (for example, calculate all latinas every 10 minutes or on demand). Find these databases on different servers.

0


source







All Articles