Whatever your bot should do, it's up to you! If you have a script being able to search a database, integrate it in your bot's code. If you have a control script Monitoring your infrastructure you may also make the bot querying it and response to your requests. If you'd have a remote control script for a plane, integrate it and your bot may control the plane
You can start with the sample bots which are reacting to a simple hello. Extend them to responded to a phrase query, extract the term and issue it to your database, get the results back and make the bot post a response.
For more detailed bot related help (ie. not about querying a database) you must provide more information as well: code samples etc, error messages