KY SQL
SQL Basic Interview Questions (English + Hinglish)
✅1. What is SQL?
SQL (Structured Query Language) is used to manage and interact with databases.
Hinglish:
SQL ek language hai jo database ke data ko manage karne ke liye use hoti hai.
✅2. What is a Database?
A database is a collection of organized data.
Hinglish:
Database ek jagah hoti hai jahan structured data store hota hai.
✅3. What is a Table?
A table stores data in rows and columns.
Hinglish:
Table rows aur columns me data store karti hai.
Example:
idnamecity1RahulJaipur
✅4. What is a Primary Key?
A Primary Key uniquely identifies each row in a table.
Hinglish:
Primary Key har row ko unique banati hai.
id SERIAL PRIMARY KEY✅5. What is a Foreign Key?
A Foreign Key creates a relationship between two tables.
Hinglish:
Foreign Key do tables ko connect karti hai.
teacher_id INT REFERENCES teachers(id)✅6. Difference between SQL and PostgreSQL/MySQL?
- SQL is a language.
- PostgreSQL and MySQL are database management systems.
Hinglish:
SQL ek language hai, aur PostgreSQL/MySQL databases hain jo SQL use karte hain.
✅7. What does SELECT query do?
SELECT is used to fetch data.
SELECT * FROM users;Hinglish:
SELECT database se data nikalne ke liye use hoti hai.
✅8. What is WHERE clause?
WHERE is used to apply conditions.
SELECT * FROM users
WHERE city = 'Jaipur';Hinglish:
WHERE condition lagane ke liye use hota hai.
✅9. What is ORDER BY?
ORDER BY is used for sorting data.
SELECT * FROM users
ORDER BY name ASC;Hinglish:
ORDER BY data ko ascending ya descending order me sort karta hai.
✅10. What is GROUP BY?
GROUP BY groups same values together.
SELECT city, COUNT(*)
FROM users
GROUP BY city;Hinglish:
GROUP BY same data ko group karta hai.
✅11. What does COUNT() do?
COUNT() returns total number of rows.
SELECT COUNT(*) FROM users;Hinglish:
COUNT total rows count karta hai.
✅12. What is INNER JOIN?
INNER JOIN returns matching data from both tables.
SELECT teachers.name, students.name
FROM teachers
INNER JOIN students
ON teachers.id = students.teacher_id;Hinglish:
INNER JOIN dono tables ka matching data return karta hai.
✅13. What is LEFT JOIN?
LEFT JOIN returns all data from left table and matching data from right table.
SELECT *
FROM teachers
LEFT JOIN students
ON teachers.id = students.teacher_id;Hinglish:
LEFT JOIN left table ka sara data dikhata hai even if match na ho.
✅14. What is INSERT query?
INSERT is used to add new data.
INSERT INTO users(name, city)
VALUES('Rahul', 'Jaipur');Hinglish:
INSERT database me naya data add karta hai.
✅15. What is UPDATE query?
UPDATE modifies existing data.
UPDATE users
SET city = 'Delhi'
WHERE id = 1;Hinglish:
UPDATE existing data change karta hai.
✅16. What is DELETE query?
DELETE removes data from a table.
DELETE FROM users
WHERE id = 1;Hinglish:
DELETE data remove karta hai.
✅17. Difference between DELETE and DROP?
- DELETE removes rows
- DROP removes entire table
Hinglish:
DELETE sirf data hataata hai, DROP poori table delete karta hai.
✅18. What is NULL?
NULL means no value.
Hinglish:
NULL ka matlab value available nahi hai.
✅19. What is UNIQUE constraint?
UNIQUE prevents duplicate values.
email VARCHAR(100) UNIQUEHinglish:
UNIQUE duplicate values ko rokta hai.
✅20. What is NOT NULL?
NOT NULL prevents empty values.
name VARCHAR(100) NOT NULLHinglish:
NOT NULL field ko empty hone se rokta hai.
✅21. What is Normalization?
Normalization is a process of organizing data in database tables to reduce data duplication and improve data consistency.
Get Rahul Jingar’s stories in your inbox
Join Medium for free to get updates from this writer.
Hinglish:
Normalization ka use duplicate data ko remove karne aur database ko properly organize karne ke liye hota hai.
Interview Line:
“Normalization improves database structure and reduces redundancy.”
✅22. What are Relations?
Relations means connection between tables using keys.
Hinglish:
Relations ka matlab tables ke beech connection banana.
✅23. What is Indexing?
Indexing improves query performance and makes searching faster.
Hinglish:
Index database me searching fast karta hai.
Interview Answer
“Indexing improves SELECT query performance but too many indexes can slow INSERT and UPDATE operations.”
✅24. What are Transactions?
Transaction is a group of SQL queries executed together.
Hinglish:
Transaction multiple queries ka group hota hai jo ek saath execute hota hai.
Transaction Commands
BEGIN
BEGIN;COMMIT
Save changes permanently.
COMMIT;ROLLBACK
Undo changes if error occurs.
ROLLBACK;ACID Properties
A → Atomicity
Either all queries run or none.
C → Consistency
Database valid state me rehna chahiye.
I → Isolation
Transactions ek dusre ko affect nahi karte.
D → Durability
Committed data permanently save hota hai.
✅25. What is Pagination?
Pagination large data ko small parts/pages me divide karta hai.
OR
Pagination improves performance and user experience by loading limited data at a time.
Hinglish:
Pagination ka use large records ko page-wise dikhane ke liye hota hai.
OR
Example
- Page 1 → 10 records
- Page 2 → next 10 records
PostgreSQL Pagination Query
SELECT * FROM users
LIMIT 10 OFFSET 0;Explanation
- LIMIT → kitne records chahiye
- OFFSET → kitne skip karne hain
✅26. Why do we use normalization?
To reduce duplicate data and improve consistency.
✅27. Which relation is mostly used?
One-to-Many relation is most commonly used.
✅28. Why use indexing?
To improve query search speed.
✅29. Why are transactions important?
To maintain data integrity.
✅30. Why use pagination?
To efficiently handle large datasets and improve performance.
Practical Interview Questions
✅31. Find all users from Jaipur
SELECT * FROM users
WHERE city = 'Jaipur';✅32. Find highest salary
SELECT MAX(salary)
FROM employees;✅33. Count total students
SELECT COUNT(*)
FROM students;✅34. Find duplicate emails
SELECT email, COUNT(*)
FROM users
GROUP BY email
HAVING COUNT(*) > 1;✅35. Find second highest salary
SELECT MAX(salary)
FROM employees
WHERE salary < (
SELECT MAX(salary)
FROM employees
);PostgreSQL Interview Questions
✅36. What is SERIAL in PostgreSQL?
SERIAL is an auto-increment integer.
id SERIAL PRIMARY KEY✅37. How do you connect PostgreSQL with Node.js?
Using pg package.
npm install pgconst { Client } = require("pg");✅38. What is ORM?
ORM helps interact with database using objects instead of raw SQL.
hinglish
ORM database ke data ko objects ke form me deta hai bina direct SQL likhe.
Examples:
- Prisma ORM
- Sequelize





