Mysql entertainment explanation table relationship
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 |
---|---|---|---|---|
Skeleton King | 1 | |||
Chaos Knight | 4 | |||
centaur | 7 |
Equipment table
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:
Equipment name | Recovery Blood | Recovery Magic | Defense | |
---|---|---|---|---|
10 | 3 | 5 | 2 | |
22 | 4 | 1 | 3 | |
3 | 4 | 5 | 4 | |
1 | 3 | 4 | 5 | |
5 | 6 | 3 | 6 | |
13 | 32 | 32 | 7 | |
11 | 33 | 45 |
Bank Card ID | Bank Card Number | Password | Whether to freeze | Balance |
---|---|---|---|---|
1 | ##6222 0202 0002 66014e10adc3949ba59abbe56e057f20f883e | 0 | 12345.00 | |
##5423 4321 4567 8889 | 5bd2026f128662763c532f2f4b6f2476 | 1 | 45.58 |
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.
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.
- Course Recommendations
- Courseware download
-
IntermediateFront-end Vue3 actual combat [handwritten vue project]
2857 people are watching -
ElementaryAPIPOST tutorial [Popularization of technical concepts related to network communication]
1795 people are watching -
IntermediateIssue 22_Comprehensive actual combat
5521 people are watching -
ElementaryIssue 22_PHP Programming
5172 people are watching -
ElementaryIssue 22_Front-end development
8713 people are watching -
IntermediateBig data (MySQL) video tutorial full version
4525 people are watching -
ElementaryGo language tutorial-full of practical information and no nonsense
2794 people are watching -
ElementaryGO Language Core Programming Course
2814 people are watching -
IntermediateJS advanced and BootStrap learning
2563 people are watching -
IntermediateSQL optimization and troubleshooting (MySQL version)
3374 people are watching -
IntermediateRedis+MySQL database interview tutorial
2963 people are watching -
ElementaryDeliver food or learn programming?
5708 people are watching
Students who have watched this course are also learning
- Let's briefly talk about starting a business in PHP
- Quick introduction to web front-end development
- Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
- Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
- Login verification and classic message board
- Computer network knowledge collection
- Quick Start Node.JS Full Version
- The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
- Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
- About us Disclaimer Sitemap
- php.cn:Public welfare online PHP training,Help PHP learners grow quickly!
Operation | Location | |
---|---|---|
-1000.00 | Beijing Baidu Building ATM | |
+34000.00 | Shanghai Bund xx Bank Business Office | |
-12.08 | Taobao Online Shopping |