mysql distributed database

Statement: I participated in the graduating class's student technology seminar today. I really feel that the growth rate of the students is quite amazing. I used to say "you are the worst class of students I have ever taken." Haha, actually not, today In-depth graduating class participated in a technical seminar to share with the students' research results. The code is rather rough, for your reference only, at least the idea can be used for reference.

Sub-library idea
  • Single database, single table
    Single database, single table is the most common database design. For example, there is a user (user) table in the database db, and all users can be found in the user table in the db database.
  • Single database with multiple tables
    As the number of users increases, the amount of data in the user table will become larger and larger. When the amount of data reaches a certain level, the query to the user table will gradually slow down, thereby affecting the performance of the entire DB. The user can be split horizontally in some way to produce two tables such as user_0000 and user-0001 with exactly the same structure. The data of user_0000 + user-0001 +… is just a complete data.
  • Multi-database, multi-table
    As the amount of data increases, the storage space of a single DB may not be enough. As the amount of queries increases, a single database server can no longer support it. At this time, the database can be differentiated horizontally.
Schematic diagram of sub-library:

Insert picture description here

Insert picture description here

mysql distributed database (increase)

Insert picture description here

Note: After operating a database, you must close the database connection, otherwise mysql will think that it is always connected to the same database

Or take the modulo to determine which configuration file is loaded to connect to which database
Insert picture description here

mysql distributed database (change)

The principle is similar to the new
Insert picture description here

mysql distributed database (check, delete)

Insert picture description here

mysql distributed sub-database delete

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_41475067/article/details/112426539