Understanding Joins

Tables in relational databases share information through a conceptual link, or join, between related columns in different tables. These relationships are displayed in the data model through visual join lines between topic items.

Joins enable you to connect or link records in two tables by way of a shared data field. Once a data field is shared, other data contained in the joined tables can be accessed. In this way, each record can share data with another record, but does not store and duplicate the same kind of information.

Joins can be automatically created joins for you, or you can manually join topics.

Suppose you queried only the Customers table to determine the number of customers. You would retrieve 32 records with the names of the stores that purchase products since 32 is the exact amount of stores that have made a purchase.

But suppose you made the same query with the Customers table and Sales table joined. This time you would retrieve 1,000 records, because each store made multiple purchases. Figure 3, Result of Join Between Two Tables shows the intersection of all records in the Sales table that mention stores listed in the Customers table.

Figure 3. Result of Join Between Two Tables

Image shows result of join between two tables.

In other words, a database query returns the records at the intersection of joined tables. If one table mentions stores 1-32 and the other table mentions those same stores repeatedly, each of these records will be returned.

If you join still a third table, such as items, records are returned from the intersection of all three. Figure 4, Result of Join Between Three Tables shows the intersection of all records in the Sales table that have stores in the Customers table and items in the Items table.

Figure 4. Result of Join Between Three Tables

Image shows the result of join between three tables.

The following sections discuss the types of joins available and how to use them: