Sams Teach Yourself SQL in 10 Minutes a Day: Setting Up for Success

Photo by Avery Evans on Unsplash

Yes, you need to learn SQL

You’ve heard it before, I’m saying it again: If you’ve studied to be a Data Scientist, there’s a big chance you’ll need SQL to break into your first job. There are tons of resources for learning SQL (referred to by its letters S-Q-L or pronounced “sequal”), but I kept hearing about a book titled Sams Teach Yourself SQL in 10 Minutes a Day* by Ben Forta to get started. It shows up on practically every “best of” SQL book list, and is one of the best selling SQL books of all time (1/4 of a million copies sold holds some weight!). So some data nerd friends of mine and I gave it a try in our book club. While I already had some limited experience using SQL, this book is great for someone who’s never even seen a SELECT statement.

*Note: resources for buying and/or downloading the book can be found at the end of this article.

While the book is extremely beginner-friendly, there is one potential roadblock I could see for beginners, and that is getting your environment set up for the first time. After the 3rd time having to reinstate my connection, I thought “maybe I should jot this down for others?” So I just wanted to write a “quick tips” entry on how to get started setting up a MySQL server and the appropriate scripts to follow along in the chapters.

Download your necessary files

First, you’ll have to decide which DBMS (Database Management System) you want to use. I chose MySQL because it’s one of the most popular, it’s fairly easy to set up, and it’s free.

Download both the MySQL and also the MySQL Workbench for your operating system. (I’m on macOS.) Follow install instructions accordingly.

Next, you’ll head to the book’s resources page and scroll until you find Appendix A (pictured below) and choose MySQL (and MariaDB) SQL Scripts.

Appendix A: Sample Table Scripts (screenshot)

This will download 3 files: README.pdf, populate.txt, and create.txt. Once you have your programs and scripts downloaded, you have what you need to get set up.

Getting Connected

Open MySQL Workbench and click the plus sign to create a new connection.

Welcome (screenshot)

On the window that pops up, name it something catchy like “localhost” and click on “Test Connection”.

The instructions in the book at this point say “if all ok, click OK to create the connection,” but you made need to troubleshoot (I did… hence this blog post😉). If you encounter an error that begins with “Failed to Connect,” you’ll need to head to your Mac’s System Preferences and click on MySQL.

System Preferences (screenshot)

In the Instances window, click on “Initialize Database” on the right side.

Click Initialize Database (screenshot)

In the window that pops up, enter your computer’s password and choose Use Legacy Password Encryption, and click OK.

Enter your credentials (screenshot)

Doing so will bounce you back to your Instances window, where you’ll click Start MySQL Server. You’ll notice your red instances turn green and you’re good to go!

Green light! (screenshot)

Head back to MySQL and try “Test Connection” again. This time, you should (hopefully) get a success message like “Successfully made the MySQL connection”. Press OK and your localhost connection will appear on the welcome screen.

localhost now available (screenshot)

Creating Your Database

Next, you will use the SQL scripts you downloaded to create and populate the database needed to follow along with the exercises.

View this short video demonstrating the next few steps on how to create a new schema (aka a new database) and follow along in steps 1–5 below.

Creating your database/schema (video by author)
  1. First, click on the “Create New Schema” button (looks like a barrel with a + sign next to it).
  2. Name your new schema something like tysql and click Apply. Another verification window will pop up and you’ll click Apply again.
  3. Go back to your Query window and select your newly created tysql database from the Object Browser menu on the left by double clicking. You’ll know it’s selected because it will be bold.
  4. Copy and paste the contents of the “create” file into the SQL editor window and execute the query using the lightning bolt icon (or hot keys Cmd+return).
  5. Now copy and paste the contents of “populate” into the SQL editor window and execute this query as well.

Done! Time to test it out with your first Select statement.

SELECT * FROM Customers
Photo by Christina @ wocintechchat.com

I hope this article is helpful for beginners getting MySQL up and running. Now, go forth and learn SQL!

Resources

Buy the book: Sams Teach Yourself SQL in 10 Minutes a Day — AbeBooks has used copies for around $6 ♻️

Get the (digital) book for free from zlibrary — Zlibrary is my favorite resource for free books online. You can download books in PDF or EPUB format (EPUB works in your mac or iPhone’s Apple Books app)

From forta.com, download the files needed to follow along the exercises.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Cierra Andaur

Cierra Andaur

73 Followers

Data Scientist | Analytics Nerd | Pythonista | Professional Question Asker |