avatarJIN

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2519

Abstract

and persistent, it will not cause data errors or data loss due to abnormalities or downtime.</li></ol><p id="2251"><b>Understanding Consistency</b></p><p id="3a95"><b>Internal consistency </b>(Database system): Consistency in ACID — modification loss, dirty read, non-repeatable read</p><p id="f6ab"><b>External Consistency </b>(distributed System): Strong consistency, weak consistency, and eventual consistency</p><div id="6637" class="link-block"> <a href="https://aws.plainenglish.io/distributed-system-cap-theorem-3ca7d933f5e7"> <div> <div> <h2>An Introduction to CAP Theorem in Distributed System Design</h2> <div><h3>CAP is about the trade-offs in distributed system design.</h3></div> <div><p>aws.plainenglish.io</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*wDc1GywIuB1eVuDj.png)"></div> </div> </div> </a> </div><p id="aaa3"><b>Understanding Isolation</b></p><ol><li>Read Uncommitted: The transaction will not lock when reading data to avoid dirty reads and non-repeatable reads. For example, transaction 1 can update data, but transaction 2 can read only the uncommitted data of transaction 1.</li><li>Read Committed: When we modify data in a transaction if the transaction has not been committed, other transactions cannot read the data, or can only read the committed data. In the words, the read operation is only locked at the moment of reading and the lock will be released after the end of the reading. This can avoid dirty reads but cannot avoid non-repeatable reads.</li><li>Repeatable Read: this can avoid the non-repeatable reads. It is locked at the moment of reading, but the lock is not released after the end of the reading and will be released until the end of the transaction.</li><li>Serialization: It can solve all problems of consistency completely. It is solved by adding table locks.</li></ol><p id="e512"><b>Further Study</b></p><div id="08e0" class="link-block"> <a href="https://en.wikipedia.org/wiki/Locality_of_reference"> <div> <div> <h2>The locality of reference - Wikipedia</h2> <div><h3>In computer science, locality of reference, also known as the principle of locality, is the tendency of a processor to…</h3></div> <div><p>en.wikipedia.org</p></div>

Options

</div>
          <div>
            <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*mVIJhDTxBHcrBP41)"></div>
          </div>
        </div>
      </a>
    </div><p id="6b5b"><b><i>If you’ve found any of my articles helpful or useful then please consider throwing a coffee my way to help support my work or give me patronage😊, by using</i></b></p><p id="a42a"><a href="https://www.patreon.com/jinlowmedium"><b>Patreon</b></a></p><p id="dce1"><a href="https://ko-fi.com/jinlowmedium"><b>Ko-fi.com</b></a></p><p id="98c3"><a href="https://www.buymeacoffee.com/jinlowmedium"><b>buymeacoffee</b></a></p><p id="022a"><i>Last but not least, if you are not a Medium Member yet and plan to become one, I kindly ask you to do so using the following link. I will receive a portion of your membership fee at no additional cost to you.</i></p><div id="fdd9" class="link-block">
      <a href="https://jinlow.medium.com/membership">
        <div>
          <div>
            <h2>Join Medium with my referral link - JIN</h2>
            <div><h3>As a Medium member, a portion of your membership fee goes to writers you read, and you get full access to every story…</h3></div>
            <div><p>jinlow.medium.com</p></div>
          </div>
          <div>
            <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*IZhvVndOS_9HXlfs)"></div>
          </div>
        </div>
      </a>
    </div><p id="3ef5">It is my first affiliate program, if you like to further enhance your system knowledge, you can click the links and buy the course. Honestly speaking, I will receive 20% of your course fees at no additional cost to you. You will have unlimited access to our courses. There is no time expiry and you will have access to all future updates free of cost.</p><div id="ab15" class="link-block">
      <a href="https://designgurus.org/link/LX551Y">
        <div>
          <div>
            <h2>Design Gurus</h2>
            <div><h3>Once bought, you will have unlimited access to our courses. There is no time limit and you will have access to all…</h3></div>
            <div><p>designgurus.org</p></div>
          </div>
          <div>
            <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/0*RRNJF9yszsIP_sgl)"></div>
          </div>
        </div>
      </a>
    </div></article></body>

The fundamental knowledge of System Design — (2) — Database

Database System

Photo by Ryan Ancill on Unsplash

Database System

  • The transaction is the smallest logical unit that represents one or a series of operations that occurred in the database system.
  • All operations in this logical unit either succeed or fail and there is no intermediate state.
  • The purpose of the transaction mechanism is no matter if the operation is successful, failed, abnormal, down, the transaction mechanism can guarantee the final consistency of the data. Even the failure of any operation will not affect the next operation. Regardless of whether the transaction is successful or a failure, the system data is ultimately consistent.

Transaction Characteristics (ACID)

  1. Atomicity: Either the entire execution when the transaction is successful or the entire rollback when the transaction is a failure
  2. Isolation: The execution of two transactions is independently isolated. When multiple transactions operate on an object, the second transaction can only be performed after the first transaction is completed. So, the concurrency will be minimized.
  3. Consistency: The transaction must ensure the integrity and consistency of the overall database data.
  4. Durability: Persistency means that once the transaction is successfully submitted, the modified data will be irreversible and persistent, it will not cause data errors or data loss due to abnormalities or downtime.

Understanding Consistency

Internal consistency (Database system): Consistency in ACID — modification loss, dirty read, non-repeatable read

External Consistency (distributed System): Strong consistency, weak consistency, and eventual consistency

Understanding Isolation

  1. Read Uncommitted: The transaction will not lock when reading data to avoid dirty reads and non-repeatable reads. For example, transaction 1 can update data, but transaction 2 can read only the uncommitted data of transaction 1.
  2. Read Committed: When we modify data in a transaction if the transaction has not been committed, other transactions cannot read the data, or can only read the committed data. In the words, the read operation is only locked at the moment of reading and the lock will be released after the end of the reading. This can avoid dirty reads but cannot avoid non-repeatable reads.
  3. Repeatable Read: this can avoid the non-repeatable reads. It is locked at the moment of reading, but the lock is not released after the end of the reading and will be released until the end of the transaction.
  4. Serialization: It can solve all problems of consistency completely. It is solved by adding table locks.

Further Study

If you’ve found any of my articles helpful or useful then please consider throwing a coffee my way to help support my work or give me patronage😊, by using

Patreon

Ko-fi.com

buymeacoffee

Last but not least, if you are not a Medium Member yet and plan to become one, I kindly ask you to do so using the following link. I will receive a portion of your membership fee at no additional cost to you.

It is my first affiliate program, if you like to further enhance your system knowledge, you can click the links and buy the course. Honestly speaking, I will receive 20% of your course fees at no additional cost to you. You will have unlimited access to our courses. There is no time expiry and you will have access to all future updates free of cost.

Storage
Database
Consistency
System Design Interview
Sql
Recommended from ReadMedium