Database system 0T1 (0): Basic concepts

Source: Internet
Author: User
Tags cassandra comparison table

  database , in simple terms can be regarded as electronic cabinet-the place where electronic files are stored, users can run new, intercepted, updated, deleted and other operations on the data in the file.
Database storage is the basic object of data, data can be digital, text, pictures, audio, video and so on.

Basic features of the database
Data is organized, described and stored in a certain data model
can be shared for various users
Less redundancy
High data independence, independent of application
Easy to expand

type
Relational databases: MySQL, SQL Server, Oracle, etc.
Non-relational database (NoSQL): BigTable (Google) Cassandra, MongoDB, etc.
Key value (key-value) database: Apache Cassandra, Dynamo, LevelDB (Google)

Data Abstraction
Database for shielding the underlying complexity, the use of hierarchical abstraction, can be roughly divided into three summary levels: physical layer, logical layer, view layer.
Physical layer: The closest to the actual storage, i.e. the actual storage of the data.
Logical layer: An indirect layer between the two, describing how the data is stored and the relationship between the data.
View layer: The closest user, that is, about how the user views the data. A logical layer can correspond to multiple view layers.
 

As you can see, although the logic is independent of each other, the redundancy is minimized by storing only one copy of the student's base on the physical layer.

Data Model
The database structure is based on the data model. The data model provides a way to describe the physical layer, the logical layer, and the design of the view-layer database. In layman's parlance, the data model is the simulation of the real world.
The data model can be classified into four categories:
Entity-Contact Models (Entity-relationship model). The real world consists of a set of basic objects called entities and the connections between those objects.
Relational models (relational model). A relational model uses a collection of tables to represent data and data connections. Each table has more than one column, and each column has a unique column name. The relational model is based on a record model. The relational data model is the most widely used data model.
Based on the object data Model (object-based). The object-oriented data model can be seen as an extension of the E-R model with the addition of concepts such as encapsulation, methods (functions), and object identifiers.
Semi-structured data Model (semistructured). A semi-structured data model allows data items of the same type to contain data descriptions for different sets of properties.

Database Index
The idea of a data index has a long history, like a book in front of a few pages have a table of contents, is a kind of index, but its classification is wider, such as license plate, ID card, barcode, etc., are an index number, when we see the number, you can see from the number of clues, if you want to find people, cars As long as you provide the relevant number, you can quickly find the right people things.

Database management System (DBMS)
A layer of data management software located between the user and the operating system.
  

Use:
Scientifically organize and store data, efficiently access and maintain data
Function:
Provide data definition language (DDL)
Defining data Objects in a database
Data organization, storage, and management (security, integrity, concurrency control, recovery)

Database operations: Transaction
Transactions (Transaction) are a sequence of database operations that are used to complete a single logical function, either wholly or completely, and is a non-partitioned unit of work.
to ensure that transactions (transaction) are correctly and reliably, the acid properties of a transaction are:
1) atomicity (atomicity): All operations in a transaction (transaction) are either complete or not complete and do not end up in the middle of a link. A transaction has an error during execution and is rolled back (Rollback) to the state before the transaction started (failback).
2) Consistency (consistency): the integrity of the database is not compromised until the transaction begins and after the transaction has ended. This means that the data being written must fully conform to all of the preset rules, which include the accuracy of the data, the concatenation, and the subsequent database's ability to perform the scheduled work spontaneously.
3) Isolation (isolation): When two or more transactions concurrently access the same data in a database that refers to queries and modifications, a transaction cannot let other transactions see the middle state of the transaction.
4) Persistence (durability): After the transaction completes, the transaction changes made to the database are persisted in the database and are complete.
See the following example:
Han Meimei to Li Lei, must protect the Han Meimei account minus 100, the Li Lei account increased by 100 (atomicity), if the server power outage, from the Han Meimei account minus 100, Li Lei account has not increased by 100, the entire transaction to roll back.
After the transfer is complete, the accounts of the two people must remain unchanged (consistent), without disrupting the integrity of the relational data and the consistency of the business logic.
Other transactions, such as a query transaction, can not query the middle status of the transfer, such as Han Meimei account minus 100, Li Lei account did not increase the status of 100. (isolation)
Han Meimei and Li Lei account also maintain the amount after transfer (persistent) when the transfer is successful, even if the machine fails.

Let's take a look at some of the concepts in isolation:
1) Dirty Read (Dirty Reads): Dirty data refers to uncommitted data. That is, a transaction is making modifications to a record, and the transaction reads the data that the other thing has changed but not committed.
2) Non-repeatable read (non-repeatable Reads): One transaction reads the same record sequentially, but the data read two times is different, we call it non-repeatable read. That is, the transaction is changed between two reads and the data is modified by other firms.
3) Phantom Read (Phantom Reads): A transaction re-reads the previously retrieved data in the same query condition, but finds that other transactions have inserted new data that satisfies its query criteria, a phenomenon called Phantom reading.

Isolation is divided into different levels, including:
READ UNCOMMITTED: Reads data that has been modified but not yet committed by other transactions (dirty data), which is the lowest isolation level.
Read Committed: Only data that has been committed can be read. that resolves the dirty read problem.
REPEATABLE READ (Repeatable Read): In one transaction, the same item is read before and after the result
Serialization (Serializable): Serial execution of each transaction (lock mechanism)

Isolation Level Comparison table:
  

Reference:
https://zh.wikipedia.org/wiki/%E6%95%B0%E6%8D%AE%E5%BA%93
Https://zh.wikipedia.org/wiki/ACID
Http://www.cppblog.com/wolf/articles/121626.html

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Database system 0T1 (0): Basic concepts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.