What are the benefits of performing some functions or operations in the database compared to doing them in the some other programming language?
For example, let's assume there is a mysql database school
with table students
. Then the students
table has the following attributes (id
, name
, age
, dob
...): will it be better to do like the age
calculation in the database by subtracting the dob
from the current date and then storing it in age
column for all students? Or is it better to calculate it in a programming language and then store the age
result into the database?
The goal here is to let each student's age update automatically each year. Also to make sure the application performance is top notch(which includes speed).
So which method is better?