MySQL has seven query commands (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, and LIMIT) through which the data analysis is done in a database. But all these queries are helpful to analyze the data present in a single table in the entire database. A database contains more than one table in the real world, and all those tables will be interrelated.

To analyze the data on more than one table at a time, we’ll use Joins, Views, and CTEs.

We can download the database which we are using in the article here.

Primary and Foreign Keys

To understand how the Joins work, we need to be familiar with the concept of primary and foreign keys.

A primary key is a single field/column name that uniquely defines the table. The column should not contain any null values, it should not have duplicate values, and a table should have only one primary key.

A foreign key from a table refers to the column in another table.

Let’s see a simple example for a better understanding of Primary and Foreign Keys in a database.

We’ll take two tables from the database.

  • market_fact_full

#database #mysql #join #views #data-science

Joins, Views, and CTEs: MySQL Workbench
1.20 GEEK