database lab manual
database lab manual
For
Database Administration and Management
Here are six different database practical tools you can use for hands-on exercises:
Selected Software
Our group decided to select MySQL Workbench over other software options
because of its comprehensive tools, ease of use, and ability to streamline database
design and management.
Practical 2
Installation Of Software
• Once the download is complete, locate the .msi installer file in your
downloads folder and double-click to run it.
• If prompted by Windows User Account Control, click Yes to allow the
installation.
• The MySQL installer will launch and ask for the setup type. You can select
from:
o Developer Default (recommended, as it installs MySQL Server,
MySQL Workbench, MySQL Shell, and other components).
o Server Only, Client Only, or Full depending on what you need.
• For most users, Developer Default is the best option because it includes
MySQL Server, MySQL Workbench, and other useful tools.
• Click Next.
4. Check Prerequisites
• The installer will check if your system has the required software (such as
Visual Studio Tools and Microsoft Redistributables). If any are missing, the
installer will offer to download and install them.
• Ensure that everything is checked off before proceeding. Click Next.
• The installer will list the products to be installed. Make sure MySQL
Workbench is selected, and then click Execute to begin the installation.
• Wait while the installer downloads and installs the necessary components.
6. Configuration
• After the installation is complete, the MySQL installer will prompt you to
configure MySQL Server. If you don't already have MySQL Server installed,
you can install it now using the installer, or connect to an existing server.
• Set a root password for MySQL Server (ensure it’s a strong password).
• You can choose the default settings or customize the installation path and
other configurations if desired.
7. Complete Installation
• When MySQL Workbench opens for the first time, you need to configure a
connection to a MySQL server.
• Click the + icon next to MySQL Connections.
• Enter a Connection Name, set Hostname to localhost (or the IP of your
server), and input the root username and the password you set earlier.
• Click Test Connection to ensure everything is working. If successful, click
OK to save the connection.
• Now you can start managing your MySQL databases via MySQL Workbench.
You can run SQL queries, manage databases, and perform other tasks.
Practical 3
Database Design
USE Librarymanagementsystem_db;
Step 3: Create Table for Books, Members, Staff, Publishers and Transactions Details.
CREATE TABLE Books (BookID INT PRIMARY KEY, Title VARCHAR (255) NOT NULL,
Author VARCHAR (255), Publisher VARCHAR (100),YearPublished YEAR, Quantity INT
NOT NULL);
CREATE TABLE Members (MemberID INT PRIMARY KEY, Name VARCHAR (255) NOT
NULL, ContactNumber VARCHAR (15),MembershipDate DATE NOT NULL);
CREATE TABLE Publisher (Publisher_ID INT PRIMARY KEY, Name VARCHAR (255)
NOT NULL, Address TEXT,Contact_Number VARCHAR (15));
Step 4: Inserting Values into All Tables.
VALUES (1, 'Al-Qur'an', 'Multiple Authors', 'Islamic Publishers',1992,610), (2, 'Hadith of the
Prophet', 'Imam Bukhari', 'Darussalam',2010,35), (3, 'The Life of Muhammad', 'Muhammad
Husayn Haykal', 'Islamic Book Trust',1960,50);
VALUES(1,'Ali','1234567890','2023-01-10'),(2, 'Fatima','9876543210','2023-03-12'),(3,
'Omar','5555555555', '2023-05-15'); INSERT INTO Transactions (TransactionID, MemberID,
BookID, IssueDate, ReturnDate) VALUES(1, 1, 1, '2023-09-01', '2023-09-15'), (2, 2, 2, '2023-
10-01', '2023-10-15'),(3, 3, 3, '2023-11-10', '2023-11-24');
VALUES (1, 'Zainab Ali', 'Librarian', 3000.00, 'Morning'),(2, 'Khalid Ahmed', 'Assistant',2500.00,
'Evening'),(3, 'Sara Tariq', 'Admin', 3500.00, 'Full-time');
VALUES (1, 'Islamic Publishers', 'Al-Nour St, Riyadh, KSA', '+966-11-2345678'),(2, 'Darussalam',
'Makkah, Saudi Arabia', '+966-12-1234567'), (3, 'Islamic Book Trust', 'Karachi, Pakistan', '+92-
21-5678901');
USE UniversityManagement;
USE ECommerceDB;
First, we connect to the database using the appropriate credentials and connection
details before executing any SQL queries. We connect with
UniversitymanagementDB.
Once connected to the database, we apply the query to retrieve or modify the data
as needed.
First, we connect to the database using the appropriate credentials and connection
details before executing any SQL queries. We connect with
UniversitymanagementDB.
Once connected to the database, we apply the query to retrieve or modify the data
as needed.
4.3 Write SQL queries to perform CRUD (Create, Read, Update, Delete)
operations.
Once connected to the database, we apply the query to retrieve or modify the data
as needed.
First, we connect to the database using the appropriate credentials and connection
details before executing any SQL queries. We connect with
UniversitymanagementDB.
Step 2:
Step 3:
Step 4:
Step 5:
Step 6: