0% found this document useful (0 votes)
3 views

20134_BA_5

The document outlines a practical experiment for students on installing MySQL and performing various SQL commands, including DDL and DML operations as well as different types of JOINS. It provides step-by-step instructions for downloading, installing, and using MySQL Workbench, along with examples of SQL commands for database management. The learning outcomes include mastering database structure modification and writing complex SQL queries.

Uploaded by

priyanka gami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

20134_BA_5

The document outlines a practical experiment for students on installing MySQL and performing various SQL commands, including DDL and DML operations as well as different types of JOINS. It provides step-by-step instructions for downloading, installing, and using MySQL Workbench, along with examples of SQL commands for database management. The learning outcomes include mastering database structure modification and writing complex SQL queries.

Uploaded by

priyanka gami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Experiment Title 5

Student Name: Priyanka Gami UID: 23MCA20134


Branch: MCA Section/Group 23MCA6-B
Semester: 3rd Date of Performance: 22-09-2024
Subject Name Business Analytics Subject Code: 23CAH-701

1. Aim/Overview of the practical:


a) Installation of Oracle/SQL
b) To perform DDL and DML commands
c) Perform different JOINS.
2. Steps/Algorithm:
Step 1: Download MySQL Installer
1. Visit the MySQL website: Go to the MySQL Downloads page.
2. Choose MySQL Installer: Scroll down and click on the "MySQL Installer for Windows".
3. Download the installer:
o Select the appropriate installer based on your requirements:
 Web Installer (smaller, requires an internet connection during setup).
 Full Installer (larger, contains all MySQL components).
o Click on the desired version and download it.
You may be prompted to create an account, but you can skip this step by clicking No thanks,
just start my download.
Step 2: Run the MySQL Installer
1. Locate the installer: After downloading, run the mysql-installer-web-community or mysql-installer-
community file.
2. Choose Setup Type:
o You’ll be prompted to choose the setup type:
 Developer Default: Installs MySQL Server, MySQL Workbench, and other
development tools.
 Custom: Allows you to choose specific components to install.
For most users, the Developer Default setup is ideal.
Step 3: Install MySQL Components
1. Check for required components: The installer will check if you have any missing dependencies
like Visual Studio or .NET Framework.
o If prompted, allow it to install these components automatically.
2. Select Products and Features: Ensure MySQL Workbench is selected along with MySQL Server
(if needed), then click Next.
3. Begin Installation: Click Execute to begin installing the selected MySQL components. This process
may take a few minutes.
Step 4: Launch MySQL Workbench
1. Complete the installation: Once the components are installed and configured, click Finish.
2. Open MySQL Workbench:
o MySQL Workbench should now be available in your Start Menu or desktop. Launch it.
3. Connect to MySQL Server:
o If you installed MySQL Server, create a new connection:
 Open Workbench and click on New Connection.
 Enter the connection details (hostname, port, username, and password).
 Test the connection and then click OK to save it.
o If you're connecting to an external MySQL server, enter the corresponding credentials.

Step 5: Start Working with MySQL Workbench


You’re now ready to use MySQL Workbench to design databases, write queries, and manage your
MySQL databases.

To perform DDL and DML commands:


DDL Commands:
CREATE DATABASE : creates a new database.
CREATE TABLE : defines a new table with columns.
ALTER TABLE :adds a new column to the table.
DROP: delete the table
DML Commands:
INSERT INTO :inserts rows into the table.
UPDATE : modifies the salary of an employee based on a condition.
SELECT * FROM : retrieves all data from the table.
DELETE FROM : removes a record from the table.

Perform different JOINS.


In MySQL, JOINS are used to combine rows from two or more tables based on a related column
between them. There are several types of joins, including INNER JOIN, LEFT JOIN, RIGHT JOIN, and
FULL JOIN.

INNER JOIN returns only the rows where there is a match in both tables.

SELECT EMPLOYEE.first_name, EMPLOYEE.last_name, DEPARTMENT.department_name

FROM EMPLOYEE

INNER JOIN DEPARTMENT


ON EMPLOYEE.department_id = DEPARTMENT.department_id;

LEFT JOIN returns all rows from the left table (employees), even if there is no match in the right table
(departments). If there is no match, the result is NULL for columns from the right table.

SELECT EMPLOYEE.first_name, EMPLOYEE.last_name, DEPARTMENT.department_name


FROM EMPLOYEE
LEFT JOIN DEPARTMENT
ON EMPLOYEE.department_id = DEPARTMENT.department_id;

RIGHT JOIN is the opposite of LEFT JOIN. It returns all rows from the right table (departments), and
the unmatched rows from the left table (employees) will show NULL.

SELECT EMPLOYEE.first_name, EMPLOYEE.last_name, DEPARTMENT.department_name


FROM EMPLOYEE
LEFT JOIN DEPARTMENT
ON EMPLOYEE.department_id = DEPARTMENT.department_id

FULL OUTER JOIN returns rows when there is a match in either left or right table. If there is no
match, the result is NULL for the missing side.
Since MySQL doesn't support FULL OUTER JOIN natively, you can emulate it by combining LEFT
JOIN and RIGHT JOIN with a UNION.

SELECT EMPLOYEE.first_name, EMPLOYEE.last_name, DEPARTMENT.department_name


FROM EMPLOYEE
LEFT JOIN DEPARTMENT
ON EMPLOYEE.department_id = DEPARTMENT.department_id
UNION
SELECT EMPLOYEE.first_name, EMPLOYEE.last_name, DEPARTMENT.department_name
FROM EMPLOYEE
RIGHT JOIN DEPARTMENT
ON EMPLOYEE.department_id = DEPARTMENT.department_id;

3. Learning Outcomes:
a) We will learn how to navigate and utilize the various tools and features within MySQL Workbench,
including the SQL editor, database modeling, and server management.
b) We will be able to create and modify the structure of databases using Data Definition Language (DDL)
commands such as:
CREATE, ALTER, and DROP (for databases, tables, views, etc.).
c) We will also master Data Manipulation Language (DML) commands to insert, update, and delete
records.
d) We will be able to write complex SQL queries using multiple joins between several tables. You will
understand how to join more than two tables in a single query and retrieve related data from all of them

You might also like