you may use (if you direct call the DB) WordPress and the wpdb Class
The wpdb class in WordPress is at the core of all database interactions between the core software and your database. It’s also used by both plugins and themes.
The WP_Query class is an extremely powerful WordPress query that you can use to access posts in your database. We’ve already covered WP_Query extensively on this blog before, so I’m really only just pointing it out here.
you may read the article
MySQL and WordPress: Understanding How Databases Work - WPMU DEV
A MySQL database is, essentially, the filing cabinet that holds all of the information on your WordPress site. Here’s everything you need to know about how MySQL works with WordPress in one handy guide.
Also you need to know how a template works see
How to Create WordPress Theme from Scratch: A Beginners Guide
Is creating a WordPress theme seems quite similar to open a Pandora box to you? No issues ...Read on to create WordPress theme from scratch painlessly.
actually create a template with WP_QUERY, and display the results