Put SEO and Twitter card Meta tags in the Head section prior the render of the template
There's a plugin that allows you to connect to an external database, which will allow you to do a query within the template. Remember to cache the result though as it could slow things down otherwise.
Another option is to sync the external data with Craft using feed me, so you can pull the data locally.