In the previous chapter we talked about the wide range of applications of databases. Without the database, we may not be able to move forward in the future.
There are quite a lot of boys and girls learning computers now. Especially among the aboriginal Internet users born in the 80s and 90s, many people love to play games. We explain the relationship between tables through the user equipment information in the game.
Withdrawing money from the bank, transferring money, and sending red envelopes are also the most commonly used bank card operations in our daily life. We also use bank card deposits and withdrawals to explain the relationship between tables.
The relationship between equipment and users in the game
A character in the game has a helmet, clothes, boots, weapons, and necklaces.
And, each different weapon will add different attack and defense values. Then we can simulate the table design of the game in this way.
Note: The following is only for everyone to better understand the relationship between the game, users and equipment.
User table
User ID | Username | Mask | Boots | Weapon |
---|
##1 | Skeleton King | 1 |
| 6 |
2 | Chaos Knight | 4 |
| 2 |
3 | centaur |
| 3 | 7 |
Equipment table
##Equipment IDEquipment name | Recovery Blood | Recovery Magic | Defense | |
##1Death Mask | 10 | 3 | 5 | | 2
Escape Dagger | 22 | 4 | 1 | | 3
Boots of Speed | 3 | 4 | 5 | | 4
Artist Mask | 1 | 3 | 4 | | 5
Mage Cloak | 5 | 6 | 3 | | 6
Magic Wand | 13 | 32 | 32 | | 7
Ghost Scepter | 11 | 33 | 45 | | In the user table, Skeleton King wears the weapon numbered 1 (death mask) in the equipment table and uses the weapon numbered 6 (magic rod).
User 3 (Centaur) used the numbers 3 (Boots of Speed) and 7 (Ghost Scepter) in the equipment table.
This enables some users to wear equipment in the game. If there is no such option in the user's row and column data, there will be no such data.
By adding the attribute value of the equipment to the attribute value of the user's level, different effects such as blood recovery and increased defense value can be achieved when the user wears the equipment.
Opening a bank account, withdrawing cash and reprinting
One of the activities we often perform in our daily life is to use bank cards to pay. In the bank statement, every transaction we make is faithfully recorded. .
Let’s simulate it through a table:
Bank Card ID | Bank Card Number | Password | Whether to freeze | Balance |
---|
1 | ##6222 0202 0002 66014 | e10adc3949ba59abbe56e057f20f883e | 0 | 12345.00 |
2##5423 4321 4567 8889 | 5bd2026f128662763c532f2f4b6f2476 | 1 | 45.58 | |
The above table is designed with the user’s bank card ID, card number, password, whether it is frozen and the balance.
Scene simulation:
After the user inserts the card and enters the correct password. Then you can withdraw money- In social engineering, people like to use the same password. Therefore, the user's password must be encrypted again and cannot be decrypted reversely. Because I am afraid that after seeing a certain user's password, I will use this password to try the user's other bank cards.
- We stipulate by ourselves: the freezing status can be set to 0 (not frozen) and 1 (frozen). If the bank receives notice from the court. Then set the freeze status to 1. If you have money, you are not allowed to withdraw it. (This business logic needs to be implemented in the program).
- If the user withdraws money or deposits money, the user's balance will be increased or decreased. At the same time, the records will be recorded in the transaction flow.
Transaction flow sheet
Bank card IDOperation | Location | |
1-1000.00 | Beijing Baidu Building ATM | |
1+34000.00 | Shanghai Bund xx Bank Business Office | |
2-12.08 | Taobao Online Shopping | |
Whenever a user's balance changes, we will faithfully record it in the transaction schedule. Make transactions traceable and traceable.
This simulates the bank's freezing, cash withdrawal, and deposit processes.
Note:
The password must be encrypted for the user using encryption methods such as md5. The user enters the original password such as: 123456. We use md5 to encrypt the 123456 entered by the user and compare it with the password of the database.
If they match, the password will pass. If they are inconsistent, the user entered the password incorrectly.
This ensures the security of user passwords and prevents insiders from leaking user passwords.
For more password knowledge, we will explain more to you in the next volume and advanced projects.
Next Section<?php
echo "Hello Mysql";
?>
- Chapter1Why choose this course to learn PHP
- Why learn PHP?
- What is PHP
- You can learn even with z...
- Why can't some people lea...
- Chapter2PHP environment installation
- What is the development e...
- Windows environment insta...
- Linux environment install...
- Other development environ...
- Tool selection for writin...
- Chapter3php basic syntax
- PHP basic syntax
- Our first piece of PHP co...
- Variables in php - you wi...
- echo display command
- Learning php annotations
- Data types are not myster...
- PHP integer type is an in...
- PHP data type Boolean (ac...
- PHP data type string
- PHP data type floating po...
- PHP flow control if else ...
- PHP data type NULL type
- php data type array
- Resource type of php data...
- PHP data type viewing and...
- Automatic conversion and ...
- Object (will learn later)
- PHP constants and variabl...
- PHP constants and variabl...
- PHP constants and variabl...
- PHP constants and variabl...
- Variable references for P...
- PHP basic syntax arithmet...
- PHP basic syntax assignme...
- PHP basic syntax: self-in...
- PHP basic syntax comparis...
- Logical operations of php...
- PHP basic syntax bit oper...
- PHP basic syntax: ternary...
- Chapter4PHP process control
- Process control in PHP
- PHP process control if co...
- PHP flow control if state...
- Nested if...else...elseif...
- Multiple nesting of if st...
- Use of branch structure s...
- Use of loop statements in...
- while loop
- The difference between do...
- PHP flow control for loop...
- PHP flow control goto syn...
- Chapter5Basic function syntax of PHP
- Basic function syntax of ...
- PHP function basic syntax...
- PHP custom function callb...
- PHP custom function varia...
- PHP custom function anony...
- Internal function of php ...
- Variable scope of php cus...
- Reference to parameters o...
- PHP custom function recur...
- Static variables of php c...
- php uses system built-in ...
- php file contains functio...
- PHP math commonly used fu...
- PHP function to obtain pe...
- php date validation funct...
- PHP gets localized timest...
- PHP program execution tim...
- PHP string common functio...
- Chapter6PHP arrays and data structures
- PHP arrays and data struc...
- php array definition
- PHP array calculation
- php for loop traverses in...
- php foreach traverses as...
- PHP list, each function t...
- PHP commonly used array m...
- Common functions for php ...
- Chapter7Regular expressions in PHP
- Regular expressions in PH...
- Delimiter expressed by ph...
- Atoms in php regular expr...
- Metacharacters in php reg...
- Pattern modifiers in php ...
- Tips and commonly used re...
- PHP uses regular expressi...
- Chapter8php file system
- File system
- php read file
- php creates and modifies ...
- php creates temporary fil...
- php move, copy and delete...
- php detect file attribute...
- Common functions and cons...
- php file locking mechanis...
- php directory processing ...
- php file permission setti...
- php file path function
- PHP implements file guest...
- PHP implementation exampl...
- Chapter9PHP file upload
- PHP file upload
- When uploading files, you...
- Steps to upload php files
- Precautions for php file ...
- php completes file upload...
- php multiple file upload
- PHP file upload progress ...
- Chapter10PHP image processing
- PHP image processing
- PHP image processing gd2 ...
- PHP uses image processing...
- PHP development verificat...
- php image scaling and cro...
- PHP image watermark proce...
- Chapter11PHP error handling
- Error handling
- PHP error handling prohib...
- PHP error handling error ...
- PHP error handling error ...
- PHP error handling custom...
- Chapter12Getting started with MySQL
- Getting Started with MySQ...
- Mysql database introducti...
- Mysql entertainment expla...
- mysql database installati...
- Data statement operation ...
- Mysql connect to database
- Mysql database operation
- Mysql data table operatio...
- Mysql data field operatio...
- Mysql data type
- Mysql character set
- Mysql table engine
- Mysql index
- Mysql add, delete, modify...
- Mysql add, delete, modify...
- Mysql multi-table joint q...
- Mysql addition, deletion,...
- Mysql add, delete, modify...
- DCL statement
- Learn commonly used Engli...
- Chapter13PHP operates mysql database
- PHP operates mysql databa...
- PHP database connection s...
- PHP operates the database...
- PHP database operation: m...
- PHP database operation: p...
- PHP database operation: b...
- PHP database operation to...
- The ultimate solution to ...
- Chapter14php session management and control
- session overview
- Overview of Cookies for P...
- php session control Cooki...
- PHP session control using...
- php SESSION application e...
- Session management and co...
- Chapter15Making a thief program through cURL
- php curl usage methods an...
- php curl custom get metho...
- php curl uses post to sen...
- Making a thief program th...
- Chapter16Learn commonly used English words in PHP
- List of commonly used Eng...