If the URL is [site]/course/view.php?id=XX, then the XX refers to a record in the mdl_course database table.
If the URL is [site]/mod/[activitytype]/view.php?id=XX, then the XX refers to a record in the mdl_course_modules table. In that case, the 'module' field in that record will point to an entry in the table mdl_modules (which will have the name '[activitytype]', matching the URL) and the 'instance' field will refer to a record in the table 'mdl_[activitytype]' (again, matching the URL). See https://docs.moodle.org/dev/Course_module for more details.