Hands-On Lab - Create and Load Tables Using SQL Scripts
Hands-On Lab - Create and Load Tables Using SQL Scripts
In this lab, you will learn how to create tables and load data using the phpMyAdmin graphical user interface (GUI) tool in the MySQL database
service.
Objectives
After completing this lab, you will be able to use phpMyAdmin with MySQL to:
MySQL
In this lab, you will use MySQL. MySQL is a Relational Database Management System (RDBMS) designed to efficiently store, manipulate, and
retrieve data.
To complete this lab, you will use MySQL relational database service available as part of IBM Skills Network Labs (SN Labs) Cloud IDE, the
virtual lab environment used in this course.
Each table has a few rows of sample data. The following diagram shows the contents of the CVD database:
about:blank 1/8
02/07/2024, 15:38 about:blank
Your task is to create this database in MySQL. This task is divided into three parts.
Task 3: Populate each table with the data in respective CSV files.
Launch phpMyAdmin
1. Click Skills Network Toolbox. In the Database section, click MySQL.
2. Once MySQL has started, click the phpMyAdmin button to open phpMyAdmin in the same window.
about:blank 2/8
02/07/2024, 15:38 about:blank
4. In the tree view, click New to create a new empty database. Then, enter CVD as the name of the database and click Create.
The encoding will be left as utf8mb4_0900_ai_ci. UTF-8 is the most commonly used character encoding for content or data.
about:blank 3/8
02/07/2024, 15:38 about:blank
Note: SQL scripts are basically a set of SQL commands compiled in a single file. Each command must be terminated with a semicolon ;. The extension
of the file is to be kept as .sql. Upon importing this file in the phpMyAdmin interface, the commands in the file are run sequentially.
CVD_Database_Create_Tables_Script.sql
Click Choose File, browse for the file and upload it.
about:blank 4/8
02/07/2024, 15:38 about:blank
The script then gets executed successfully, and the interface shows entries in the image below.
about:blank 5/8
02/07/2024, 15:38 about:blank
Click any of the tables to see its Table Definition (its list of columns, data types, and so on). The image below displays the structure of the
table PATIENTS.
The steps below explain loading data into the tables you created in Task 2.
Patients.csv
about:blank 6/8
02/07/2024, 15:38 about:blank
MedicalHistory.csv
MedicalProcedures.csv
MedicalDepartments.csv
MedicalLocations.csv
Browse to the location of the CSV file and click ‘Go’ to load the CSV file.
The images below share how to load the CSV data to the PATIENTS table.
Once the table is loaded, you will get a message that the records are inserted successfully.
Further, you can click on browse and view the table's data.
Practice exercise
Repeat the same process for all of the other tables.
Conclusion
Congratulations on completing this lab.
about:blank 7/8
02/07/2024, 15:38 about:blank
Use phpMyAdmin GUI to operate on MySQL servers
Author(s)
Dmytro Yesyp
Additional Contributor(s)
Abhishek Gagneja
Changelog
Date Version Changed by Change Description
2023-10-09 1.3 Steve Hord QA pass with edits
2023-10-06 1.2 Misty Taylor ID Check
2023-09-09 1.1 Abhishek Gagneja Modified the instructions
2023-08-02 1.0 Dmytro Yesyp Initial version created
about:blank 8/8