Tutorial — Relational Data Browsing

DZone 's Guide to

Tutorial — Relational Data Browsing

In this article, navigate bidirectionally through the database by following foreign-key-based or user-defined relationships with Jailer.

· Database Zone ·
Free Resource

Image title

Relational Data Browsing

Navigate bidirectionally through the database by following foreign-key-based or user-defined relationships with Jailer.

The Jailer tool can be found at:

You might also like:  Why You Should Use a Relational Database Instead of NoSQL for Your IoT Applications

1. Connect With the Database

Start the Data Browser (JailerDataBrowser.exe or jailerDataBrowser.bat on windows platform)

$ sh jailerDataBrowser.sh

and create a new data model. Press New and enter "Tutorial" as the name for the new model.

A data model holds information about the tables in the database and all associations between them.

Most of the information can be retrieved automatically by analyzing the database schema.

Click on Analyze Database.

You will be asked for the database connection information.

Image title

Create a new connection.

Image title

Select the DBMS you are using from the displayed list and fill out the following form:

Image title

Finally, click on Connect. Jailer finds seven tables and five associations:

Two associations are still missing:

  • an employee is classified into a salary grade depending on his salary
  • employees may receive bonuses
Add the definitions manually (Add-Button under Associations):

Image title

The data model is now complete.

2. Browse a Table

Select the menu item "Open Table" from "File" and choose "EMPLOYEE" as the table you want to browse.

A Table Browser appears showing the rows of table EMPLOYEE.

Image title

3. Browse Related Rows

Select the "Children" item from the "Related Rows" drop-down menu and choose "EMPLOYEE on inverse-BOSS".

Another Table Browser appears showing the subordinates of each Employee (the inverse of the "BOSS" relationship).

4. Generate SQL-Query

Within each table browser, a SQL-Query can be generated which selects exactly the browser's content.
Essentially it's a join of all the tables in the navigation chain.

Close the second "EMPLOYEE" browser, navigate from EMPLOYEE to PROJECT_PARTICIPATION, and from there to PROJECT.

Choose "Query Builder" item from the "SQL/Query" menu in the "PROJECT" browser:

Image title

The Query Builder form lets you save the query into a file, copy it to the clipboard or even execute it.
Choose "Execute" to get a query-result browser:

Within this query-result browser, you can edit the query anyway you want.

Thanks for reading!

Further Reading

From Relational to Graph: A Developer’s Guide

Relational Data Model: Back to the Roots

client, database, jailer, jailer tool, relational data browsing, sql, tutorial

Published at DZone with permission of Ralf Wisser . See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}