In the LAN, the main store summarizes the branch sales and other information by establishing a backup database for the Branch database in the general store database, and then collecting the required information in the database of the branch to be counted.
This tells us that the database name of each branch is unique and clear, otherwise the statistics will be inaccurate. The database name of each branch is recorded in the t_shop table.
However, when the backup file is transferred from the branch to the master store, its name can be changed. As a result, the program cannot directly determine the Database Name of the branch and create a database based on the name.
The solution is as follows:
Solution 1: Increase investment in backup and restoration of databases.
On the one hand, the store can clearly tell the store the name of the backup file when it transfers the database backup file; on the other hand, the store requires the total effort. Each time a database backup file of a branch is received, it is named as the unique database name corresponding to the branch.
Solution 2: increase programming intensity. Regardless of the name of the database backup file passed by the store, it is restored to the database under the corresponding database name of the store. This solution has two routes.
First, use the backup file to read the corresponding data name of the file, and then create a backup database by name;
The second is to indirectly read the corresponding database name of the file. The backup file is used to create a temporary database temp in the master store database. Then, restore the backup file to the temp database. Then you can operate the data table t_shop, read the Database Name of the branch, and use the name to create a backup database for the Branch database of the master store.
Now the problem and solution are cleared up. All things should end with discussion, thinking, and sorting.