Let's go back to where we left off in the Exercise 11: Validating a Request of Chapter 2, Building the API – Part 1. In this example, we will be using MySQL as our database of choice. Make sure your machine is set up with MySQL and MySQL Workbench:
Use the Code/Lesson-3/exercise-a folder for your reference.
- Open MySQL Workbench. Click on the + button to create a connection:
- Add the connection name as packt, username as root, and the password (if any). Click on Test Connection to see if the connection is correct, then click on OK:
- Click on OK to create the connection.
- Now, click on the connection, packt:
- Create the todo database by running the following query, and click on the Execute icon:
CREATE DATABASE todo;
- The chapter files come with a basic SQL schema for our todo example project, almost similar to what we were using with the basic JavaScript array in the previous exercises:
- In the Code/Lesson-3 folder, there is a file called raw-sql.sql. Open the file with your code editor and copy the contents of the file.
- Then, go back to the MySQL Workbench.
- Paste what you copied from the file in the textbox and click on the Execute icon:
-
- You should see the list of the created tables (todo, todo_item, user) as below, when you click on the Refresh icon to the right of the SCHEMAS label, and click on Tables: