Skip to content
Go back

[Computer Science] Kiến thức về Database cơ bản

Published:  at  10:11 PM

Bài viết tổng hợp câu trả lời cho các câu hỏi về Database cơ bản trong computer science được fork từ repo: https://github.com/vietnakid/learning-material.git

Table of contents

Open Table of contents

Compare Relational DB (SQL) vs NoSQL


How these 2 things can scale up?

How Transaction is handled?

ACID of SQL and BASE of NoSQL? Why NoSQL is eventual consistency?

CAP theorem in this case

image.png

What is parameterized statement (in Java it’s prepared statement)? How does it work internally?


What is SQL injection? how to avoid it?

How many “requests” you have to send to Database in a single prepared statement query?

Can you reuse the compiled query multiple times?

How indexing works internally?

What algorithm and data structure indexing used? And why?

How composite indexing works?

How to know your query is using index?

How index work in this case: WHERE age = 5 and Where age > 5? The complexity to go to the next record?

Indexing with char?

The complexity of SQL query? How to measure it? How SQL optimize a query?


Compare WHERE id = 'a' AND id = 'b' AND id = 'c' vs WHERE id in (a, b, c)?

Complexity of this query SELECT * FROM abc ORDER BY name LIMIT 10 OFFSET 1000000. SELECT 10 record from offset $10^6$ after sort by name (which is a char)? How to optimize it?

What is the complexity of COUNT(*) query?

How to write query to avoid full table scan?

Complexity of JOIN, INNER JOIN, OUTTER JOIN?

What is Database Replicating? When we need it?


What is bin log? How Master DB sync with Slave DB?

Can a Slave DB be a slave of another Slave DB (we do not need to sync from Master DB directly)?

What is Database Sharding? When we need it?


Which rule we can apply to DB Sharding?

How to ensure primary key is globally unique when sharding?

How we can shard a table to multiple tables (same server) and multiple DB (multiple servers)?

How query can work when we sharding? for example query but the data is in different tables/dbs?

What is database transaction?


How rollback works internally?

ACID? What is dirty read?

How transaction work when there are many concurrent requests?

How to avoid race condition in DB? Read/Write lock?

Distributed transaction? How to make a transaction when a query needs to access multiple DB?


Suggest Changes

Previous Post
[Computer Science] Kiến thức về Security cơ bản
Next Post
[Computer Science] Kiến thức về OS cơ bản