This assignment assumes you have installed the software MySQL on your computer. If not, please do that first!
- Practice the concepts
- Prep exercises
- MySQL exercises
- Code along
- Career Training 2 (If not completed yet)
Let's start this week off with some interactive exercises. Check out the following to get started writing your first queries! In the following online course, do sections 1 (Manipulation) and sections 2 (Queries).
Also make time to do lesson 1-5 from the following:
Prep exercises are exercises that you should work on before the session on Sunday. These are a little more difficult or show an important concept and as such are a great exercise to talk about with your mentor. Have a solution ready by Sunday as you may be asked to show what you did.
The QA_PREP_EXERCISE.md file explains what needs to be done for the prep exercise this week. There will also be some questions at the bottom to think about. Go through them before the session on Sunday as it will be covered then.
You will need to do some research to solve these exercises. NOT all the concepts necessary to solve these exercises are covered in the reading material. This is on purpose.
Write a JavaScript file (to be executed with Node.js) that creates and makes a connection to a MySQL database. Do so
using the mysql
package (https://www.npmjs.com/package/mysql).
Remember, It's always better to test your queries as soon as you have created them. Feel free to first write them in any SQL viewer tool or MySQL console before writing the Node program.
- Create a database called
meetup
- Make a connection to your database, using your MySQL
hyfuser
login credentials - Create a table called
Invitee
with the following fields (invitee_no
,invitee_name
andinvited_by
) - Create a table called
Room
with the following fields (room_no
,room_name
andfloor_number
) - Create a table called
Meeting
with the following fields (meeting_no, meeting_title, starting_time, ending_time
,room_no
) - Insert 5 rows into each table with relevant fields. Find a way to create the data for those fields
- Test your code by executing
node <FILE_NAME>
in the terminal. Then check your MySQL database and see if everything has been created as expected. Please, be sure your file can be run more than once. You can drop and create the database every time the file is run.
For this part of the assignment, use the
world.sql
file in theweek1/databases
folder to create the database and tables. Before you go on, execute the file to create a database instance of theworld
database, using mysql console or any tool. Test to see if it's created. Make sure all the tables (city
,country
andcountrylanguage
) and the containing data are there.
Write a JavaScript file (to be executed with Node.js) that queries (using select statements) the world
database. The
results given back should answer following questions:
Don't omit to test your queries evey time.
- What are the names of countries with population greater than 8 million?
- What are the names of countries that have “land” in their names?
- What are the names of the cities with population in between 500,000 and 1 million?
- What's the name of all the countries on the continent ‘Europe’?
- List all the countries in the descending order of their surface areas.
- What are the names of all the cities in the Netherlands?
- What is the population of Rotterdam?
- What's the top 10 countries by Surface Area?
- What's the top 10 most populated cities?
- What is the population number of the world?
After you've written your tested queries, test to see if everything work by executing node <FILE_NAME>
.
In this week's code along you won't be building a complete app, but get familiar with using MySQL together with Node.js.
Remember that the Career Training 2 session is coming up (check your cohort channel on slack for the exact date). Before the session make sure you have:
- Read the whole ‘Interview Preparation’ Repo.
- Done the assignment: make a copy of this file and submit your answers to the team here.
After you've finished your todo list it's time to show us what you got! The assignment that needs to be submitted is the following:
- MySQL exercises
Upload your code to your forked Databases repository in GitHub. Make a pull request to HackYourAssignment/databases-cohortXX
repository.
Forgotten how to upload your assignment? Go through the guide to learn how to do this again.
Deadline Tuesday 23.59 CET