|
Introduction
|
|
|
|
About the Course
|
|
|
Advanced SQL Querying
|
|
|
|
Explain the difference between RANK(), DENSE_RANK() and ROW_NUMBER().
|
|
|
|
How does a CROSS APPLY differ from an INNER JOIN?
|
|
|
|
Write a query to find the second highest salary per department.
|
|
|
|
How would you pivot data using PIVOT and UNPIVOT?
|
|
|
|
Explain recursive CTEs with an example.
|
|
|
|
What is a window function? Provide examples.
|
|
|
|
How do you calculate a running total using SQL?
|
|
|
|
What’s the difference between WHERE and HAVING?
|
|
|
|
Write a query to detect duplicate rows based on specific columns.
|
|
|
|
What are correlated subqueries? Provide an example.
|
|
|
|
Write a query to transpose rows into columns.
|
|
|
|
What is the WITH TIES clause in SQL?
|
|
|
|
How would you paginate results in SQL Server? PostgreSQL?
|
|
|
|
Write a query to get the Nth highest salary.
|
|
|
|
How do EXISTS and IN differ in performance?
|
|
|
|
Can you delete from a CTE? Give an example.
|
|
|
|
What are lateral joins and where are they used?
|
|
|
|
Explain the MERGE statement and give use cases.
|
|
|
|
How do you handle gaps in date ranges in SQL?
|
|
|
|
Write a query to calculate a moving average.
|
|
|
Performance Tuning & Optimization
|
|
|
|
What is a query execution plan and how do you interpret it?
|
|
|
|
How do indexes affect query performance?
|
|
|
|
When should you use a covering index?
|
|
|
|
How do you detect and resolve table scans?
|
|
|
|
What are clustered and non-clustered indexes?
|
|
|
|
What is index fragmentation? How do you fix it?
|
|
|
|
How do statistics affect query optimization?
|
|
|
|
What is parameter sniffing and how do you mitigate it?
|
|
|
|
How do materialized views affect performance?
|
|
|
|
How can you avoid or minimize locking and blocking?
|
|
|
Database Design & Normalization
|
|
|
|
Explain 1NF, 2NF, 3NF, BCNF with examples.
|
|
|
|
What is denormalization? When is it appropriate?
|
|
|
|
What are surrogate keys vs natural keys?
|
|
|
|
How do you design a many-to-many relationship in SQL?
|
|
|
|
What are the pros and cons of composite primary keys?
|
|
|
|
What is an entity-attribute-value (EAV) model?
|
|
|
|
How would you design a schema for versioned data?
|
|
|
|
What are the implications of NULLs in normalization?
|
|
|
|
How do you ensure data integrity across distributed databases?
|
|
|
|
What are the considerations for multi-tenant database design?
|
|
|
Transactions & Concurrency
|
|
|
|
What are ACID properties?
|
|
|
|
What is the difference between READ COMMITTED and REPEATABLE READ?
|
|
|
|
What is optimistic vs pessimistic locking?
|
|
|
|
Explain deadlocks and how to prevent them.
|
|
|
|
What is transaction isolation level? List the types.
|
|
|
|
What are phantom reads and how do you avoid them?
|
|
|
|
What are savepoints in transactions?
|
|
|
|
How does SQL Server handle concurrency vs PostgreSQL?
|
|
|
|
How do you handle retry logic in database operations?
|
|
|
|
Can a trigger cause a deadlock? How?
|
|
|
Stored Procedures, Triggers, and Views
|
|
|
|
What are the advantages and disadvantages of stored procedures?
|
|
|
|
How do you debug a stored procedure?
|
|
|
|
What’s the difference between AFTER and INSTEAD OF triggers?
|
|
|
|
Can a view be updated? When and how?
|
|
|
|
What are indexed views and when should they be used?
|
|
|
|
How do you prevent SQL injection in stored procedures?
|
|
|
|
What are recursive stored procedures?
|
|
|
|
What are the security implications of triggers?
|
|
|
|
When should you use scalar vs table-valued functions?
|
|
|
|
How does deferred name resolution work in stored procs?
|
|
|
Security and Access Control
|
|
|
|
What is SQL injection and how do you prevent it?
|
|
|
|
How do role-based permissions work in SQL Server / PostgreSQL?
|
|
|
|
What is the GRANT and REVOKE mechanism?
|
|
|
|
What are database roles and schemas?
|
|
|
|
How would you implement row-level security?
|
|
|
|
What is encryption at rest vs in transit in databases?
|
|
|
|
How does column-level encryption work?
|
|
|
|
How do you audit database access and changes?
|
|
|
|
What are proxy users in Oracle?
|
|
|
|
How can you manage secrets (e.g., DB passwords) securely?
|
|
|
Advanced Data Types and JSON/XML
|
|
|
|
How do you store and query JSON data in PostgreSQL?
|
|
|
|
What is the difference between JSON and JSONB?
|
|
|
|
How do you index JSON fields?
|
|
|
|
How do you query hierarchical data using XML/JSON?
|
|
|
|
How can you validate JSON schema in SQL?
|
|
|
|
How do you extract elements from XML fields?
|
|
|
|
What are arrays in PostgreSQL and how do you use them?
|
|
|
|
How do you normalize JSON data into relational format?
|
|
|
|
When would you use a document store within a relational DB?
|
|
|
|
How do you perform full-text search on JSON fields?
|
|
|
Data Warehousing and OLAP
|
|
|
|
What is the difference between OLAP and OLTP?
|
|
|
|
What is a star schema? What is a snowflake schema?
|
|
|
|
How do you handle slowly changing dimensions?
|
|
|
|
What are fact and dimension tables?
|
|
|
|
What are cube functions in SQL Server?
|
|
|
|
How do you use GROUPING SETS, ROLLUP, and CUBE?
|
|
|
|
What are materialized views and their use in analytics?
|
|
|
|
How do you optimize ETL pipelines using SQL?
|
|
|
|
What is partitioning and how does it improve performance?
|
|
|
|
Explain the concept of time-series modeling in SQL.
|
|
|
Conceptual
|
|
|
|
What is sharding and how does it impact SQL queries?
|
|
|
|
What is CAP theorem and how does SQL database fit into it?
|
|
|
|
How do SQL and NoSQL differ fundamentally?
|
|
|
|
What is eventual consistency and where does SQL support it?
|
|
|
|
How do you enforce uniqueness in complex business rules?
|
|
|
|
What is a temp table vs table variable?
|
|
|
|
How does SQL handle timezone-aware data?
|
|
|
|
What are system-versioned temporal tables?
|
|
|
|
How do you perform cross-database queries securely?
|
|
|
|
Describe a real-world problem you solved using complex SQL.
|
|
|
|
How would you detect and repair database corruption?
|
|
|
|
How do you handle schema changes in a production environment?
|
|
|
|
What is the difference between horizontal and vertical partitioning?
|
|
|
|
What are common causes of slow queries in large-scale systems?
|
|
|
|
How would you log changes to sensitive tables securely?
|
|
|
|
How do you implement soft deletes vs hard deletes?
|
|
|
|
What are the trade-offs of using UUIDs as primary keys?
|
|
|
|
How can you enforce foreign key constraints across schemas?
|
|
|
|
What are upserts and how are they implemented in PostgreSQL and MySQL?
|
|
|
|
How does the RETURNING clause in PostgreSQL improve performance?
|
|
|
|
How do you identify and fix non-SARGable queries?
|
|
|
|
What is a fill factor in SQL Server and when should you adjust it?
|
|
|
|
How do you batch insert data efficiently in SQL?
|
|
|
|
How do you optimize queries with large IN clauses?
|
|
|
|
How would you design a logging table for high-write throughput?
|
|
|
|
What are parallel queries and when are they beneficial?
|
|
|
|
What is the difference between logical and physical data models?
|
|
|
|
How can you track changes over time in a table without using triggers?
|
|
|
|
How does PostgreSQL's GIN index differ from a BTREE index?
|
|
|
|
What are the differences between NOWAIT, SKIP LOCKED, and regular locking?
|
|
|
|
How do you migrate large datasets with minimal downtime?
|
|
|
|
How would you identify and clean up orphaned records?
|
|
|
|
What is a bloom filter index and where is it useful?
|
|
|
|
How do you implement multi-language (i18n) support in a database schema?
|
|
|
|
What is the role of Write-Ahead Logging (WAL) in databases?
|
|