Selenium is just a browser automation tool. You can use the programming language(PL) of your choice to use its library say Java or python, combine it with any testing framework to do your testing.
To test the DB, you have to go to the official site of DB and use the driver and the library available for the PL of your choice.
You can write your DB commands in between your Selenium code.
That's how it integrates.