I don’t understand the summary and study of the problems encountered in Zhengzhou (mysql problems, arrays, linked lists... etc.)

Mysql's transaction
atomicity : all operations in a transaction are either completed or not completed, and there will be no intermediate links. If an error occurs during the execution of the transaction, it will be rolled back to the state before the transaction started.
Consistency like this transaction has not been executed : Before the start of the transaction and after the end of the transaction, the integrity of the database is not damaged, which means that the written data must be completely consistent.
Isolation : the database allows multiple concurrent transactions to read and write them at the same time And modification, isolation can prevent the concurrent execution of multiple transactions due to cross-execution of data inconsistency.
Persistence : After the transaction is completed, the modification of the data is permanent.
Note: Mysql is the default setting of the command line, the transaction is Automatic submission, that is, the commit operation will be executed immediately after the sql statement is executed.
The four isolation levels introduced by isolation
read uncommitted : in this isolation level. All transactions can see the execution results of other uncommitted transactions. This isolation level is rarely used in practical applications. Its performance is not as good as other levels. So it is also called dirty read.
Read to submit : This is the default isolation level of most database systems (such as Sql Server, Oracle), but the default of mysql is repeatability. It satisfies the simple definition of isolation: a transaction can only see the changes made by the committed transaction. This isolation level also supports the so-called non-repeatability, because other instances of the same transaction may have new commits during the processing of this instance. So the same select may return different results.
Repeatable: Mysql default transaction isolation level, to ensure that multiple instances of the same transaction will see the same data rows when reading data concurrently, but it may cause another problem with phantom reading. Simply put, when the user reads a range of data rows, another transaction inserts data in the range. When the user accesses the new data, the phantom read appears. However, Innodb and falcon storage solve this problem by introducing concurrency control (mvcc) through multiple versions.
Serializable : This is the highest isolation level. It solves the phantom reading problem by forcing transaction ordering to make it impossible to conflict with each other. That is, each add a shared lock. At this level, it may cause a large number of timeouts and lock competitions.
The four isolation levels are prone to problems
Insert picture description here
Mysql index
1. Singleton index : An index contains only a single column, but there can be multiple singleton indexes in a table.
1. Ordinary index: There are no restrictions on the basic index type in mysql. Duplicate values ​​and null values ​​are allowed to be inserted in the column that defines the index, just to make the query faster.
2. Unique index: The value in the index column must be unique, but null values ​​are allowed.
3. Primary key index: is a special unique index that does not allow null values ​​(primary key constraint, that is, primary key index),
primary key index and unique The difference between indexes?
1. The primary key is a constraint, and the unique index is an index. The two are different in nature.
2. After the primary key is created, it must contain a unique index. The unique index is not necessarily the primary key.
3. Unique index The column allows null values, while the primary key column does not allow null value
4. When the primary key index is created, it has defaulted to non-null value + unique index.
5. At most one primary key index can be created for a table, but multiple unique indexes can be created.
6. The primary key is more suitable for unique identification, self-increment, and ID number that are not easy to change.
7. The primary key can be referenced as a foreign key by other tables, and the unique index cannot be
two. The index
created by the composite index on the combination of multiple fields in the table will only be used when the left field of these fields is used in the query conditions. Is used, and the left-most prefix set is followed when using a combined index. For example, here is an index composed of three fields: id, name, and age. The index row is stored in the order of id/name/age. The index can index the following combination of fields (id, name, age) or (id, name) or (id) If the field to be queried does not constitute the leftmost prefix of the index, then the index will not be used. For example, the combination of age or (name, age) will not use the index query .
3. Full-text index
Full-text index can only be used on Myisam engine. Full-text index can only be used on char, varchar, and text type fields. The requirements are introduced. It is to find the record line to which the field belongs through a certain keyword in a bunch of text.

Introduction to database B-Tree Introduction
:
B+Tree is an optimization based on B-Tree, which makes it suitable for realizing storage index structure. InnoDb storage engine uses B+tree to realize its index structure.
B+tree is relative to B-Tree. There are several differences
1. Non-leaf nodes only store value information
2. There is a link pointer between all leaf nodes
3. Data records are stored in the leaf nodes.
Description:
1. Usually there are two head pointers on B+tree, one It points to the root node, and the other points to the leaf node
2 with the smallest keyword , and all leaf nodes (data nodes) are in a chain ring structure
3, so two search operations can be performed on B+tree:
3.1 One is For the primary key range search and paging search
3.2 The other is to start from the root node, perform a random search
clustered index secondary index
secondary index leaf child nodes do not contain all the data of the row record, but store the clustered index relative to the row data The key is the primary key. When querying data through the auxiliary index, the Innodb storage engine traverses the auxiliary index to find the primary key, and then finds the complete row record in the clustered index through the primary key.

