Database

What is a “database”?

What is a “database management system”?

What is a “relational data model”?

Define the terms “simple”, “composite”, “candidate” and “alternate” keys.

What is a “primary key”? What are the criteria for choosing one?

What is a “foreign key”?

What is “normalization”?

Explain 1NF, give example

Explain 2nf, give example

Can you give an example where we have composite key and no partial dependency ?

3NF, give example

What is “denormalization”? What is it used for?

What are the types of relationships in a database? Give examples.

Is primary key always indexed ?

Give example of use of composite primary key

If i define primary key as student_id, course_id, why i use only WHERE student_id = 1, for example, and how index of primary key works here ?

What are “indexes”? What are they used for? What are their advantages and disadvantages?

What types of indexes exist?

I was sure that Composite Index (Multi-column) is b-tree

How EXPLAIN shows B-tree vs. hash usage in query plans ?

What is the difference between clustered and non-clustered indexes?

What is clustered index ?

How do i define my clustered index ?

Does it make sense to index data that has a small number of possible values?

When is a full scan of a data set more advantageous than index access?

What is Low Selectivity problem, when we speaking about indexes ?

What is a “transaction”?

What are the main properties of a transaction?

What are the levels of transaction isolation?

What problems can arise with concurrent access using transactions?

ExplainCommand

BEGINNER

What is a primary key?

What is a foreign key?

What is ON DELETE CASCADE?

What is the difference between INNER JOIN and LEFT JOIN?

What is normalization? Why is it important?

Normalization.1NF.2NF.3NF

Beginner.2NF.Details

Third Normal Form (3NF)

What is Denormalization?

What are the different types of JOINs in SQL?

FullOuterJoin

What is index ?

Any disadvantages of using index ?

What is an Index Page in a Database?

Understanding b-tree and leaf pages in db

What is Fragmentation in a Database?

Why Fragmentation of leaf pages in b-tree is Bad

Ways to Fix Fragmentation

What is the difference between WHERE and HAVING clauses?

What is a UNIQUE constraint?

What are NULL Values in SQL?

What about composite primary key and many unique constraints ?

What is a VIEW in SQL?

What is the purpose of the GROUP BY clause?

Can i group by many columns ?

What is primary key?

Is primary key only about uniquness ?

What is the difference between DELETE, TRUNCATE, and DROP?

How to Fetch the Top N Records in SQL ?

What is the default sort order of ORDER BY?

What is the purpose of DISTINCT?

How would you find records that exist in one table but not another?

Explain ACID properties in databases.

What is a transaction?

Anomalies

Anomalies.SQL.Example

What are Aggregate Functions in SQL?

How would you update all rows in a table to set a column value to a default?

What is the difference between CHAR and VARCHAR?

Why is CHAR Sometimes Faster Than VARCHAR?

What is a self-join?

What is a subquery?

How is a correlated subquery different from a regular subquery?

StoredProcedures

What is the difference between UNION and UNION ALL?

How do you prevent SQL injection?

Is primary key only about uniquness ?

MIDDLE

What are the differences between clustered and non-clustered indexes?

ClusterIndex.Examples

How would you optimize a slow SQL query?

Is composite indexes better ?

How does a B-tree index work?

What is a covering index?

How would you design a schema for a social network?

What is a deadlock in a database?

When we start transaction, what is locked, table or row ?

How can you detect and resolve deadlocks?

MaterializedView

Explain the concept of sharding in databases.

What is eventual consistency?

How would you implement pagination in SQL?

What is the Seek Method?

Why, when we seek for pages no shifting from inserts/deletes on other rows ?

What if some rows were deleted ?

What is window function?

Give examples with Sum(), Avg(), Max()

WindowFunctions.Explain ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW

Middle.If i don’t use ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, so i take all rows ?

What are CTEs (Common Table Expressions)?

What is the difference between ROW_NUMBER(), RANK(), and DENSE_RANK()?

What is a trigger? How and when would you use it?

How does database partitioning work?

Do i see different tables in some sql explorer like dataGrip, for example ?

Partitions and sharding, differenes

Explain the difference between OLTP and OLAP.

What are surrogate keys ?

What is optimistic vs. pessimistic locking?

How can you enforce referential integrity?

How would you handle schema migrations in a production database?

How do you design a database for multi-tenant architecture?

What is a star schema? How is it different from a snowflake schema?

What is a hash join?

How does an index-only scan work?

Explain write-ahead logging (WAL).

How would you track changes (auditing) in a table?

What is a read replica and why would you use it?

What is replication lag ?

ACID

What is CAP theorem?

How does a database optimizer work?

What is query execution plan (EXPLAIN)?

ADVANCED

How would you design a high-availability database system?

What is eventual consistency ?

How do you implement eventual consistency in a distributed database?

What is multi-version concurrency control (MVCC)?

Is MVCC implementation of optimisti lock ?

How would you implement full-text search in SQL?

How does a bloom filter help in database optimization?

What is bloom filter

Explain acid compliance in distributed systems

What is Saga pattern ?

How would you handle database failover?

Explain the architecture of Amazon Aurora.

How would you store and query time-series data efficiently?

What is Z-ordering?

How would you implement a priority queue in a relational database?

How do you minimize replication lag ?