

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
DATABASE MANAGEMENT SYSTEM PRACTICAL SAMPLES consist of MySQL practical
Typology: Lecture notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


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.
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.
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.
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.
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.
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.
Question: Delete the student with StudentID 1. SQL Command: DELETE FROM Students WHERE StudentID = 1; Explanation:
DELETE removes records from a table.
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.
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.
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.
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.
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.
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.