Database_1
DATABASE &
TABLE CONCEPTS
MCQ 1: Purpose of CREATE DATABASE
What is the purpose of the following command?
CREATE DATABASE IF NOT EXISTS animaldb;
A. Creates a new database named animaldb only if it does not
already exist
B. Deletes the existing database named animaldb
✅ Correct Answer: A
MCQ 2: Purpose of USE
What does the USE animaldb; command do?
A. Deletes the animaldb database
B. Selects animaldb as the active database for subsequent queries
✅ Correct Answer: B
MCQ 3: Purpose of DROP TABLE IF EXISTS
Why is this command used before creating a table?
DROP TABLE IF EXISTS animals;
A. To remove the table if it already exists and avoid errors
B. To permanently lock the table for editing
✅ Correct Answer: A
MCQ 4: AUTO_INCREMENT and PRIMARY KEY
What is the role of id INT AUTO_INCREMENT PRIMARY KEY?
A. Automatically generates a unique identifier for each record
B. Allows duplicate values in the id column
✅ Correct Answer: A
MCQ 5: NOT NULL Constraint
What does NOT NULL ensure in a column definition?
A. The column must always contain a value
B. The column can store duplicate values
✅ Correct Answer: A
MCQ 6: ENUM Data Type
What is the purpose of using ENUM('Male','Female')?
A. To restrict the column values to predefined options
B. To allow any text value in the column
✅ Correct Answer: A
MCQ 7: DEFAULT Keyword
What does DEFAULT 'Available' mean in a column
definition?
A. The column will automatically get this value if none is provided
B. The column value cannot be changed later
✅ Correct Answer: A
MCQ 8: FOREIGN KEY with ON DELETE CASCADE
What happens when a record in animals is deleted?
A. Related records in animal_images are automatically deleted
B. The delete operation is blocked
✅ Correct Answer: A
MCQ 9: Purpose of INSERT INTO
What is the main function of the INSERT INTO statement?
A. To add new records into a table
B. To modify existing records
✅ Correct Answer: A
MCQ 10: Purpose of COMMIT
Why is the COMMIT; statement used?
A. To permanently save the changes made in the transaction
B. To undo all database changes
✅ Correct Answer: A
MCQ 11: SELECT * Statement
What does the following command do?
SELECT * FROM animals;
A. Displays all columns and rows from the animals table
B. Deletes all records from the animals table
✅ Correct Answer: A
MCQ 12: TIMESTAMP with DEFAULT CURRENT_TIMESTAMP
What is the purpose of this column definition?
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
A. Automatically stores the date and time when a record is
created
B. Requires the user to manually enter date and time
✅ Correct Answer: A
MCQ 13: Purpose of IF NOT EXISTS
Why is IF NOT EXISTS used in CREATE statements?
A. To prevent errors if the database or table already exists
B. To force recreation every time
✅ Correct Answer: A
MCQ 14: Database vs Table
What is the correct relationship between a database and a
table?
A. A database contains tables
B. A table contains databases
✅ Correct Answer: A
MCQ 15: Effect of DROP TABLE
What happens when DROP TABLE animals; is executed?
A. The table structure and all its data are permanently deleted
B. Only the data is deleted, table structure remains
✅ Correct Answer: A
DATA TYPES & STORAGE
MCQ 16: Purpose of VARCHAR
Why is VARCHAR used instead of CHAR for name columns?
A. It stores variable-length strings and saves space
B. It stores fixed-length strings only
✅ Correct Answer: A
MCQ 17: TEXT vs VARCHAR
Why is temperament defined as TEXT instead of VARCHAR(100)?
A. TEXT can store longer descriptions
B. TEXT stores only numeric values
✅ Correct Answer: A
MCQ 18: INT DEFAULT 0
What is the purpose of DEFAULT 0 in numeric columns?
A. Assigns 0 when no value is provided
B. Prevents the column from storing numbers
✅ Correct Answer: A
CONSTRAINTS & KEYS
MCQ 19: PRIMARY KEY Concept
Why is a PRIMARY KEY important?
A. It uniquely identifies each record in a table
B. It allows duplicate rows
✅ Correct Answer: A
MCQ 20: FOREIGN KEY Purpose
What is the main purpose of a FOREIGN KEY?
A. To enforce a relationship between two tables
B. To store duplicate values
✅ Correct Answer: A
MCQ 21: One-to-Many Relationship
What type of relationship exists between animals and animal_images?
A. One animal can have many images
B. One image can have many animals
✅ Correct Answer: A
MCQ 22: Referential Integrity
Which concept ensures that animal_id in animal_images
must exist in animals?
A. Referential integrity
B. Data redundancy
✅ Correct Answer: A
MCQ 23: ON DELETE CASCADE
What problem does ON DELETE CASCADE solve?
A. Prevents orphan records in child tables
B. Prevents deletion of parent records
✅ Correct Answer: A
DATA MANIPULATION (DML)
MCQ 24: INSERT Statement Design
Why is one INSERT used per record in this script?
A. Makes the script clearer and easier to debug
B. Improves query execution speed
✅ Correct Answer: A
MCQ 25: Column Order in INSERT
Why are column names specified in the INSERT statement?
A. To ensure values match the correct columns
B. It is mandatory for all INSERT statements
✅ Correct Answer: A
MCQ 26: Missing Column Values
What happens if a column with a DEFAULT value is omitted
in INSERT?
A. The default value is automatically used
B. The INSERT fails
✅ Correct Answer: A
TRANSACTIONS & CONTROL
MCQ 27: Transaction Concept
What is a transaction in SQL?
A. A group of SQL statements executed as a single unit
B. A single SELECT statement
✅ Correct Answer: A
MCQ 28: COMMIT vs ROLLBACK
What does COMMIT do in a transaction?
A. Saves all changes permanently
B. Reverses all changes
✅ Correct Answer: A
USERS & SECURITY CONCEPTS
MCQ 29: Password Storage (Conceptual)
Why are plaintext passwords unsafe in real applications?
A. They can be easily read if the database is compromised
B. They improve login speed
✅ Correct Answer: A
MCQ 30: Hashing Best Practice
What is the recommended way to store passwords?
A. Store hashed passwords
B. Store encrypted plaintext passwords
✅ Correct Answer: A
TIMESTAMP & SYSTEM GENERATED VALUES
MCQ 31: Automatic Time Tracking
Why is CURRENT_TIMESTAMP useful in tables like contacts?
A. Automatically records when data is inserted
B. Allows manual date entry only
✅ Correct Answer: A
MCQ 32: Audit Columns
Columns like created_at are mainly used for:
A. Tracking and auditing data changes
B. Sorting alphabetically
✅ Correct Answer: A
EXAM-FOCUSED APPLICATION QUESTIONS
MCQ 33: Data Consistency
Which feature ensures every image belongs to a valid
animal?
A. Foreign key constraint
B. AUTO_INCREMENT
✅ Correct Answer: A
MCQ 34: Table Design Choice
Why is animal images stored in a separate table?
A. To support multiple images per animal
B. To reduce the number of records
✅ Correct Answer: A
MCQ 35: SELECT * Usage
Why is SELECT * not recommended in large production
systems?
A. It retrieves unnecessary data and affects performance
B. It causes syntax errors
✅ Correct Answer: A
QUICK REVISION (VERY COMMON EXAM QUESTIONS)
MCQ 36:
DDL commands are used to:
A. Define or modify database structure
B. Insert and update data
✅ Correct Answer: A
MCQ 37:
DML commands are used to:
A. Insert, update, and retrieve data
B. Create databases
✅ Correct Answer: A
MCQ 38:
Which of the following is a DDL command?
A. CREATE TABLE
B. INSERT INTO
✅ Correct Answer: A
MCQ 39:
Which command is used to retrieve data from a table?
A. SELECT
B. DROP
✅ Correct Answer: A
MCQ 40:
Which constraint prevents duplicate primary key values?
A. PRIMARY KEY
B. DEFAULT
✅ Correct Answer: A
⭐ VERY IMPORTANT (HIGH FREQUENCY)
1. What is the purpose of CREATE DATABASE IF NOT EXISTS?
Answer:
Prevents an error by creating the database only if it does not already exist.
2. What is the use of the USE command in SQL?
Answer:
Selects the active database for executing subsequent SQL statements.
3. What does DROP TABLE IF EXISTS do?
Answer:
Deletes the table if it exists, avoiding errors when re-running the script.
4. Define PRIMARY KEY. Why is it used?
Answer:
A PRIMARY KEY uniquely identifies each record in a table and does not allow
NULL or duplicate values.
5. What is the purpose of AUTO_INCREMENT?
Answer:
Automatically generates a unique value for each new record.
6. What is the use of NOT NULL constraint?
Answer:
Ensures that a column cannot have NULL (empty) values.
⭐ DATA TYPES & CONSTRAINTS
(VERY COMMON)
7. What is ENUM? Give its use.
Answer:
ENUM restricts a column to a fixed set of predefined values.
8. What is the difference between VARCHAR and TEXT?
Answer:
VARCHAR stores limited-length strings, while TEXT stores longer text data.
9. What is the use of DEFAULT in a column?
Answer:
Assigns a default value when no value is provided during insertion.
10. What happens if a value is not provided for a column
with DEFAULT?
Answer:
The default value is automatically inserted.
⭐ RELATIONSHIPS & KEYS
(EXTREMELY IMPORTANT)
11. What is a FOREIGN KEY?
Answer:
A FOREIGN KEY is used to link two tables and enforce referential integrity.
12. What is referential integrity?
Answer:
It ensures that foreign key values always refer to existing primary key values.
13. What is the purpose of ON DELETE CASCADE?
Answer:
Automatically deletes related records in the child table when a parent record
is deleted.
14. What type of relationship exists between animals and animal_images
tables?
Answer:
One-to-many relationship.
15. Why are images stored in a separate table?
Answer:
To allow multiple images to be associated with a single animal.
⭐ DML COMMANDS (HIGH PROBABILITY)
16. What is the use of INSERT INTO?
Answer:
Used to add new records into a table.
17. Why are column names specified in INSERT statements?
Answer:
To ensure values are inserted into the correct columns.
18. What does SELECT * do?
Answer:
Retrieves all columns and all rows from a table.
⭐ TRANSACTIONS (COMMON THEORY
QUESTION)
19. What is a transaction in SQL?
Answer:
A transaction is a group of SQL statements executed as a single unit.
20. What is the purpose of COMMIT?
Answer:
Permanently saves all changes made during a transaction.
⭐ SECURITY & BEST PRACTICES
(SHORT THEORY)
21. Why should passwords not be stored in plaintext?
Answer:
They can be easily read if the database is compromised.
22. What is the recommended method for storing passwords?
Answer:
Store hashed passwords.
⭐ TIMESTAMP & SYSTEM VALUES
(COMMON SHORT Q)
23. What is the use of CURRENT_TIMESTAMP?
Answer:
Automatically stores the current date and time when a record is inserted.
24. Why is created_at important in a table?
Answer:
It helps track when records were created (audit purposes).
⭐ CLASSIFICATION QUESTIONS (VERY
LIKELY)
25. Define DDL commands with one example.
Answer:
DDL commands define database structure (e.g., CREATE TABLE).
26. Define DML commands with one example.
Answer:
DML commands manipulate data (e.g., INSERT INTO).
27. Which SQL command is used to retrieve data?
Answer:
SELECT
28. Which constraint ensures uniqueness of records?
Answer:
PRIMARY KEY
Below is a THOROUGH PRACTICE TEST designed for basic
SQL mastery, using simple tables (1–2 columns only) while still
testing all the important features you studied:
DDL, DML, constraints, keys, relationships, DEFAULT, ENUM, transactions, and
SELECT.
This is ideal for exam practice and hands-on
revision.
📝 BASIC SQL PRACTICE TEST
Topic: SQL Fundamentals (DDL, DML, Constraints,
Transactions)
Instructions:
- Answer
all questions
- Assume
MySQL syntax
- Write
SQL queries where required
SECTION A: MULTIPLE CHOICE QUESTIONS (1 MARK EACH)
Q1. Which command is used to create a database?
A. CREATE DATABASE
B. CREATE TABLE
Q2. What does the USE command do?
A. Selects the active database
B. Deletes the database
Q3. Which command removes a table completely?
A. DROP TABLE
B. DELETE TABLE
Q4. Which constraint ensures that a column cannot have
NULL values?
A. NOT NULL
B. UNIQUE
Q5. Which constraint uniquely identifies a record?
A. PRIMARY KEY
B. FOREIGN KEY
Q6. What is the purpose of AUTO_INCREMENT?
A. Automatically generates a unique number
B. Allows duplicate values
Q7. Which data type stores variable-length text?
A. VARCHAR
B. INT
Q8. Which command permanently saves changes?
A. COMMIT
B. ROLLBACK
Q9. Which keyword assigns a value automatically when none
is provided?
A. DEFAULT
B. ENUM
Q10. Which command retrieves all rows from a table?
A. SELECT
B. INSERT
SECTION B: WRITE SQL COMMANDS (2 MARKS EACH)
Q11. Create a database named testdb only if it does not
already exist.
Q12. Select the database testdb.
Q13. Create a table students with:
- id
→ integer, primary key, auto increment
- name
→ text, cannot be NULL
Q14. Drop the table students only if it exists.
Q15. Insert a student with name Rahul into the students
table.
SECTION C: CONSTRAINTS & DEFAULT VALUES (3 MARKS)
Q16. Create a table products with:
- id
→ primary key, auto increment
- status
→ ENUM with values Available, Out of Stock
- Default
value should be Available
Q17. Insert a record into products without specifying the
status.
Q18. What value will be stored in the status column?
Explain.
SECTION D: FOREIGN KEY & RELATIONSHIP (3 MARKS)
Q19. Create a table departments with:
- id →
primary key
- name
→ not null
Q20. Create a table employees with:
- id →
primary key
- department_id
→ foreign key referencing departments(id)
- Delete
employees automatically if a department is deleted
Q21. What type of relationship exists between departments
and employees?
SECTION E: DATA RETRIEVAL (2 MARKS)
Q22. Write a query to display all records from products.
Q23. Write a query to display all records from employees.
SECTION F: TRANSACTIONS (2 MARKS)
Q24. What is a transaction?
Q25. Write the SQL command used to save a transaction
permanently.
SECTION G: SHORT THEORY QUESTIONS (1–2 MARKS)
Q26. What is the difference between DELETE and DROP?
Q27. Why is IF NOT EXISTS used in CREATE commands?
Q28. What is referential integrity?
Q29. Why should passwords be stored in hashed form?
Q30. Which SQL command is used to retrieve data from a
table?
⭐ BONUS PRACTICE (OPTIONAL – VERY
IMPORTANT)
Q31. Write a query to display only the name column from students.
Q32. What happens if you insert a NULL value into a NOT
NULL column?
Below is a HANDS-ON SQL LAB VERSION of your practice
test.
This is written exactly like a college / lab-exam worksheet, where
students run commands, observe output, and understand concepts.
You can copy-paste and execute step by step in MySQL
/ MariaDB.
🧪 SQL HANDS-ON LAB
Topic: Basic SQL Commands & Constraints
Objective:
✔ Practice DDL, DML, constraints, keys,
relationships, and transactions
✔ Use simple tables (1–2 columns) for clarity
🔹 PART 1: DATABASE SETUP
Step 1: Create Database
CREATE DATABASE IF NOT EXISTS labdb;
Step 2: Select Database
USE labdb;
🔹 PART 2: TABLE CREATION
(DDL)
Task 1: Create students Table
Features tested: PRIMARY KEY, AUTO_INCREMENT, NOT
NULL
CREATE TABLE students (
id INT
AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT
NULL
);
📌 Observation:
- id
auto-generates values
- name
cannot be NULL
Task 2: View Table Structure
DESC students;
🔹 PART 3: DATA INSERTION
(DML)
Task 3: Insert Records
INSERT INTO students (name) VALUES ('Rahul');
INSERT INTO students (name) VALUES ('Anita');
Task 4: View Records
SELECT * FROM students;
Task 5: Test NOT NULL Constraint
INSERT INTO students (name) VALUES (NULL);
📌 Expected Result:
❌
Error (NOT NULL constraint)
🔹 PART 4: DEFAULT &
ENUM
Task 6: Create products Table
Features tested: ENUM, DEFAULT
CREATE TABLE products (
id INT
AUTO_INCREMENT PRIMARY KEY,
status
ENUM('Available','Out of Stock') DEFAULT 'Available'
);
Task 7: Insert Without Status
INSERT INTO products () VALUES ();
Task 8: View Products
SELECT * FROM products;
📌 Observation:
- status
is automatically set to Available
🔹 PART 5: FOREIGN KEY
& RELATIONSHIP
Task 9: Create departments Table
CREATE TABLE departments (
id INT PRIMARY KEY,
name VARCHAR(50) NOT
NULL
);
Task 10: Create employees Table
Features tested: FOREIGN KEY, ON DELETE CASCADE
CREATE TABLE employees (
id INT PRIMARY KEY,
department_id INT,
FOREIGN KEY
(department_id)
REFERENCES
departments(id)
ON DELETE CASCADE
);
Task 11: Insert Parent Record
INSERT INTO departments VALUES (1, 'IT');
Task 12: Insert Child Record
INSERT INTO employees VALUES (101, 1);
Task 13: View Data
SELECT * FROM departments;
SELECT * FROM employees;
Task 14: Test ON DELETE CASCADE
DELETE FROM departments WHERE id = 1;
SELECT * FROM employees;
📌 Expected Result:
- Employee
record is automatically deleted
🔹 PART 6: TRANSACTIONS
Task 15: Insert Data (Without Commit)
INSERT INTO students (name) VALUES ('Temporary');
Task 16: Rollback Changes
ROLLBACK;
Task 17: Verify Rollback
SELECT * FROM students;
📌 Observation:
- Inserted
record is undone
Task 18: Commit Changes
INSERT INTO students (name) VALUES ('Final Student');
COMMIT;
🔹 PART 7: DATA RETRIEVAL
Task 19: Retrieve All Records
SELECT * FROM students;
Task 20: Retrieve Specific Column
SELECT name FROM students;
🔹 PART 8: CLEANUP
(OPTIONAL)
DROP TABLE IF EXISTS employees;
DROP TABLE IF EXISTS departments;
DROP TABLE IF EXISTS products;
DROP TABLE IF EXISTS students;
✅ LAB LEARNING OUTCOMES
By completing this lab, you have practiced:
✔ CREATE / DROP DATABASE
✔ CREATE / DROP TABLE
✔ PRIMARY KEY & AUTO_INCREMENT
✔ NOT NULL constraint
✔ ENUM & DEFAULT
✔ FOREIGN KEY & ON DELETE CASCADE
✔ INSERT, SELECT, DELETE
✔ COMMIT & ROLLBACK
🎯 EXAM TIP
👉 In practical exams:
- Always
create parent table before child table
- Test
constraints to show understanding
- Use
DESC table_name; to explain structure
Below is a clean, exam-ready comparison list of the MOST
IMPORTANT “X vs Y” SQL questions, written exactly in the format
examiners expect.
Each item includes short, clear answers suitable for 2–5 mark
questions.
1. DROP vs DELETE
|
Feature |
DROP |
DELETE |
|
Type |
DDL command |
DML command |
|
Purpose |
Removes the table completely |
Removes rows from a table |
|
Data |
All data is lost |
Selected or all rows can be removed |
|
Structure |
Table structure is deleted |
Table structure remains |
|
WHERE clause |
❌ Not allowed |
✅ Allowed |
|
Rollback |
❌ Cannot be rolled back |
✅ Can be rolled back (before
COMMIT) |
Example:
DROP TABLE students;
DELETE FROM students WHERE id = 1;
2. VARCHAR vs CHAR
|
Feature |
VARCHAR |
CHAR |
|
Length |
Variable length |
Fixed length |
|
Storage |
Uses only required space |
Uses full allocated space |
|
Performance |
Slightly slower |
Faster |
|
Best for |
Names, addresses |
Fixed-size data (gender, codes) |
Example:
name VARCHAR(50);
gender CHAR(1);
3. DELETE vs TRUNCATE
|
Feature |
DELETE |
TRUNCATE |
|
Type |
DML |
DDL |
|
WHERE clause |
✅ Allowed |
❌ Not allowed |
|
Rollback |
✅ Possible |
❌ Not possible |
|
Speed |
Slower |
Faster |
|
Table structure |
Remains |
Remains |
4. PRIMARY KEY vs FOREIGN KEY
|
Feature |
PRIMARY KEY |
FOREIGN KEY |
|
Purpose |
Uniquely identifies a record |
Links two tables |
|
Duplicate values |
❌ Not allowed |
✅ Allowed |
|
NULL values |
❌ Not allowed |
✅ Allowed |
|
Count per table |
Only one |
Multiple allowed |
5. WHERE vs HAVING
|
Feature |
WHERE |
HAVING |
|
Used with |
Rows |
Groups |
|
Aggregate functions |
❌ Not allowed |
✅ Allowed |
|
Execution |
Before GROUP BY |
After GROUP BY |
6. DDL vs DML
|
Feature |
DDL |
DML |
|
Full form |
Data Definition Language |
Data Manipulation Language |
|
Purpose |
Defines structure |
Manipulates data |
|
Examples |
CREATE, DROP |
INSERT, UPDATE |
|
Rollback |
❌ Not possible |
✅ Possible |
7. INT vs BIGINT
|
Feature |
INT |
BIGINT |
|
Storage |
4 bytes |
8 bytes |
|
Range |
Smaller |
Very large |
|
Usage |
IDs, age |
Large counters |
8. NULL vs NOT NULL
|
Feature |
NULL |
NOT NULL |
|
Meaning |
No value |
Value required |
|
Insert allowed |
Yes |
No |
|
Usage |
Optional fields |
Mandatory fields |
9. DEFAULT vs AUTO_INCREMENT
|
Feature |
DEFAULT |
AUTO_INCREMENT |
|
Purpose |
Assigns a fixed value |
Generates increasing numbers |
|
Used for |
Status, flags |
Primary keys |
|
Manual override |
Allowed |
Usually not |
10. COMMIT vs ROLLBACK
|
Feature |
COMMIT |
ROLLBACK |
|
Purpose |
Saves changes |
Cancels changes |
|
Effect |
Permanent |
Temporary undo |
|
Usage |
End of transaction |
Error handling |
🔑 EXAM TIP (VERY
IMPORTANT)
👉 For “Differentiate
between” questions:
- Draw
table format
- Write
at least 4 points
- Add
one example → guaranteed full marks
Below are PRACTICAL-EXAM VIVA QUESTIONS based
strictly on basic SQL commands, exactly the type examiners ask during
lab viva.
Each question has a short, clear answer that you can memorize and
speak confidently.
🎤 SQL PRACTICAL-EXAM VIVA
QUESTIONS & ANSWERS
🔹 BASIC SQL &
DATABASE
1. What is SQL?
Answer:
SQL (Structured Query Language) is used to create, manage, and manipulate data
in relational databases.
2. What is a database?
Answer:
A database is an organized collection of related data stored electronically.
3. What is the use of CREATE DATABASE?
Answer:
It is used to create a new database.
4. Why do we use the USE command?
Answer:
To select the database on which SQL commands will be executed.
5. What is the difference between database and table?
Answer:
A database contains tables, while a table stores actual data in rows and
columns.
🔹 TABLE & DDL
COMMANDS
6. What is DDL?
Answer:
DDL (Data Definition Language) is used to define or modify database structure.
7. Name any two DDL commands.
Answer:
CREATE, DROP.
8. What does DROP TABLE do?
Answer:
It deletes the table structure along with all data permanently.
9. What is the use of IF NOT EXISTS?
Answer:
It prevents errors if the table or database already exists.
10. What is the difference between DROP and DELETE?
Answer:
DROP removes the table completely, while DELETE removes records from a table.
🔹 DATA TYPES &
CONSTRAINTS
11. What is a data type?
Answer:
A data type defines the kind of value a column can store.
12. What is VARCHAR?
Answer:
VARCHAR stores variable-length character data.
13. Difference between VARCHAR and CHAR?
Answer:
VARCHAR uses variable space, CHAR uses fixed space.
14. What is NOT NULL?
Answer:
It ensures that a column cannot store NULL values.
15. What is DEFAULT?
Answer:
It assigns a default value when no value is provided.
🔹 KEYS &
RELATIONSHIPS (VERY IMPORTANT)
16. What is a PRIMARY KEY?
Answer:
A primary key uniquely identifies each record in a table.
17. Can a table have more than one primary key?
Answer:
No, a table can have only one primary key.
18. What is a FOREIGN KEY?
Answer:
A foreign key is used to link two tables.
19. What is referential integrity?
Answer:
It ensures that foreign key values exist in the parent table.
20. What is ON DELETE CASCADE?
Answer:
It automatically deletes child records when a parent record is deleted.
🔹 DML COMMANDS
21. What is DML?
Answer:
DML (Data Manipulation Language) is used to insert, update, and delete data.
22. Name any two DML commands.
Answer:
INSERT, SELECT.
23. What does INSERT INTO do?
Answer:
It adds new records to a table.
24. What does SELECT * do?
Answer:
It retrieves all rows and columns from a table.
25. What is the use of WHERE clause?
Answer:
It filters records based on a condition.
🔹 TRANSACTIONS (COMMON
VIVA AREA)
26. What is a transaction?
Answer:
A transaction is a group of SQL statements executed as one unit.
27. What is COMMIT?
Answer:
COMMIT permanently saves the changes made.
28. What is ROLLBACK?
Answer:
ROLLBACK undoes changes made before COMMIT.
29. Can DROP be rolled back?
Answer:
No, DROP cannot be rolled back.
🔹 PRACTICAL SCENARIO
QUESTIONS
30. Why should parent tables be created before child
tables?
Answer:
Because foreign keys depend on primary keys of parent tables.
31. What happens if you insert NULL into a NOT NULL
column?
Answer:
An error occurs.
32. Why do we use AUTO_INCREMENT?
Answer:
To automatically generate unique values for primary keys.
33. Why are passwords not stored in plaintext?
Answer:
For security reasons, to prevent misuse if data is leaked.
34. What is ENUM?
Answer:
ENUM restricts a column to a fixed set of values.
35. What is the advantage of using separate tables for
related data?
Answer:
It reduces data redundancy and improves data integrity.
⭐ FINAL VIVA TIPS (VERY
IMPORTANT)
✔ Answer short and confident
✔ Use keywords: “uniquely identifies”,
“referential integrity”, “automatically”
✔ If stuck → explain using example
table names
If you want next:
- 🎯
Top 20 guaranteed viva questions
- 🧠
One-line memory answers
- ⏱
Mock viva (I ask, you answer)
- 📄
Printable viva cheat sheet
Just tell me 👍
Comments
Post a Comment