How could I have a trigger that updates a certain field when the system reaches a certain date ?
i.e.
+---------------------+ +-------------+
| Trains | | Trips |
+---------------------+ +-------------+
| id | | id |
| distanceTraveled | | endDate |
| | | trainUsed |
| | | distance |
+---------------------+ +-------------+
Trains :
- train1, 0
- train2, 0
- train3, 0
- train4, 0
Trips :
- 1, 12:00:00 tomorrow, train1, 10
- 2, 14:45:00 tomorrow, train3 ,20
- 3, 02:15:00 after-tomorow ,train1, 15
Execution :
- At 12:00:00 tomorrow, update the table train so the distanceTraveled field for train1 comes to 10
- At 14:45:00 tomorrow, update the table train so the distanceTraveled field for train3 comes to 20
- At 02:15:00 the day after-tomorrow, update the table train so the distanceTraveled field for train1 comes to 25
Final result in 2 days would be
Trains :
- train1, 25
- train2, 0
- train3, 20
- train4, 0