Data Base Auto-Update

What I want is simple to explain. 
Imagine that I have a database for "Classes". This "Classes" requires "Material". "Classes" have "beginTime" and "endtime", so while the "Classes" are running some "Material" abre being used. I want to change the state of this "Material" to available, when the class ends. But this process should be done automatically in the backend. How can I do this? Is it possible to build some kind of "screen action" to do that?
Use a timer, run it ever 15 minutes, or whatever, query for ended classed and do whatever you need to do.