DATA with BARAA

DATA with BARAA

fun with data

SQL Basics

Querying Data

Filtering Data

Joining Tables

SQL Functions

Modifying Data

Defining Data

Create our SQL Database

In this tutorial, you will learn how to create the database for our tutorial, learn about the contents of the database and at the end you will even execute your first SQL statement!

Intro to our Tutorial SQL Database

We will work on the db_sql_tutorial database as MySQL sample database to help you through the tutorial quickly and effectively.

The db_sql_tutorial database contains simple, typical tables:

  • Customers – stores all customer information such as names, country, and scores.
  • Orders – stores sales orders placed by customers.
  • Employees – stores all employee information such as names and salaries.

All the examples in tutorials are based on both tables customers and orders. In only a few examples we will be using employees.

The following diagram is called ER-Diagram, it stands for Entity Relationship Diagram. It is a graphical representation of the database tables. 

Sometimes we call it a data model, it makes it easy to understand the tables and the relationship between them. In our example, we have two tables, customers and orders, and both are linked using the column customer_id.

Let’s have a look inside Customers and Orders, we will find the following data: 

Create our Tutorial SQL Database

#1 Copy SQL Database Script

The following SQL script contains 53 rows, which will create all the objects we need in our tutorial.

Get Baraa's FREE SQL Stuff

Subscribe to get the script of our tutorial SQL database, the data inside it, SQL Cheat Sheet and many Presentations... all for free 😉

You don’t have to understand this script, so don’t worry, but I promise that you will understand every line after completing the tutorial

.

#2 Execute the Script

Open your MySQL Workbench and follow the simple three steps:

  1. Past the script in Query Editor
  2. Click Execute
  3. The output should not contain any errors. you can ignore the warnings.

#3 Query our Tutorial SQL Database

Generally speaking, if you create or change anything in the database, always click on refresh to see the new changes. 

In the last step, we created a new databasedb_sql_tutorial and you might not see it at the Schema Navigator. To be able to see it, click on refresh like in the picture below. 

I would recommend you to navigate through our database.

Lets now query our data, and write our first Hello world SQL statement:

				
					SELECT * FROM customers
				
			

If you are able to see all customers, that means you have successfully created the database and you wrote your first query! 👏

.
Share it !