MySQL

Databases with MYSQL


Progress
Reviewed: 0%
8 Tasks


MySQL is one of the most widely used open-source relational database management systems. As a software engineer, it is essential to have a solid understanding of SQL commands and MySQL server monitoring to be able to design, develop, and maintain efficient and robust databases.
In this course, you will learn the fundamentals of SQL commands, including data retrieval, modification, and management. You will also gain practical experience in creating and optimizing MySQL databases. You will get a comprehensive understanding of how to apply this knowledge to build efficient and reliable databases for your web applications.



  • Day 1
  • Introduction to MySQL

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"\n Task 1: Install MySQL + Workbench\n\n Follow these simple steps:\n \n Go to "},{"text":"https://dev.mysql.com/downloads/","bold":true},{"text":"\n Download "},{"text":"MySQL Installer (Community Edition)","bold":true},{"text":"\n Choose installation type: "},{"text":"Developer Default","bold":true},{"text":"\n Set username: "},{"text":"root","bold":true},{"text":"\n Create a password (remember it!)\n Finish setup → MySQL Workbench is installed 🎉\n \n "}]},{"_type":"paragraph","spans":[{"text":"\n Task 2: Open MySQL Workbench\n\n Launch MySQL Workbench and log in using:\n \nUsername: root\n\n Password: your_password\n "}]}]



  • Day 3
  • CREATE Statement and Data Types

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Create the Database\n\n Using the CREATE DATABASE statement, create a database named CompanyDB.\n\n\n Example:\n\n CREATE DATABASE CompanyDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Select the Database\n\n After creating it, switch to the database using:\n\n USE CompanyDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Create the Table\n\n Inside CompanyDB, create a new table named Products with the following columns:\n\n\n\n \n product_id – INT, AUTO_INCREMENT, PRIMARY KEY\n product_name – VARCHAR\n price – DECIMAL\n in_stock – BOOLEAN\n added_date – DATE\n \n\n Example starter structure to edit:\n\n \n CREATE TABLE Products (\n\n   product_id INT AUTO_INCREMENT PRIMARY KEY,\n\n   product_name VARCHAR(100),\n\n   price DECIMAL(10,2),\n\n   in_stock BOOLEAN,\n\n   added_date DATE\n\n );\n \n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL from the dropdown.\n\n A starter code will appear automatically — edit inside that code to complete the assignment.\n\n Your final output should successfully create the CompanyDB database and Products table.\n "}]}]



  • Day 4
  • SELECT and WHERE

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Create the Database\n\n Create a database named StoreDB.\n\n\n Example:\n\n CREATE DATABASE StoreDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Select the Database\n\n Switch to the database using:\n\n USE StoreDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Create the Orders Table\n\n Create a table named Orders with the following columns:\n\n\n\n \n order_id – INT, AUTO_INCREMENT, PRIMARY KEY\n customer_name – VARCHAR(100)\n amount – DECIMAL(10,2)\n order_date – DATE\n is_delivered – BOOLEAN\n \n\n Example table structure:\n\n \n CREATE TABLE Orders (\n\n   order_id INT AUTO_INCREMENT PRIMARY KEY,\n\n   customer_name VARCHAR(100),\n\n   amount DECIMAL(10,2),\n\n   order_date DATE,\n\n   is_delivered BOOLEAN\n\n );\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 4: Insert Sample Records\n\n Insert at least two rows:\n\n \n INSERT INTO Orders (customer_name, amount, order_date, is_delivered) VALUES\n\n ('Rahul Sharma', 650.00, '2025-01-10', TRUE),\n\n ('Sneha Patel', 400.00, '2025-01-12', FALSE);\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 5: Write SELECT Queries\n\n Write queries to show:\n\n • Only delivered orders\n\n • Only orders with amount > 500\n\n\n\n Example:\n\n \n SELECT * FROM Orders WHERE is_delivered = TRUE;\n\n\n SELECT * FROM Orders WHERE amount > 500;\n \n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL.\n\n A starter code will automatically appear — edit inside that code to complete all steps.\n\n Your output must correctly fetch filtered data using the SELECT and WHERE clauses.\n "}]}]



  • Day 5
  • Insert, Update and Delete Statements

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Create the Database\n\n Create a database named LibraryDB.\n\n\n Example:\n\n CREATE DATABASE LibraryDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Select the Database\n\n Switch to the database:\n\n USE LibraryDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Create the Books Table\n\n Create a table named Books with the following columns:\n\n\n\n \n book_id – INT, AUTO_INCREMENT, PRIMARY KEY\n title – VARCHAR(100)\n author – VARCHAR(100)\n price – DECIMAL(10,2)\n is_available – BOOLEAN\n \n\n Example:\n\n \n CREATE TABLE Books (\n\n   book_id INT AUTO_INCREMENT PRIMARY KEY,\n\n   title VARCHAR(100),\n\n   author VARCHAR(100),\n\n   price DECIMAL(10,2),\n\n   is_available BOOLEAN\n\n );\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 4: Insert 3 Books\n\n Add three sample books:\n\n \n INSERT INTO Books (title, author, price, is_available) VALUES\n\n ('Atomic Habits', 'James Clear', 450.00, TRUE),\n\n ('The Alchemist', 'Paulo Coelho', 300.00, TRUE),\n\n ('Deep Work', 'Cal Newport', 550.00, FALSE);\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 5: Update a Book Price\n\n Update the price of any one book:\n\n \n UPDATE Books SET price = 500.00 WHERE book_id = 2;\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 6: Delete a Book\n\n Delete a book where is_available = FALSE:\n\n \n DELETE FROM Books WHERE is_available = FALSE;\n \n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL.\n\n A starter file will appear — modify that code to complete the assignment.\n\n Your final output should correctly perform INSERT, UPDATE, and DELETE operations.\n "}]}]



  • Day 6
  • Drop and Truncate

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Create the Database\n\n Create a database named TrainingDB.\n\n\n Example:\n\n CREATE DATABASE TrainingDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Select the Database\n\n Switch to the database:\n\n USE TrainingDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Create Users Table\n\n Create a table named Users with these columns:\n\n\n\n \n user_id – INT, AUTO_INCREMENT, PRIMARY KEY\n full_name – VARCHAR(100)\n email – VARCHAR(100)\n is_active – BOOLEAN\n \n\n Example:\n\n \n CREATE TABLE Users (\n\n   user_id INT AUTO_INCREMENT PRIMARY KEY,\n\n   full_name VARCHAR(100),\n\n   email VARCHAR(100),\n\n   is_active BOOLEAN\n\n );\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 4: Insert Sample Users\n\n Add two sample users:\n\n \n INSERT INTO Users (full_name, email, is_active) VALUES\n\n ('Arjun Singh', 'arjun@example.com', TRUE),\n\n ('Meera Kapoor', 'meera@example.com', FALSE);\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 5: TRUNCATE the Table\n\n Remove all rows from the table:\n\n TRUNCATE TABLE Users;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 6: DROP the Table\n\n Delete the entire table:\n\n DROP TABLE Users;\n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL.\n\n The starter code will appear — modify it to complete all tasks.\n\n Your final output must correctly use TRUNCATE and DROP.\n "}]}]



  • Day 7
  • Group by, Order by, Having

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Create the Database\n\n Create a database named SalesDB.\n\n\n Example:\n\n CREATE DATABASE SalesDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Select the Database\n\n Switch to the database:\n\n USE SalesDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Create the Sales Table\n\n Create a table named Sales with these columns:\n\n\n\n \n sale_id – INT, AUTO_INCREMENT, PRIMARY KEY\n product_name – VARCHAR(100)\n quantity – INT\n price – DECIMAL(10,2)\n sale_date – DATE\n \n\n Example:\n\n \n CREATE TABLE Sales (\n\n   sale_id INT AUTO_INCREMENT PRIMARY KEY,\n\n   product_name VARCHAR(100),\n\n   quantity INT,\n\n   price DECIMAL(10,2),\n\n   sale_date DATE\n\n );\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 4: Insert Sample Data\n\n Insert 4 rows of sample sales:\n\n \n INSERT INTO Sales (product_name, quantity, price, sale_date) VALUES\n\n ('Laptop', 3, 50000.00, '2024-01-05'),\n\n ('Mouse', 10, 500.00, '2024-01-10'),\n\n ('Keyboard', 4, 1200.00, '2024-01-15'),\n\n ('Mouse', 6, 500.00, '2024-01-20');\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 5: Group Data\n\n Group by product and calculate total quantity:\n\n \n SELECT product_name, SUM(quantity) AS total_quantity\n\n FROM Sales\n\n GROUP BY product_name;\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 6: Apply HAVING\n\n Show only products where total quantity > 5:\n\n \n HAVING total_quantity > 5;\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 7: Apply ORDER BY\n\n Sort results in descending order of quantity:\n\n \n ORDER BY total_quantity DESC;\n \n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL.\n\n A starter file will appear — modify that code to complete the assignment.\n\n Your final output should correctly apply GROUP BY, HAVING, and ORDER BY.\n "}]}]



  • Day 8
  • Joins - Cross, Inner, Outer

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Create the Database\n\n Create a database named SchoolDB.\n\n\n CREATE DATABASE SchoolDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Select the Database\n\n Switch to the database:\n\n USE SchoolDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Create Two Tables\n\n\n Table 1: Students\n\n \n CREATE TABLE Students (\n\n   student_id INT AUTO_INCREMENT PRIMARY KEY,\n\n   name VARCHAR(100),\n\n   class VARCHAR(20)\n\n );\n \n \n\n\n\n Table 2: Marks\n\n \n CREATE TABLE Marks (\n\n   mark_id INT AUTO_INCREMENT PRIMARY KEY,\n\n   student_id INT,\n\n   subject VARCHAR(50),\n\n   marks INT\n\n );\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 4: Insert Students\n\n \n INSERT INTO Students (name, class) VALUES\n\n ('Rohan', '10A'),\n\n ('Sneha', '10B'),\n\n ('Arjun', '10A');\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 5: Insert Marks\n\n \n INSERT INTO Marks (student_id, subject, marks) VALUES\n\n (1, 'Math', 85),\n\n (2, 'Science', 90),\n\n (1, 'English', 78);\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 6: Perform JOIN Operations\n\n\n 1️⃣ CROSS JOIN\n\n \n SELECT * FROM Students CROSS JOIN Marks;\n \n \n\n\n\n 2️⃣ INNER JOIN (only students who have marks)\n\n \n SELECT Students.name, Marks.subject, Marks.marks\n\n FROM Students\n\n INNER JOIN Marks ON Students.student_id = Marks.student_id;\n \n \n\n\n\n 3️⃣ LEFT JOIN (all students + marks if available)\n\n \n SELECT Students.name, Marks.subject, Marks.marks\n\n FROM Students\n\n LEFT JOIN Marks ON Students.student_id = Marks.student_id;\n \n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL.\n\n A starter file will appear — modify that code to complete the assignment.\n\n Your final output should include CROSS JOIN, INNER JOIN, and LEFT JOIN queries.\n "}]}]



  • Day 9
  • Indexing

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Create the Database\n\n Create a database named IndexDB.\n\n\n CREATE DATABASE IndexDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Select the Database\n\n USE IndexDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Create the Products Table\n\n \n CREATE TABLE Products (\n\n   product_id INT PRIMARY KEY,\n\n   product_name VARCHAR(100),\n\n   category VARCHAR(50),\n\n   price DECIMAL(10,2)\n\n );\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 4: Insert 3 Sample Products\n\n \n INSERT INTO Products (product_id, product_name, category, price) VALUES\n\n (1, 'Laptop', 'Electronics', 55000.00),\n\n (2, 'Chair', 'Furniture', 3000.00),\n\n (3, 'Mobile', 'Electronics', 22000.00);\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 5: Create an Index on product_name\n\n \n CREATE INDEX idx_product_name ON Products(product_name);\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 6: Create a UNIQUE Index on category\n\n (This will prevent duplicate categories)\n\n \n CREATE UNIQUE INDEX idx_unique_category ON Products(category);\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 7: Drop One Index\n\n Example: Drop the index on product_name\n\n \n DROP INDEX idx_product_name ON Products;\n \n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL.\n\n Edit the starter code to complete the assignment.\n\n Your final output must include: creating indexes, unique index, and dropping an index.\n "}]}]



  • Day 10
  • Transactions and ACID properties

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Create the Database\n\n Create a database named BankDB.\n\n\n CREATE DATABASE BankDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Select the Database\n\n USE BankDB;\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Create the Accounts Table\n\n \n CREATE TABLE Accounts (\n\n   acc_id INT PRIMARY KEY,\n\n   holder_name VARCHAR(100),\n\n   balance DECIMAL(10,2)\n\n );\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 4: Insert 2 Sample Accounts\n\n \n INSERT INTO Accounts (acc_id, holder_name, balance) VALUES\n\n (1, 'Rohit Sharma', 5000.00),\n\n (2, 'Virat Kohli', 3000.00);\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 5: Start a Transaction & Transfer Money\n\n Transfer ₹1000 from Account 1 to Account 2.\n\n\n \n START TRANSACTION;\n\n UPDATE Accounts SET balance = balance - 1000 WHERE acc_id = 1;\n\n UPDATE Accounts SET balance = balance + 1000 WHERE acc_id = 2;\n\n COMMIT;\n \n "}]},{"_type":"paragraph","spans":[{"text":"Task 6: Practice ROLLBACK\n\n Perform another transaction but cancel the changes:\n\n\n \n START TRANSACTION;\n\n UPDATE Accounts SET balance = balance + 500 WHERE acc_id = 1;\n\n UPDATE Accounts SET balance = balance - 500 WHERE acc_id = 2;\n\n ROLLBACK;\n \n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL.\n\n Modify the starter code to complete the assignment.\n\n Your output must show correct use of START TRANSACTION, COMMIT, and ROLLBACK.\n "}]}]



  • Day 11
  • Cache in MySQL

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Observe Caching\n\n Understand how MySQL uses caching (buffer pool) to speed up queries.\n\n Students will run SELECT queries on the same table multiple times to see the effect of cached data.\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Starter Code\n\n A starter code will appear in the editor.\n\n You must edit inside the starter code only.\n\n Do NOT delete starter code lines.\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Sample Steps to Try\n\n \n Create a database and a sample table.\n Insert some rows.\n Run a SELECT query multiple times and note the time difference (first run reads from disk, subsequent runs may hit cache).\n \n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL.\n\n Edit the starter code to complete the assignment.\n\n Your submission should demonstrate understanding of caching by showing queries accessing cached data.\n "}]}]



  • Day 13
  • Process list and Explain Commands

    Concept:



    Resources:



    Assignments:


    [{"_type":"heading","level":3,"text":"Your Tasks"},{"_type":"paragraph","spans":[{"text":"Task 1: Understand SHOW PROCESSLIST\n\n Use SHOW PROCESSLIST; to view all active queries and connections.\n\n This helps identify long-running queries and potential bottlenecks.\n "}]},{"_type":"paragraph","spans":[{"text":"Task 2: Understand EXPLAIN\n\n Use EXPLAIN SELECT ... to see how MySQL executes queries.\n\n It shows indexes used, join order, and type of scan (e.g., ALL, index, ref).\n "}]},{"_type":"paragraph","spans":[{"text":"Task 3: Starter Code\n\n A starter code will appear in the editor.\n\n Edit only inside the starter code.\n\n Do NOT delete any starter lines.\n "}]},{"_type":"paragraph","spans":[{"text":"Task 4: Sample Steps\n\n \n Create a sample table with data.\n Run SELECT queries and use EXPLAIN to analyze them.\n Use SHOW PROCESSLIST; to observe query execution.\n \n "}]},{"_type":"paragraph","spans":[{"text":"💡 Tip:\n\n You must not write the full code from scratch — use the starter code that appears in the editor and edit inside it.\n\n\n Note: Our code editor uses SQLite. You can run your SQL queries here, and try MySQL locally if needed.\n "}]},{"_type":"heading","level":3,"text":"For Submission"},{"_type":"paragraph","spans":[{"text":"\n Go to “Submit via Editor” → select MySQL.\n\n Modify the starter code to complete the assignment.\n\n Your final submission should demonstrate using SHOW PROCESSLIST and EXPLAIN effectively.\n "}]}]



×

Let's Go!

Congratulations on getting started. Here is a little reward for you...

×

10

Going to the next task in