Giter VIP home page Giter VIP logo

be-northwind-mysql's Introduction

Northwind MySQL Challenge

A pre-populated MySQL database and practice exercises.

Getting Started

This exercise requires you to install docker on you macine. Docker allows us to run applications inside containers. You can read more about containers here.

Installing Docker

Ubuntu

Update your software database:

sudo apt update

Remove any old versions of docker that might be on your system:

sudo apt remove docker docker-engine docker.io

Install docker:

sudo apt install docker.io

Check docker version:

docker --version

Windows and Mac

Docker requires a Linux kernal in order to run. This can be emulated on Windos and Mac. The easiest way to do this is to install Docker Desktop. You will need to have Docker Desktop running in order to use docker commands in your terminal.

Install MySQL Workbench

For this challenge we will be using MySQL Workbench. Windows and Mac users can download it from here. Linux users can run:

sudo apt install mysql-workbench

Getting the Database Running

Run the container

docker run -d -p 3307:3306 --name northwind -e MYSQL_ROOT_PASSWORD=supersecret manchestercodes/northwind

Finally you can confirm the container is built and running by opening a shell inside it. This uses the exec command:

docker exec -it northwind bash

The -it option asks docker to open an interactive shell, and then we set the terminal promt to bash.

From here we can open mysql and check the database has been created:

mysql -uroot -p

You will then be prompted for the root user password. Type in supersecret and hit return. (characters you entered won't be shown on terminal, just type away and hit enter)

Check database has been created:

show databases;

You should see the following:

+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| northwind          |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

That's everything we need to do inside the container. Type in exit; to close MySQL and then again (without the ;) to exit the container. It will continue to run in the background.

Working on the database

Open up MySQL-Workbench and connect it to local instance 3303 if it's listed under "MySQL connections”.You will need to enter the root user password supersecret.

If the connection is not automatically shown, you can create one by clicking the + button and filling the fields:

- Connection Name: `northwind`
- Username: leave it as `root`
- Port: leave it as `3307`
- Password: `supersecret`

Click Test Connection and then OK.

In the bottom right of the screen you will see the northwind database. Right click on it and set it as your default schema.

Check that you are able to send queries to the database by entering some thing like:

SELECT * FROM employees;

Click the lightning bolt and confirm that the query returns employee information.

Running the image on M1 Mac

Run the image

docker run -d -p 3307:3306 --name northwind -e MYSQL_ROOT_PASSWORD=supersecret manchestercodes/northwind:m1

Please ignore the MYSQL_ROOT_PASSWORD environment variable we passed above.

Accessing the database

You can connect MySQL Workbench or any other DB GUI to this version of the database with the following settings:

- Username: user
- Port: 3307
- Password: password

be-northwind-mysql's People

Contributors

codenivore avatar dragosrobertn avatar ersel avatar ian-antking avatar lukebrobbs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

be-northwind-mysql's Issues

00-create-exercises.md -- Task 6

Task 6 states "Now recreate the table, but this time make the country a key field. This can also be used to prevent duplicate data."
But the solution defines region_id as the KEY field.
Should the Task read "Now recreate the table, but this time make the region_id a key field. This can also be used to prevent duplicate data."
or...
"Now recreate the table, but this time make the country_id a key field. This can also be used to prevent duplicate data."
and the solution defines country_id as the KEY field?

00-create-exercises.md -- Task 7

The task states "Finally, recreate the table with the country_id as a primary key with auto increment. Insert a few records into the table to confirm that it is auto-incrementing this column."

This is confusing since all previous task solutions define country_id as VARCHAR(2) which implies ISO 3166 ALPHA-2 codes.

Would it not be better to aim this task at a field that has previously been established with a datatype of INTEGER?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.