The principle of the half search algorithm
1. If the sequence to
be queried is empty, then return -1 and exit the algorithm; this means that the target element cannot be found 2. If the sequence to be queried is not empty, the middle element will be compared with the searched sequence. The target elements are matched to see if they are equal.
3. If they are equal, return the index of the middle element and exit the algorithm; at this time, the search is successful.
4. If they are not equal, compare the sizes of the two elements.
5. If the intermediate element is greater than the target element, then the first half of the current sequence is taken as the new sequence to be checked.
6. If the intermediate element is smaller than the target element, then Take the second half of the current sequence as the new sequence to be checked.
The second-half search is fast because it can exclude half of the remaining elements every time when the match is unsuccessful. Therefore, the effective range that may contain the target element is shrunk, unlike the sequential search, which can only exclude one element at a time

What is the difference between an array and a linked list?
Array : fixed length, can store basic types, can also store reference types. The
storage element types are consistent.
Arrays can be constructed by storing multiple elements consecutively in memory. The allocation in memory is also continuous and
is accessed through the subscript of the array. The subscript starts from 0 to get a
linked list.
Connect multiple nodes (elements) through a chain. An element is composed of data and address. The node itself must have an address value (that is, the address value of the next element).
Advantages : The linked list is A very commonly used data structure that does not need to initialize the capacity and can add or subtract elements at will.
Add blocks and delete blocks
Disadvantages : Because it contains a large number of pointer fields, it takes up a lot of space, and it needs to traverse the linked list to find the elements.

Git workflow
Common workflow
centralized workflow :
This way of working is similar to svn. It has only one master branch. Developers will first clone the remote warehouse to the local, and then modify and submit them locally until The workflow of incorporating local code into the remote master at a suitable point in time is suitable for small teams.
Example:
Step 1: Someone creates a central warehouse on the server. If it is a new project, initialize an empty warehouse.
Step 2: Everyone clones the central warehouse.
Then A develop functions, and use standard Git process development functions locally: edit, temporarily store, submit

git status # 查看本地仓库的修改状态
git add # 暂存文件
git commit # 提交文件-(这些命令生成的是本地提交,以按自己需求反复操作多次,而不用担心中央仓库上有了什么操作。)
git push 别名 master  上传到中央仓库

Second, functional development workflow
This workflow focuses on functional development. It does not directly submit code to the master to ensure that it is stable and clean. Instead, it pulls branches from the master for functional development. Team members pull different functional branches according to the division of labor. Develop different functions so that everyone's work can be isolated. When the function development is completed, a pull request will be initiated to the master branch. Only the code that has passed the review is allowed to be merged into the master.
Application example example
If A develops a function, before developing the function, Xiaohong needs an independent branch, then use the command to create a new branch

git checkout -b marys-feature master

After creating, follow the original routine

git status # 查看本地仓库的修改状态
git add # 暂存文件
git commit # 提交文件-(这些命令生成的是本地提交,以按自己需求反复操作多次,而不用担心中央仓库上有了什么操作。)

Then, A push once before going to lunch, so that it can be easily backed up, and if they collaborate with other developers, they can also see Xiaohong's submission.

git push -u origin marys-feature

A comes back after lunch, completes the development of the entire function, and merges to the remote branch.

Three, gitflow workflow

This kind of workflow will be relatively complicated and is suitable for managing the release and maintenance of large projects.
Fourth, Foking workflow
Foking workflow is often used in open source projects. It is a public central warehouse. Other contributors can clone this warehouse as your own private warehouse. Open source project maintainers can directly push
common commands and commands to the central warehouse.

Four common request methods in restful style

1. The get request will send a request for data to the database to obtain information. It is only used to query the data. It will not modify or increase the data. It will not affect the content of the resource. No matter how many operations are performed, the result is the same of
2, put the data request is sent to the server, thereby changing the information, which is used to modify the contents of the data, but does not increase the data type and the like, regardless of how many times, the results did not differ
3, post request with the put request Similarly, they are all sending data to the server, but the request will change the type of data and other resources. Almost all requests are post
4, and the delete request is used to delete a
post of a resource. It is mainly used in a collection of resources. While put mainly acts on a
URL address on a specific resource , it is used to describe a resource on the network, and the GET, post, put, delete in HTTP correspond to the search, modification, and addition of this resource. Delete operation.

Guess you like

Origin blog.csdn.net/m0_46937429/article/details/114947535