Hi,
When user is enrolled into a particular course. which tables are updated?. I want to find out course_id corresponding to user_id ? .
The tables to query are mdl_user_enrolments and mdl_enrol
SELECT ue.id, ue.userid, e.courseid
FROM {user_enrolments} ue JOIN {enrol} e ON ( ue.enrolid = e.id)
AND userid = ?
This diagram might help a little
Another thing that you can use to get these data is Moodle API's (when you are outside moodle).
For your request you can get what you want with 'core_enrol_get_users_courses'