Count the records of a related module and save the value in a custom field

Count the records of a related module and save the value in a custom field

I have a custom module called Reservations that is related to the Contacts module.

Through related lists I can know how many reservations each contact has.

I need to store this number in a custom variable of the Contact module called "Number of Reservations". I have tried with a custom function through a Workflow but it doesn't work quite right.

Is it possible to make a query directly and have the field updated in real time every time I access a contact's record?