theme bp-corporated add a new page

i want to add a new page. The page must show the 5 first records from a new table from the database. in the admin panel, i added a new page.
1) is it neccessary to add the code to select the db ?
2) should i put the query in a function? if yes how do i have require that function?
3) any example will be appreciated.