✅ Web development Interview Questions with Answers Part-7
61. What is the difference between SQL and NoSQL databases?
SQL databases are relational and use structured schemas. They support joins and ACID transactions. NoSQL databases are schema-flexible and scale horizontally. I choose SQL for complex relationships. I choose NoSQL for high-scale or unstructured data.
62. What is database normalization?
Normalization organizes data to reduce duplication. It improves data integrity. It uses normal forms like 1NF, 2NF, and 3NF. I normalize by default and denormalize only for performance.
63. How does indexing improve database performance?
Indexes speed up read queries. They reduce full table scans. Indexes increase storage and slow writes. I index columns used in filters and joins.
64. What is the difference between primary key and foreign key?
Primary key uniquely identifies a row. Foreign key links one table to another. Primary keys enforce uniqueness. Foreign keys enforce referential integrity.
65. What are database transactions and ACID properties?
Transactions group operations into a single unit. Atomicity ensures all or nothing. Consistency keeps data valid. Isolation prevents conflicts. Durability ensures data persists after commit.
66. What are joins and when do you use them?
Joins combine data from multiple tables. INNER JOIN returns matching rows. LEFT JOIN returns all left rows. I use joins to avoid data duplication.
67. What are the advantages and disadvantages of using an ORM?
ORM speeds up development. It reduces boilerplate SQL. It can hide performance issues. I use ORM but write raw queries when needed.
68. What are common pagination strategies?
Offset-based pagination is simple but slow on large data. Cursor-based pagination is faster and scalable. I use cursor-based pagination for large datasets.
69. How do you validate data before storing it?
I validate at both client and server. I enforce schema-level validation. I sanitize inputs to prevent injection. Server-side validation is mandatory.
70. How do you prevent SQL injection attacks?
I use prepared statements. I avoid string concatenation. I validate and sanitize inputs. ORM query builders help reduce risk.
Double Tap ♥️ For Part-8
Post #3440
3.94K
- ❤ 11
- 🙏 1