0% found this document useful (0 votes)
36 views8 pages

Unit 1 Record Writing

Uploaded by

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

Unit 1 Record Writing

Uploaded by

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

Ex.

No: 01 MySQL Database Management Commands


Date:
Write the command to create a new database “Your Name”, “REVARBS”, “REVA
Management” and “REVA UNIVERSITY”, and suggest you provide the suitable command for
the following purpose:
Aim:
The aim of this exercise is to demonstrate basic MySQL database management
commands for creating, accessing, and removing databases.
Commands:
1. Create databases:
>>>CREATE DATABASE `Your Name`;
>>>CREATE DATABASE `REVARBS`;
>>>CREATE DATABASE `REVA Management`;
>>>CREATE DATABASE `REVA UNIVERSITY`;
2. To display the list of existing databases:
>>>SHOW DATABASES;
3. To use the database named REVA UNIVERSITY:
>>>USE `REVA UNIVERSITY`;
4. To remove the pre-existing database named REVA Management:
>>>DROP DATABASE `REVA Management`;
5. To make REVARBS the active database:
>>>USE `REVARBS`;
Result:
This set of commands would execute the specified actions in MySQL. It includes
creating databases, displaying existing databases, using a specific database, removing a
database, and switching between databases.
Ex. No: 02 SQL Database Management Exercise: Employee Details
Date:
Write an SQL query to create the table 'Employee_details' in the REVARBS database with the
following structure: Emp_Id, Emp_Name, Department, contact no, email, address, Date of
Joining, Salary
Aim:
The aim of this exercise is to practice SQL queries for creating, altering, and
manipulating a table named 'Employee_details' in the REVARBS database.
Commands:
a. Create table 'Employee_details' with specified structure
>>>CREATE TABLE Employee_details (
Emp_Id INT PRIMARY KEY,
Emp_Name VARCHAR(255),
Department VARCHAR(255),
Contact_No VARCHAR(15),
Email VARCHAR(255),
Address VARCHAR(255),
Date_of_Joining DATE,
Salary DECIMAL(10, 2)
);
b. Display the structure of the table
>>>DESC Employee_details;
c. Add a new column 'appraisal' and display the structure of the table
>>>ALTER TABLE Employee_details ADD COLUMN Appraisal DECIMAL(5, 2);
>>>DESC Employee_details;
d. Calculate the updated salary in a new column 'updated_salary' (Total = salary + appraisal)
>>> update employee_details set total=salary+appraisal;
e. Display the content of the table
>>>SELECT * FROM Employee_details;
Result:
In this SQL exercise, we managed the 'Employee_details' table in the REVARBS
database, performing tasks such as table creation, record addition, structural alterations, salary
updates, and content display.
Ex. No: 03 SQL Database Management Exercise: Customer Details
Date:
Write an SQL query to create the table 'Customer_details' in the REVARBS database with the
following structure: customer_id, first_name, last_name, category, sub_category,
phone_number, city, country, bill_amount.
Aim:
The aim of this exercise is to practice SQL queries for creating, altering, and
manipulating a table named 'Customer_details' in the REVARBS database, focusing on tasks
such as table creation, record addition, structural alterations, and data analysis.
Commands:
a. Create table 'Customer_details' with specified structure and add 10 records
>>>CREATE TABLE Customer_details (
customer_id INT PRIMARY KEY,
first_name VARCHAR(255),
last_name VARCHAR(255),
category VARCHAR(50),
sub_category VARCHAR(50),
phone_number VARCHAR(15),
city VARCHAR(255),
country VARCHAR(255),
bill_amount DECIMAL(10, 2)
);
Inserting 10 records into the 'Customer_details' table
>>>INSERT INTO Customer_details (customer_id, first_name, last_name, category,
sub_category, phone_number, city, country, bill_amount) VALUES
(1, 'John', 'Doe', 'Furniture', 'Chairs', '123-456-7890', 'New York', 'USA', 500.00),
(2, 'Jane', 'Smith', 'Stationery', 'Pen', '456-789-1234', 'London', 'UK', 20.00),
(3, 'Alice', 'Johnson', 'Electronics', 'Laptop', '789-123-4567', 'Tokyo', 'Japan', 1500.00),
(4, 'Bob', 'Williams', 'Furniture', 'Sofa', '321-654-9870', 'Paris', 'France', 800.00),
(5, 'Emily', 'Brown', 'Stationery', 'Notebooks', '654-987-3210', 'Berlin', 'Germany',
30.00),
(6, 'Michael', 'Davis', 'Electronics', 'Mobile', '987-321-6540', 'Sydney', 'Australia',
1000.00),
(7, 'Jessica', 'Wilson', 'Furniture', 'Table', '741-852-9630', 'Toronto', 'Canada', 600.00),
(8, 'David', 'Martinez', 'Stationery', 'Calendar', '852-963-7410', 'Madrid', 'Spain', 15.00),
(9, 'Sarah', 'Taylor', 'Electronics', 'Printer', '963-852-7410', 'Mumbai', 'India', 300.00),
(10, 'James', 'Wilson', 'Furniture', 'SystemTable', '147-258-3690', 'Moscow', 'Russia',
700.00);
b. Display the structure of the table
>>>DESC Customer_details;
c. Add a new column 'Service_Feedback' and display the structure of the table
>>>ALTER TABLE Customer_details ADD COLUMN Service_Feedback
VARCHAR(10);
>>>DESC Customer_details;
d. Find the minimum and maximum Bill_amount from the table
>>> SELECT MIN(bill_amount) AS min_bill_amount, MAX(bill_amount) AS
max_bill_amount FROM Customer_details;
e. Display the first_name and city of customers who have given the feedback as
“Good”
>>> SELECT first_name, city FROM Customer_details WHERE
Service_Feedback = 'Good';
Result:
This query performs various operations on the 'Customer_details' table within the tasks
of the created table, adding the records, alterations made in the structure and analysis.
Ex. No: 04 Management of Flight Details in AAI Database
Date:
Write an SQL query to create the new database in the name of “AAI” and create a table
'Flight_details' with the following structure: flight_id, airline, departure_airport,
arrival_airport, departure_time, arrival_time
Aim:
The aim of this exercise is to demonstrate SQL queries for database creation, table
creation, data insertion, structure alteration, and data manipulation focusing on the
'Flight_details' table within the newly created 'AAI' database.
Commands:
a. Create Database,Table and Insert into 10 Records:
>>> CREATE DATABASE AAI;
>>> USE AAI;
b. Create the Flight_details table
>>> CREATE TABLE Flight_details (
flight_id INT PRIMARY KEY,
airline VARCHAR(50),
departure_airport VARCHAR(50),
arrival_airport VARCHAR(50),
departure_time DATETIME,
arrival_time DATETIME
);
>>> INSERT INTO Flight_details (flight_id, airline, departure_airport, arrival_airport,
departure_time, arrival_time) VALUES
(1, 'Airline1', 'Airport1', 'Airport5', '2024-04-04 08:00:00', '2024-04-04 10:00:00'),
(2, 'Airline2', 'Airport2', 'Airport6', '2024-04-04 09:00:00', '2024-04-04 11:00:00'),
(3, 'Airline3', 'Airport3', 'Airport7', '2024-04-04 10:00:00', '2024-04-04 12:00:00'),
(4, 'Airline4', 'Airport4', 'Airport8', '2024-04-04 11:00:00', '2024-04-04 13:00:00'),
(5, 'Airline5', 'Airport5', 'Airport9', '2024-04-04 12:00:00', '2024-04-04 14:00:00'),
(6, 'Airline6', 'Airport6', 'Airport10', '2024-04-04 13:00:00', '2024-04-04 15:00:00'),
(7, 'Airline7', 'Airport7', 'Airport1', '2024-04-04 14:00:00', '2024-04-04 16:00:00'),
(8, 'Airline8', 'Airport8', 'Airport2', '2024-04-04 15:00:00', '2024-04-04 17:00:00'),
(9, 'Airline9', 'Airport9', 'Airport3', '2024-04-04 16:00:00', '2024-04-04 18:00:00'),
(10, 'Airline10', 'Airport10', 'Airport4', '2024-04-04 17:00:00', '2024-04-04
19:00:00');
c. Display Table Structure:
>>> DESC Flight_details;
d. Remove Departure Time Column:
>>> ALTER TABLE Flight_details DROP COLUMN departure_time;
e. Change Arrival Airport Name:
>>> UPDATE Flight_details SET arrival_airport = 'NewAirport5' WHERE
arrival_airport = 'Airport5';
f. Display Airlines in Alphabetical Order:
>>> SELECT airline FROM Flight_details ORDER BY airline;

Result:
This SQL queries allows for the management of flight details within the 'Flight_details'
table in the 'AAI' database, including database creation, table creation, data insertion, structural
alterations, and data manipulation.
Ex. No: 05 Management of Patient Details in REVA Health Centre Database
Date:
Write an SQL query to create the new database in the name of “REVA_Health_Centre” and
create a table 'Patient_details' with the following structure: patient_id, patient_name, gender,
date_of_birth, place of birth, Contact_No.
Aim:
This exercise aims to demonstrate SQL queries for creating a database named
'REVA_Health_Centre' and a table named 'Patient_details'. We'll perform tasks such as adding
records, altering the table structure by adding a new column, updating existing data, and
displaying specific details.
Commands:
a. Create Database and Table:
>>> CREATE DATABASE REVA_Health_Centre;
>>> USE REVA_Health_Centre;
b. Create the Patient_details table
>>> CREATE TABLE Patient_details (
patient_id INT PRIMARY KEY,
patient_name VARCHAR(100),
gender VARCHAR(10),
date_of_birth DATE,
place_of_birth VARCHAR(100),
Contact_No VARCHAR(15)
);
c. Add 10 Records to the Table:
>>> INSERT INTO Patient_details (patient_id, patient_name, gender,
date_of_birth, place_of_birth, Contact_No) VALUES
(1, 'John Doe', 'Male', '1990-05-15', 'New York', '1234567890'),
(2, 'Jane Smith', 'Female', '1985-08-20', 'Los Angeles', '9876543210'),
(3, 'Michael Johnson', 'Male', '1976-03-10', 'Chicago', '4567890123'),
(4, 'Emily Davis', 'Female', '1999-11-25', 'Houston', '7890123456'),
(5, 'William Brown', 'Male', '1988-07-18', 'Dallas', '2345678901'),
(6, 'Ava Wilson', 'Female', '1995-09-30', 'Miami', '8901234567'),
(7, 'James Taylor', 'Male', '1970-02-05', 'San Francisco', '5678901234'),
(8, 'Olivia Martinez', 'Female', '1983-06-12', 'Seattle', '9012345678'),
(9, 'Ethan Garcia', 'Male', '2002-04-08', 'Denver', '3456789012'),
(10, 'Sophia Rodriguez', 'Female', '1978-12-15', 'Phoenix', '6789012345');
d. Display Table Structure:
>>> DESC Patient_details;
e. Add the Doctor_Name Column:
>>> ALTER TABLE Patient_details ADD Doctor_Name VARCHAR(100);
f. Change the Contact_No of a Particular Patient:
>>> UPDATE Patient_details SET Contact_No = '9988776655' WHERE
patient_id = 1;
g. Display Patient_Name and Doctor_Name Details:
>>> SELECT patient_name, Doctor_Name FROM Patient_details;

Results:
This SQL query allows for the REVA Health Centre database and the Patient_details
table to be successfully created, including the addition of the Doctor_Name column. Contact
numbers for specific patients were updated, and patient names along with Doctor_Name details
were displayed.

You might also like