1️⃣ What is a Database?
A: A structured collection of data stored electronically. Examples: MySQL, MongoDB, PostgreSQL.
2️⃣ Difference between SQL and NoSQL
- SQL: Relational, structured tables, uses schemas, supports ACID transactions.
- NoSQL: Non-relational, flexible schema, document/graph/column storage, scalable.
3️⃣ What is a Primary Key?
A: Unique identifier for a record in a table. Example:
id column in Users table. 4️⃣ What is a Foreign Key?
A: A field in one table that refers to the primary key of another table to maintain relationships.
5️⃣ CRUD Operations
- Create:
INSERT INTO table_name ... - Read:
SELECT * FROM table_name ... - Update:
UPDATE table_name SET ... WHERE ... - Delete:
DELETE FROM table_name WHERE ... 6️⃣ What is Indexing?
A: A performance optimization technique to speed up data retrieval. Types: B-Tree, Hash indexes.
7️⃣ What is Normalization?
A: Process of organizing tables to reduce redundancy and improve data integrity. Forms: 1NF, 2NF, 3NF, BCNF.
8️⃣ What is Denormalization?
A: Combining tables or duplicating data to improve read performance at the cost of redundancy.
9️⃣ ACID Properties
- Atomicity: All or nothing transaction
- Consistency: Database remains valid
- Isolation: Transactions don’t interfere
- Durability: Committed changes persist
🔟 Difference between JOIN types
- INNER JOIN: Only matching rows
- LEFT JOIN: All left + matching right rows
- RIGHT JOIN: All right + matching left rows
- FULL OUTER JOIN: All rows from both tables
1️⃣1️⃣ What is a NoSQL Database?
A: Database designed for large-scale, unstructured, or semi-structured data. Types: Document (MongoDB), Key-Value (Redis), Column (Cassandra), Graph (Neo4j).
1️⃣2️⃣ What is a Transaction?
A: A set of SQL operations executed as a single unit of work. Either all succeed or all fail.
1️⃣3️⃣ Difference between DELETE and TRUNCATE
- DELETE: Row-by-row, can use WHERE, slower, logs each row.
- TRUNCATE: Removes all rows, faster, cannot use WHERE, resets auto-increment.
1️⃣4️⃣ What is a View?
A: A virtual table representing a stored query. Useful for abstraction, security, and complex queries.
1️⃣5️⃣ Difference between SQL and ORM
- SQL: Direct queries to DB
- ORM: Object-Relational Mapping, allows interacting with DB using programming language objects (e.g., Sequelize, SQLAlchemy)
💬 Tap ❤️ if you found this useful!