Accessing database to make a site dynamic is something that every PHP developer encounters with. But every time there are game changer newbie in the town.
The most important point for accessing data from custom DB Table is to have a custom DB table. Rest other things are secondary.
1. Create a db table in db created by word press installation. keep prefix wp_ before table name.
2. Access this table via get_results() method called on word press db object.
Pseudo Code snippet
$categoryArray = $wpdb->get_results("SELECT DISTINCT CATEGORY_ID FROM `wp_blogs_table` WHERE PARENT_CATEGORY=0;");
Use this code to access dynamic data from a database in your word press pages.