Is there anyone who can explain mining?
Mining is a process of exploring and extracting coal, gold, or other metal. Let's draw some pictures to let me know what looks like a miner in your mind. This is what I imagine the miner is.

They work hard to dig and find resources for all humankind. For example, we can buy these resources, like coal, from them to cook.
The miners in Blockchain are similar to it. But, it is the computers to mine the resources for us. Does anyone want to guess how our computer can mine the resources?
One of the significant power of a computer is to compute things. So, the miner in Blockchain will compute some complicated mathematical problem to mine the resources.

The resources in Blockchain are cryptocurrency. The most famous one is bitcoin.
People say the Blockchain is a distributed network because everyone in the world can be the miner without anyone’s approval. Let me draw a simple graph to show the difference between distributed and centralized networks.

It's a little hard to think about it, right? Let me give you some examples. If your teacher asks you questions and then tells your classmates about your answer, it is how centralized network work. Your teacher is the agent to collect information and share it with all of you. On the contrary, if classmate A can share his secret with classmate B, then classmate B share it with classmate C, D, E, and so on. After that, everyone in this room knows the secret about classmate A. It is what these graphs tell us. It may take a longer time, but it is important that we can share the same information among ourselves without any central agency.

So, the miner in Blockchain doesn't need to fill up any application to get this job. This job is so important for the users of Blockchain because they also help people to transfer their resources from one to another. So, if I live in Taiwan, I can instantly share resources with friends who live in the USA without any central agency. In return, the miner can receive some resources as a reward because they are hard-working for us.
Can anyone explain what Blockchain is now? Or, can you imagine what Blockchain is?
Let's separate the word Blockchain to block and chain like this picture.

It is just like a train. Every carriage is chained together and only can move in one direction. In Blockchain, every block contains the user's transaction. Like cargos in the train carriages. When the resources are exchanged between my friends and me, they will record in one of the blocks, and everyone can see them. After transferring only one resource to my friend, I can't transfer it to another person again, right? In Blockchain, every record is transparent to everyone. It is an important attribute because everyone can validate it and ensure no one is cheating.

But who will pick those cargos and put them on the train? Who can tell me?
We know the miners in Blockchain will help us to transfer our resources, right? In the mining process, miners will pick some transactions and validate them to protect our resources are well treated. After, the miner will put them into a block, which is a process of mining a block.
We know what block is now. Does anyone want to guess what the chain between these blocks means?
We can't chain things together as the train does in a digital world. So, the chain between these blocks is really magic. Every block will contain the previous block's information. So, the result will look like every block is chained together. I would say it is a pretty elegant mechanism in Blockchain.

Because of the invisible chain, one significant attribute comes to the Blockchain. It is the transactions in Blockchain are immutable. It can not be changed after it is put into a block and chained together. Let's think about the train. If every carriage on this train has a unique hook between them. So, if I change one carriage, this train will break into two pieces, and it can not move together forever. The only way I can change this carriage is to change the hook and the carriage behind it, which can fit the new hook. When the carriage behind the fraud one changes, I need to change its hook, too, and so on.
This is how Blockchain work to protect history from being mutable. If I change this block, then the chain will break up. The other miners or users will figure out if there is some bad thing happening because the chain length is different compared to the previous times, and the only way you can cover the cheating behavior by yourself is you need to change every single block behind it. I would say it is tough for a single miner can do it by himself.

Here is the last question for you. There are tons of miners who can put valid transactions and append the block to the Blockchain. What will happen if they validate the different transactions and put different content in a block?
Do you remember the complex mathematical problem I said? After the miner collects some transactions and validates them to build a new block, they will start to calculate the mathematical problem. The first one who solves the problem, his block will be accepted by the other miners, which means the whole network will have a consensus for this valid block to be the latest block.
However, the miners are doing it in parallel, so it might have a situation in which two or more miners solve the problem simultaneously and be accepted by the miners near them first. So, there is another principle in Blockchain that is called the longest-chain rule. If there are two or more blocks generated at the same time, then the miners will both record them and wait. After some time, they can choose the longest chain and remove the branch.

Let's have some takeaways from what we learned today.
First, we know that miners play an important role in Blockchain. They will mine blocks and be responsible for Blockchain security and can receive rewards depending on their work.
Second, Blockchain is a distributed network that everyone can join as a miner or a user. We can transfer resources without any central agency.
Third, Blockchain is immutable and transparent. Everyone can see transactions on Blockchain, but we can’t change the history.
Fourth, there is a consensus rule in Blockchain. In the PoW algorithm we learned today, the miners will calculate mathematical problems to win the right to produce the latest block. Moreover, we will need to wait some time for the network to reach the longest chain.

