Credits: SQL Practice Problems.
Based on the following publication:
Title: SQL Practice Problems: 57 beginning, intermediate, and advanced challenges for you to solve using a “learn-by-doing” approach
Edition: Kindle
Publication date: November 16, 2016
ASIN: B01N41VQFO
The original scripts shipped with the Kindle edition of the book I bought off Amazon was compatible with only Windows/SQL Server. I needed a way to run the scripts on my Mac. I came up with two solutions:
- Option 1: Port the scripts to work on MySQL.
- Option 2: Run Microsoft SQL Server as a Docker container.
Both the options are cross-platform!
- Login to MySQL
$ mysql -h localhost -P 3306 --protocol=tcp -u root -p
- Re-create database
mysql> drop database if exists northwind;
mysql> create database northwind;
- Import northwind-mysql.sql
mysql> source [/path/to/]northwind-mysql.sql;
You'll notice the tables and column names are in snake_case per MySQL convention.
-
Install Docker Desktop for Mac
-
Start MS SQL Server as a Docker container
$ docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=@dmin!234' -p 1433:1433 --name mssql -h mssql -d mcr.microsoft.com/mssql/server
-
Note the credentials. User ID is
SA
. Password is@dmin!234
. -
Install Azure Data Studio for Mac
-
Set up the database in MS SQL Server:
- Login to Azure Data Studeo
- Launch 'New query' and run the following command:
CREATE DATABASE Northwind
- Refresh the tree on the left to reveal Northwind.
- Launch 'New query' and run the contents of the file northwind-ms-sql-server.sql.
- Refresh the tree again to reveal the tables created.