0
0
MySQLquery~30 mins

MySQL CLI and Workbench - Mini Project: Build & Apply

Choose your learning style9 modes available
Using MySQL CLI and Workbench to Manage a Simple Database
📖 Scenario: You are helping a small bookstore keep track of their books and authors using MySQL. You will use both the MySQL Command Line Interface (CLI) and MySQL Workbench to create and manage the database.
🎯 Goal: Create a database called bookstore with two tables: authors and books. Add some sample data using MySQL CLI commands and then connect to the database using MySQL Workbench to view the tables.
📋 What You'll Learn
Create a database named bookstore using MySQL CLI
Create an authors table with columns author_id (primary key) and name
Create a books table with columns book_id (primary key), title, and author_id (foreign key)
Insert exactly two authors into the authors table
Insert exactly three books into the books table with correct author_id references
Use MySQL Workbench to connect to the bookstore database and verify the tables and data
💡 Why This Matters
🌍 Real World
Bookstores and many businesses use databases to keep track of products, customers, and transactions.
💼 Career
Knowing how to create and manage databases with MySQL CLI and Workbench is a key skill for database administrators and backend developers.
Progress0 / 4 steps
1
Create the bookstore database
Use the MySQL CLI to create a database called bookstore by typing the command CREATE DATABASE bookstore;
MySQL
Need a hint?

Remember to end your SQL command with a semicolon ;.

2
Create the authors and books tables
Write the SQL commands to create the authors table with columns author_id as an integer primary key and name as a VARCHAR(100), and the books table with columns book_id as an integer primary key, title as VARCHAR(100), and author_id as an integer foreign key referencing authors.author_id. Use the commands CREATE TABLE authors (...); and CREATE TABLE books (...);
MySQL
Need a hint?

Use USE bookstore; to select the database before creating tables.

3
Insert sample data into authors and books
Insert two authors into the authors table with author_id 1 and 2 and names 'Jane Austen' and 'Mark Twain'. Then insert three books into the books table with book_id 1, 2, 3, titles 'Pride and Prejudice', 'Emma', and 'Adventures of Huckleberry Finn', and correct author_id references (1 for Jane Austen's books, 2 for Mark Twain's book). Use INSERT INTO authors (...) VALUES (...); and INSERT INTO books (...) VALUES (...); commands.
MySQL
Need a hint?

Each INSERT command must end with a semicolon ;.

4
Connect and verify data in MySQL Workbench
Open MySQL Workbench and connect to your MySQL server. Select the bookstore database from the left panel. Use the GUI to view the authors and books tables and verify that the data you inserted is visible.
MySQL
Need a hint?

Use MySQL Workbench's left sidebar to find the bookstore database and click on tables to see the data.