You will develop a plugin to interface with WP. You will access the database using $wpdb methods. You could either create the tables manually with myPhpAdmin if this is a one off app, or via the plugin activation hook.
The relationships are defined by how you construct the SQL queries. You will want to develop a series of functions that add an abstraction layer between procedural code and the database. Functions like list_image_comments()
and such to establish relationships and to avoid writing mySQL queries every time you want something out of the database, just as WP does with it's data. This is best done by defining class properties and methods, but not a requirement.
If you are looking for examples, you don't need to look much farther than the WP source code itself.