DATABASE MANAGEMENT SYSTEM PRACTICAL SAMPLES, Lecture notes of Database Management Systems (DBMS)

DATABASE MANAGEMENT SYSTEM PRACTICAL SAMPLES consist of MySQL practical

Typology: Lecture notes

2022/2023

Available from 06/17/2026

emmanuel-ondako
emmanuel-ondako 🇰🇪

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
DATABASE MANAGEMENT SYSTEM PRACTICAL SAMPLES
This document contains practical Database Management System (DBMS) sample questions and detailed answers.
The practicals are designed to help students understand how to create, manipulate, test, and secure databases using
SQL and DBMS concepts.
Practical 1: Creating a Database
Question:
Create a database called SchoolDB. SQL Command:
CREATE DATABASE SchoolDB; Explanation:
This command creates a new database named SchoolDB where tables and records can be stored.
Practical 2: Creating a Table
Question:
Create a table named Students with the following fields: StudentID Name Course Age SQL Command:
CREATE TABLE Students ( StudentID INT PRIMARY KEY, Name VARCHAR(50), Course
VARCHAR(50), Age INT ); Explanation:
The CREATE TABLE command is used to define table structure. PRIMARY KEY uniquely identifies each student.
Practical 3: Inserting Data into a Table
Question:
Insert records into the Students table. SQL Command:
INSERT INTO Students (StudentID, Name, Course, Age) VALUES (1, 'John', 'Computer
Science', 20), (2, 'Mary', 'Business IT', 22); Explanation:
The INSERT command adds new records into the table.
Practical 4: Retrieving Data
Question:
Display all records from the Students table. SQL Command:
SELECT * FROM Students; Explanation:
SELECT retrieves data from the database. The asterisk (*) means all columns.
Practical 5: Updating Records
Question:
Update Mary's course to Information Technology. SQL Command:
UPDATE Students SET Course = 'Information Technology' WHERE StudentID = 2; Explanation:
UPDATE modifies existing records in a table.
Practical 6: Deleting Records
Question:
Delete the student with StudentID 1. SQL Command:
DELETE FROM Students WHERE StudentID = 1; Explanation:
pf3

Partial preview of the text

Download DATABASE MANAGEMENT SYSTEM PRACTICAL SAMPLES and more Lecture notes Database Management Systems (DBMS) in PDF only on Docsity!

DATABASE MANAGEMENT SYSTEM PRACTICAL SAMPLES

This document contains practical Database Management System (DBMS) sample questions and detailed answers. The practicals are designed to help students understand how to create, manipulate, test, and secure databases using SQL and DBMS concepts.

Practical 1: Creating a Database

Question: Create a database called SchoolDB. SQL Command: CREATE DATABASE SchoolDB; Explanation: This command creates a new database named SchoolDB where tables and records can be stored.

Practical 2: Creating a Table

Question: Create a table named Students with the following fields: StudentID Name Course Age SQL Command: CREATE TABLE Students ( StudentID INT PRIMARY KEY, Name VARCHAR(50), Course VARCHAR(50), Age INT ); Explanation: The CREATE TABLE command is used to define table structure. PRIMARY KEY uniquely identifies each student.

Practical 3: Inserting Data into a Table

Question: Insert records into the Students table. SQL Command: INSERT INTO Students (StudentID, Name, Course, Age) VALUES (1, 'John', 'Computer Science', 20), (2, 'Mary', 'Business IT', 22); Explanation: The INSERT command adds new records into the table.

Practical 4: Retrieving Data

Question: Display all records from the Students table. SQL Command: SELECT * FROM Students; Explanation: SELECT retrieves data from the database. The asterisk (*) means all columns.

Practical 5: Updating Records

Question: Update Mary's course to Information Technology. SQL Command: UPDATE Students SET Course = 'Information Technology' WHERE StudentID = 2; Explanation: UPDATE modifies existing records in a table.

Practical 6: Deleting Records

Question: Delete the student with StudentID 1. SQL Command: DELETE FROM Students WHERE StudentID = 1; Explanation:

DELETE removes records from a table.

Practical 7: Using WHERE Clause

Question: Display students whose age is greater than 20. SQL Command: SELECT * FROM Students WHERE Age > 20; Explanation: WHERE filters records according to a condition.

Practical 8: Database Relationships

Question: Create two related tables: Students and Fees. SQL Command: CREATE TABLE Fees ( FeeID INT PRIMARY KEY, StudentID INT, Amount DECIMAL(10,2), FOREIGN KEY (StudentID) REFERENCES Students(StudentID) ); Explanation: FOREIGN KEY creates a relationship between tables.

Practical 9: Database Testing

Question: Explain how database testing is performed. Answer: Database testing checks whether: Data is stored correctly Relationships work properly Constraints are enforced Queries produce correct results Example test: INSERT INTO Students VALUES (1, NULL, 'IT', 20); This test checks if NULL values are allowed.

Practical 10: Transactions

Question: Write SQL commands showing a transaction. SQL Command: BEGIN TRANSACTION; UPDATE Accounts SET Balance = Balance - 500 WHERE AccountID = 1; UPDATE Accounts SET Balance = Balance + 500 WHERE AccountID = 2; COMMIT; Explanation: Transactions ensure all operations are completed successfully together.

Practical 11: Database Security

Question: Explain ways of securing a database. Answer: Database security can be improved using: Passwords and authentication User privileges Encryption Regular backups Firewalls Example: GRANT SELECT ON Students TO User1; This command gives User1 permission to read records.

Practical 12: Backup and Recovery

Question: Why is backup important in DBMS? Answer: Backups help recover lost data after: System failure Virus attacks Accidental deletion Hardware damage Regular backups ensure business continuity.