Joining Tables in a Datasource

A JOIN is used to combine rows of two or more tables based on a common field between them. Joins are used to access data from multiple tables and represent that data as a separate combined table. There are many types of joins. LEFT JOIN, RIGHT JOIN, FULL JOIN and INNER JOIN are among them.

For example, let’s consider the two tables; Order and Product. The Order table would have have a field to represent the product. Generally, this would be the Product ID. If we need to access the details of the order and the details of the product of that order, instead of querying two tables, we can create a join between the tables. The Order table would be connected to the Product table using the product_id field of the Order table and the id field of the Product table. The joined table would include data from both these tables, based on the type of JOIN defined in this JOIN relationship.

Zing gives you the capability to create joins between multiple tables or views. You can create a single JOIN or a set of JOINS. Zing Data creates an internal representation of this JOIN helping you avoid storage costs and administration overhead.

Step 1: Connect your datasource

  1. Log into the Zing Data console here.
  2. Click on “Connect” on the datasource type you want to connect from the dashboard.
  3. Connect to your datasource and select the required tables.

Step 2: Create a Join

Now click on Data Sources on the navigation bar where you can see the list of connected datasources.

  1. Click on the “Settings” button of the datasource you connected.
  2. Next, click on the “Add New Join” button.
  3. You will see the list of tables of your datasource on the right sidebar.
  4. Drag a table to the canvas. The first table you drag will be considered as the root table for your join. The header of this table will be highlighted in blue.
  5. Drag the next table which you want to connect to your first table, on to the canvas.
  6. When you move the cursor to the right edge of a field in the first field, the cursor will turn to a plus sign, giving you the capability to drag a connection to a field from the second table.
  7. A successful connection will be created if the data types of the two fields match.
  8. You can update the JOIN type by clicking on the JOIN icon and selecting the type from the dropdown.
  9. If you need to create a JOIN with more than two tables, you can drag the next table and create a connection by following the same steps above.
  10. Type in a name for your JOIN and click “Save”.
  11. The JOIN will be validated and saved. Next, let’s look at how to query this joined table.

Step 3: Querying a join

Navigate to the Zing App.

  1. You will be able to see the joined table along with the other tables under “Tables and Joins” on the homepage.
  2. Click on the joined table. You will be navigated to the Swift Query builder.
  3. Columns from both tables in the JOIN will be available for you to start querying.
  4. Drag a column to the X Axis and drag another column to the Y Axis. Zing will run the query and display the chart.
  5. Click on “Run”. Next, click on the three-dot menu and save the question.

Conclusion

And that’s it! In a few easy steps, you’ll be able to query multiple tables/views together with the use of JOINS enabled by Zing.

Related articles

Download Zing For Free

Available on iOS, Android, and the web

Learn how Zing can help you and your organization collaborate with data

Schedule Demo