1. Database Lock Granularityhistorical

    1. What Are Granularity Locks Database locks can be divided by granularity into row locks, page locks, and table locks. 2. Row Locks 2.1. What They Are Row locks lock data at row granularity. 2.2. Classification By read/write: shared lock (read lock, S lock) and exclusive lock (write lock, X lock). 3. Page Locks 4. Table Locks 5. Metadata Locks 6. Row Locks vs Page Locks vs Table Locks 7. Reference

  2. Database Normal Formshistorical

    1. Definition 1NF: Every attribute in a relation that conforms to 1NF cannot be further divided. 2NF: On the basis of 1NF, 2NF eliminates partial functional dependencies of non-prime attributes on a candidate key. 3NF: On the basis of 2NF, 3NF eliminates transitive functional dependencies of non-prime attributes on a candidate key. 2. Reference What Are the First, Second, and Third Normal Forms Actually Saying? - Zhihu

  3. Database Lockshistorical

    1. What They Are When multiple transactions concurrently access the same data, conflicts will definitely occur. How should such conflicts be handled? There are mainly two ideas: 1. Pessimistic locking mechanism: avoid conflicts from occurring, such as Read/Write Locks and Two-Phase Locking. 2. Optimistic locking mechanism: allow conflicts to occur and detect them afterward, such as MVCC. Described using Java: when doing multithreaded programming in Java, locks are needed. The simplest is ReentranLock: reads and writes are mutually exclusive, and reads are also mutually exclusive. Replace it with ReentrantReadWriteLock: reads are not mutually exclusive, but reads and writes are. Finally replace it with CopyOnWriteList: reads are not mutually exclusive, and reads and writes are also not mutually exclusive. MVCC is somewhat similar to CopyOnWriteList.