I would use web services in preference to updating the database directly. If there are web service functions in existence which do what you want. You might also want to look at Moosh https://moosh-online.com/.
Failing that... you *can* update the database directly but you first need to understand the database. It's grown organically over around 20 years and the consequence of that is that it doesn't always make a great deal of sense.
The other issue you face is that Moodle relies heavily on its cache API. So changing the database doesn't always have an immediate effect on the front-end. So - executive summary - except in exceptional (one off) circumstances, I would definitely avoid updating the database from outside Moodle on a "business as usual" basis.
Failing that... you *can* update the database directly but you first need to understand the database. It's grown organically over around 20 years and the consequence of that is that it doesn't always make a great deal of sense.
The other issue you face is that Moodle relies heavily on its cache API. So changing the database doesn't always have an immediate effect on the front-end. So - executive summary - except in exceptional (one off) circumstances, I would definitely avoid updating the database from outside Moodle on a "business as usual" basis.
You can also consider writing your own plugin that works with Moodle's built-in APIs directly. It's reasonably straightforward for a plugin to publish its own Web service functions if that might help.