Introduction
In this project, you will learn how to create a "favorite" table in a MySQL database. The "favorite" table will store the courses with the longest study time for each user in the "usercourse" table.
ð Preview
MariaDB [labex]> select * from favorite limit 10;
+----+-----------+-------------+------------+
| id | user_name | course_name | study_time |
+----+-----------+-------------+------------+
| 2 | user_01 | English | 101 |
| 3 | user_02 | Chinese | 102 |
| 4 | user_03 | Chemical | 103 |
| 5 | user_04 | Physics | 104 |
| 6 | user_05 | Biology | 105 |
| 7 | user_06 | Painting | 106 |
| 8 | user_07 | Music | 107 |
| 9 | user_08 | Computer | 108 |
| 10 | user_09 | History | 109 |
| 11 | user_10 | Math | 110 |
+----+-----------+-------------+------------+
10 rows in set (0.000 sec)
ðŊ Tasks
In this project, you will learn:
- How to access the MySQL database using the
sudo
command - How to import data from a SQL script into the MySQL database
- How to create a new table with specific columns using the
CREATE TABLE AS
statement - How to join multiple tables to retrieve the necessary data for the "favorite" table
ð Achievements
After completing this project, you will be able to:
- Understand how to manage a MySQL database using the command line
- Implement a SQL query to create a new table based on data from multiple existing tables
- Apply the concept of finding the maximum value for each group in a table
- Demonstrate your ability to work with SQL statements to achieve a specific data management task