How to start practising SQL for Data Analysis

You might have heard that Data Analysis jobs are constantly in demand, especially in this modern, data driven world. Nowadays data skills are an extremely desirable asset that can instantly enhance your CV!

If you’re looking for a way to enrich your data analysis portfolio, I would definitely recommend you to learn SQL, as it’s a very powerful tool when handling and analysing data.

In a nutshell, SQL lets you access and manipulate data from relational databases through the use of structured queries and commands.

There are many versions of SQL, but in this post I will focus on how to learn Oracle SQL and SQLite.

How to start learning SQL?

I would say that learning SQL will be no different to getting started with any other skill: You need to start with the basics and establish a solid foundation that you can add to from there onwards.

You should also bear in mind that the best way to acquire proficiency in something is to practise it, as often and with as much effort as you can!

When it comes to practising SQL, you will need 2 basic things: data and an SQL editor. You can go for free online options that come with built-in datasets (eg. W3Schools and Oracle Live SQL) or you can choose to work with your own data and install an SQL editor, as explained here.

1. Starting with the Basics

One of the best resources to start learning the basics of SQL (for free!) is perhaps the W3 Schools website.

Screenshot from the online SQL editor from W3Schools
  • The site has its own sample database which includes several tables with varying amounts of data (see screenshot below). The tables aren’t very big, but they should suffice for practising basic SQL commands.
Number of records in the different tables included in the W3Schools Sample Database.
  • The site also offers an online code Editor where you can write your own SQL commands and test them against the sample datasets provided.
    • As long as you have a browser (eg. Chrome or Mozilla Firefox) that lets you access the online editor, you can use this resource from any device.
    • This means you don’t have to install any applications on your device to run your SQL code.
  • Once you’re familiarised yourself with some basic SQL, you can test your understanding with the SQL Exercises offered by the site.

2. Get your hands on Oracle SQL

Eventhough the previous resource is a great starting point, you will need more complex data as you advance through your SQL learning journey.

In my case, I was introduced to Oracle SQL while working on my last project. Eventhough I had already built a solid SQL foundation, there were times when I needed to learn new SQL methods: luckily, that’s when I heard about Oracle Live SQL.

What is Oracle Live SQL?

Oracle Live SQL is a great, FREE platform provided by Oracle that helps you learn more about Oracle SQL and practise different queries.

Code Library screenshot from Oracle Live SQL
  • The platform gives you instant read access to several Oracle Schemas (think of this as datasets), so you can practise your queries with “real life” data
  • It comes with its own online SQL editor where you can write and run your queries.
    • Bonus: The platform lets you save your queries so you can access them any time you like. This means you can easily pick up where you left off last time.
  • Since Oracle Live SQL runs directly from a web browser (eg. Chrome), you won’t need to install any software into your device.
    • This means that you can use Oracle Live SQL from any device that can connect to their website.

Contrary to W3Schools, you must create an account in Oracle Live SQL before you can use their service. The account is free though, so kudos to Oracle for that ✅


What if you want to work with your own data and on your own device?

So far, I’ve discussed 2 tools that let you practise your SQL whilst online, with the datasets provided within each resource. But, what if you want to practise with your own data, or want to work locally, without having to connect to an online resource?

In such cases, you can install a database browser on your device and use it to handle your datasets (think of the DB browser as a “viewer” for your database).

A simple solution is for you to work with SQLite and to query your data via the DB Browser for SQLite (this will be your “database viewer”). Note that the SQLite commands aren’t too different from the Oracle SQL ones, so by practising SQLite you can still improve your general SQL skills.

An SQLite query and its results in DB Browser. Dataset from Kaggle.

Setting up your data in DB Browser

The following steps will show you how to load your data into the DB Browser: once loaded, you can start writing your queries and practising with SQLite!

1. If you haven’t done so before, download DB Browser for SQLite and install it on your device.

2. Make a note of the folder where your database file is stored (in other words, where your data is stored).
Note: If you haven’t got any data yet, you can easily download an SQL dataset from Kaggle. Just make sure you choose an SQLite file as shown below.

Twitter US Airline Sentiment dataset available from Kaggle, via this link

3. Once you install DB Browser, open it and click on Open Database.

4. Navigate to the Folder where your database is stored and select your file (make sure it’s an SQLite file!).
Hint: Go back to Step 2 if you forgot where your data is stored.

5. Click OK and voila! Your database will be loaded and will give you the following options:

Database Structure tab: This screen will list all your database tables, columns within each table and the data type of each column.

Browse Data tab: You can visually inspect your data within this tab and you can apply any filters you see fit. This view is very useful to give you a general idea of how your data looks like.

Execute tab: This is the tab that you’ll be most interested in, as this is where you can practise writing and running your queries! Once you Run your code, you’ll see the results of your queries right below the query editor.

Final thoughts

I hope the resources in this post have helped you on your SQL learning journey! I shared them because I found them to be extremely useful for my own learning.

If you have any feedback about these resources or suggestions for this post, do leave a comment below. You can also get in touch with me at nana7milana@gmail.com.

Thank you for reading and happy learning!

Attribution

  • Twitter US Airline Sentiment Dataset. Downloaded from Kaggle at this link. Dataset Licence: CC BY-NC-SA 4.0
  • Oracle Live SQL screenshots.
  • W3Schools screenshots.