# Tidb Server

+ Handle client connections
+ parse and compiling SQL statements
+ Transformation of relational data and KV
+ Execution of SQL statements
+ Perform online DDL
+ Garbage collection


![right](./student-guide/diagram/01-TiDB-Sever-01-01.png)
------------------------------------------------------------
Let's take a brief look at its various functions here.

- Handle client connections
  - Users authenticate with a username+password and authorize connected users. These tasks are mainly done by the Protocol Layer module.

- parse and compiling SQL statements
  - After listening to the SQL statement, the TiDB Server parses and compiles it, optimizes it during the compilation process, and generates an execution plan. These tasks are done by the Parse, Compile module.

- Transformation of relational data and KV
  - Since data is stored on TiKV as key values (KV), there is a big difference between relational data (tables, indexes, and rows) and KV structures. If you want to execute SQL, you must be able to convert between relational data and KV storage.

- Execution of SQL statements
  - According to the compiled execution plan, it is executed on TiKV in batches. Data is read by the Executor module and DistSQL module, and transaction-related operations are completed by the Transaction module and the KV module.

- Execution of online DDL
  - TiDB database implement the function that DDL operations do not lock tables, and is done by the schema load module, worker module, and start job module.

- Garbage collection
  - The GC backend module is responsible for recovering old version data that has expired. This part will be explained in the TiKV course.

