The use of including upgrade.php when building custom queries

No, and in fact you should not include the wp-admin/includes/upgrade.php file in a plugin. There is no real valid use case for doing so. It doesn’t do anything for you or add any useful functions for a plugin.

As for your question, you say “it doesn’t work” but you fail to define what that means. Providing the error messages you receive is useful when you’re asking questions.

I do note that in a number of functions, you’re trying to call the functionality in $wpdb without declaring global $wpdb; first. Try replacing the require_once with that instead.