Database management method, device, equipment and storage medium

By generating operation script files and logic layer operation files, and automatically creating or updating databases, the complex and inefficient database development process is solved, and efficient database management is achieved.

CN113901025BActive Publication Date: 2025-08-12SHANGHAI PERFECT WORLD SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111144208.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-28
Publication Date
2025-08-12
Estimated Expiration
2041-09-28

AI Technical Summary

Technical Problem

The database development process is complex, involves a lot of manual operations, is prone to errors, and is inefficient in operation, so it cannot be processed.

Method used

By obtaining table-related files and version files, generating operation script files, target database operation files, and logical layer operation files, and automatically creating or updating databases.

Benefits of technology

The database development process is simplified, the degree of automation and operation efficiency is improved, manual participation is reduced, and error rate is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113901025B_ABST
    Figure CN113901025B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention provides a database management method, apparatus, device, and storage medium. The method includes: obtaining table-related files and version files, wherein the table-related files include text files and summary files, and the version file records the version number of the database; generating an operation script file, a target database operation file, and a logic layer operation file based on the text file, summary file, and version file, wherein the operation script file is used to assist in executing the target database operation file in the system; and creating a database or updating an already created database based on the operation script file, target database operation file, and logic layer operation file. The present invention simplifies the database development process and improves the degree of automation of the database development process, thereby greatly improving the operational efficiency of database development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a database management method, apparatus, device and storage medium. Background Art

[0002] The database development process is relatively complex, involving a large number of database tables that need to be processed, frequent database updates, the need to manually write a large amount of database operation code, difficulty in viewing the correspondence between engineering code fields and database code fields, and strict version control. Therefore, the manual workload required is large and it is relatively error-prone.

[0003] In order to solve the above problems, when establishing a database or updating an existing database, these operations can be assisted by tools. Specifically, technicians can write the logical variables of the engineering code in a text file, input the written text file into the tool, and the tool will generate code snippets based on the logical variables. The technicians need to add the code snippets back to the engineering file. In addition, in the process of updating the database, technicians are also required to select table-related files, and generate the files required for the database update operation by comparing the table-related files before and after the update. At the same time, each version of the database has its own version number. In the process of updating the database, technicians need to manually fill in the version number corresponding to the updated database.

[0004] This process still requires significant manual effort, resulting in low efficiency. Tools only provide a streamlined workflow for each stage, failing to streamline workflows. Furthermore, manual operations are prone to errors, leading to failures in database creation or updates. Summary of the Invention

[0005] The embodiments of the present invention provide a database management method, apparatus, device and storage medium, which are used to simplify the database development process and improve the automation level of the database development process.

[0006] In a first aspect, an embodiment of the present invention provides a database management method, the method comprising:

[0007] Obtain table-related files and version files, wherein the table-related files include text files and summary files. The text files record the identifier of the database table, the identifier of each field in the database table, the data volume and index, and the version files record the version number of the database.

[0008] Generate an operation script file, a target database operation file, and a logic layer operation file based on the text file, the summary file, and the version file, wherein the operation script file is used to assist in executing the target database operation file in the system;

[0009] Based on the operation script file, the target database operation file and the logic layer operation file, a database is created or an already created database is updated.

[0010] In a second aspect, an embodiment of the present invention provides a database management device, including:

[0011] An acquisition module is used to acquire table-related files and version files. The table-related files include text files and summary files. The text files record the identifier of the database table, the identifier of each field in the database table, the data volume and index. The version files record the version number of the database.

[0012] a generation module, configured to generate an operation script file, a target database operation file, and a logic layer operation file based on the text file, the summary file, and the version file, wherein the operation script file is used to assist in executing the target database operation file in the system;

[0013] A creation module is used to create a database or update an already created database based on the operation script file, the target database operation file and the logic layer operation file.

[0014] In a third aspect, an embodiment of the present invention provides an electronic device comprising a processor and a memory, wherein the memory stores executable code, and when the executable code is executed by the processor, the processor can at least implement the database management method in the first aspect.

[0015] In a fourth aspect, an embodiment of the present invention provides a non-transitory machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the database management method in the first aspect.

[0016] By adopting the method provided by the embodiment of the present invention, the technician only needs to prepare the table-related files and version files, and can automatically generate the operation script files, target database operation files and logic layer operation files based on the table-related files and version files. The operation script files, target database operation files and logic layer operation files are all the files required to create or update a database. After writing the table-related files and version files, no manual intervention is required, and all the files required to create or update a database can be automatically generated. The present invention simplifies the database development process and improves the degree of automation of the database development process, greatly improving the operational efficiency of database development. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 A flowchart of a database management method provided by an embodiment of the present invention;

[0019] Figure 2 A schematic diagram of a file generation process provided by an embodiment of the present invention;

[0020] Figure 3 A schematic diagram of the structure of a database management device provided by an embodiment of the present invention;

[0021] Figure 4 A schematic structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0022] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.

[0023] The terms used in the embodiments of the present invention are for the purpose of describing specific embodiments only and are not intended to limit the present invention. The singular forms "a," "an," "the," and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, and unless the context clearly indicates otherwise, "a plurality" generally includes at least two.

[0024] As used herein, the words "if" and "if" may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to the determination" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)," depending on the context.

[0025] In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.

[0026] Figure 1A flowchart of a database management method provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method includes the following steps:

[0027] 101. Obtain table-related files and version files. Table-related files include text files and summary files. The version file records the version number of the database.

[0028] 102. Based on the text file, summary file and version file, generate an operation script file, a target database operation file and a logic layer operation file. The operation script file is used to assist in executing the target database operation file in the system.

[0029] 103. Create a database or update an already created database based on the operation script file, the target database operation file, and the logic layer operation file.

[0030] It should be noted that the database management method provided in the embodiments of the present invention can be applied to databases in game servers. Compared to the development of other business databases, database tables in game server databases have almost no connections, and the target code can generate different versions of code depending on the configuration. Therefore, the database in the embodiments of the present invention has the concept of versioning, and the generated results include version information.

[0031] The above-mentioned operation script files, target database operation files and logic layer operation files are files required for creating a database or updating an already created database.

[0032] The table-related files and version files are edited by technicians. After the technicians have completed editing the table-related files and version files, no further manual intervention is required. The present invention can automatically convert the table-related files and version files into operation script files, target database operation files, and logic layer operation files to complete database development operations. The method provided by the embodiments of the present invention can significantly save labor costs and improve database development efficiency.

[0033] Optionally, in the process of editing table-related files, the technician can store the edited content as a text in txt format. In addition, in the process of editing version files, the technician can store the edited content as a file in ini format.

[0034] The table-related files may include text files and summary files. In a possible implementation, the text file may be, for example, t_xx.txt, the summary file may be, for example, dbinfo.txt, and the version file may be, for example, db.ini.

[0035] It is understandable that, since all files required for building or updating a database can be generated based on the table-related files and the version files, all information required for building or updating a database is recorded in the table-related files and the version files.

[0036] In the process of generating operation script files, target database operation files, and logic layer operation files based on table-related files and version files, it can be considered that the operation script files, target database operation files, and logic layer operation files include variable parts and fixed parts. For the fixed parts, the templated content can be used directly. For the variable parts, since these variable parts are constantly changing according to specific usage requirements, such as different logical variables, technical personnel need to input these variable parts into table-related files and version files. Then, the table-related files and version files can be parsed and the variable parts can be obtained from them. The operation script files, target database operation files, and logic layer operation files can be finally determined by combining the fixed parts with the variable parts obtained from the input table-related files and version files.

[0037] For example, a technician enters int m_a and int m_b in a text file to create two logical variables. Based on the input int m_a and int m_b, the SQL statements %d and %d can be output, adding the corresponding fields int m_a and int m_b to the database. The %d and %d values can be stored in the target database operation file.

[0038] It is understood that a database stores a large number of database tables, and the process of building a database is equivalent to creating database tables. The information required to create a database table is recorded in a text file, and each text file can correspond to a database table. Optionally, the text file records the database table identifier, the identifier of each field in the database table, the data volume, and the index.

[0039] Optionally, the summary file records information used by the logic layer to perform load and store operations on the database table.

[0040] The logic layer can also be considered the functional side. To achieve certain target functions, the logic layer needs to operate on logical variables. When the amount of logical variables is large, these logical variables can be stored in a database for management.

[0041] When the logic layer requires certain logical variables, it loads the target fields from the database table (the target fields correspond to the logical variables required by the logic layer) into memory for operation. By running certain logic, the values of the logical variables are modified and then stored back in the database table. Logical variables exist in memory, and the fields in the database table exist in the database, with a one-to-one correspondence between the two. For example, if there is a logical variable m_Money in memory, there is a corresponding field money in the database. The value of m_Money is read from the database, modified by the logic layer, and then stored back in the database.

[0042] As can be seen from the above description, there is interaction between the logic layer and the database. This interaction can be seen as the logic layer's load and store operations on database table fields. These load and store operations are implemented by logic layer operation files, and the information required to generate these files is recorded in summary files. Therefore, when creating or updating a database, you also need to generate the logic layer operation files required for performing operations on database tables.

[0043] It should be noted that each database table corresponds to a logic layer operation code for the logic layer to perform loading and storage operations (the logic layer operation code is stored in the logic layer operation file), and the code template for generating the logic layer operation code corresponding to each database table is recorded in the summary file.

[0044] The version file in the embodiment of the present invention is used to record the version number of the database, including the version number of the database before the update and the version number of the database after the update, which can also be called the old version number of the database and the current version number of the database.

[0045] It should be noted that if the database has not been created, you need to create it. If the database has already been created and you need to modify a field in it, you do not need to create the database again. Instead, you can update the existing database. For example, if the current version number is 2.0 and the previous version number is 1.0, and database 2.0 has added field a compared to database 1.0, you can upgrade from database 1.0 to database 2.0 by adding field a.

[0046] The operation script file in the embodiments of the present invention can also be a shell file. Shell is a program written in C that serves as a bridge for users to use Linux. Shell is both a command language and a programming language. Shell refers to an application that provides an interface through which users access services in the operating system kernel. The automatically generated target database operation file is an executable file, and executing the target database operation file requires the use of an operation script file.

[0047] The target database operation file operates on the database, while the logic layer operation file operates on the logic layer. These operations have different objects. Optionally, the target database operation file is a file written in Structured Query Language (SQL). The SQL statements in the target database operation file can be used to create and update a database, and can also be used to generate database tables. It should be noted that the text file contains the relevant information needed to generate the target database operation file. The SQL statements in the target database operation file can be generated using the text file, and the database and database tables can be created by executing the SQL statements.

[0048] Correspondingly, the logic layer operation file is a file written in C++. As mentioned above, the logic layer operation file is used to implement the logic layer's loading and storing operations on the fields in the database table.

[0049] Alternatively, as Figure 2 As shown, the process of generating an operation script file, a target database operation file, and a logic layer operation file based on the text file, the summary file, and the version file can be implemented as follows:

[0050] 201. Based on the text file and the version file, generate an operation script file and a target database operation file associated with the database version number. The content of the target database operation file is empty.

[0051] The version number of the above database may be the current version number, which is input by a technician in a version file and can be obtained by parsing the version file.

[0052] In this step, a target database operation file and an operation script file, both empty and bearing the current version number, are generated. Content can then be added to the empty target database operation file. The target database operation file is used to create the database if it hasn't been created yet, and to update it if it has already been created. The target database operation file also provides the logic layer with an operation interface for loading and storing database tables, using SQL statements. Accordingly, the operation script file can also be used to assist in executing the target database operation file used to create or update the database within the system.

[0053] 202. Determine the database operation code.

[0054] The above database operation code is the content that can be added to the target database operation file in step 301. The database operation code is an SQL statement, which can be used to implement database creation, update operations, and provide loading and storage operation interfaces.

[0055] Optionally, the process of determining the database operation code may be implemented as follows: generating an operation object corresponding to the database table based on a text file; and determining the database operation code based on the operation object.

[0056] Each text file corresponds to a database table. The text file includes information such as the identifier of the database table, the identifier of each field in the database table, the amount of data, and the index. A database table can be determined based on this information.

[0057] In actual applications, technicians may write multiple text files and traverse them one by one to generate the operation objects corresponding to each database table. After generating the operation objects corresponding to each database table, an operation interface is generated for each operation object so that the logic layer can perform load and store operations on each database table.

[0058] 203. Add the database operation code to the target database operation file.

[0059] 204. Generate a logic layer operation file based on the summary file.

[0060] The summary file contains the code templates needed to generate the logic layer operation code corresponding to each database table. Therefore, the logic layer operation file can be generated based on the code templates in the summary file. In addition, since there is a one-to-one correspondence between the fields in the database table and the logical variables in the logic layer, after creating the fields in the database table, the corresponding logical variables in the logic layer can also be created. These logical variables can also be reflected in the logic layer operation file.

[0061] In a possible implementation, the operation script file may be, for example, Update_DB.sh or Create_DB.sh, the target database operation file may be, for example, xx_table_mysql.sql, xx_data_mysql.sql, or xx_oldv_newv.sql, and the logic layer operation file may be, for example, t_xx.h.

[0062] If the database has been created and currently needs to be updated, the update process can be implemented as follows: obtain the version number of the database before the update from the version file; determine the old database operation file corresponding to the version number of the database before the update; compare the old database operation file with the target database operation file to generate a database update operation file; and update the database based on the database update operation file.

[0063] The above database update operation file may be composed of SQL statements.

[0064] To facilitate understanding, the following example illustrates the database update process. Suppose you already have database 1.0 and need to update it from version 1.0 to version 2.0. You can compare the database operation files corresponding to database 1.0 with those corresponding to database 2.0, then generate a database update operation file based on the differences between the two. Finally, you can upgrade database 1.0 based on this database update file.

[0065] By adopting the method provided by the embodiment of the present invention, the technician only needs to prepare the table-related files and version files, and can automatically generate the operation script files, target database operation files and logic layer operation files based on the table-related files and version files. The operation script files, target database operation files and logic layer operation files are all the files required to create or update a database. After writing the table-related files and version files, no manual intervention is required, and all the files required to create or update a database can be automatically generated. The present invention simplifies the database development process and improves the degree of automation of the database development process, greatly improving the operational efficiency of database development.

[0066] The following describes in detail one or more embodiments of the database management device of the present invention. Those skilled in the art will appreciate that these database management devices can be constructed using commercially available hardware components and configured according to the steps taught in this solution.

[0067] Figure 3 A schematic diagram of the structure of a database management device provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the device includes:

[0068] An acquisition module 31 is configured to acquire table-related files and version files. The table-related files include text files and summary files. The text files record the identifier of the database table, the identifier of each field in the database table, the data volume, and the index. The version files record the version number of the database.

[0069] A generating module 32, configured to generate an operation script file, a target database operation file, and a logic layer operation file based on the text file, the summary file, and the version file, wherein the operation script file is used to assist in executing the target database operation file in the system;

[0070] The creation module 33 is used to create a database or update an already created database based on the operation script file, the target database operation file and the logic layer operation file.

[0071] Optionally, the text file records the identifier of the database table, the identifier of each field in the database table, the data volume and the index;

[0072] The summary file records information used by the logic layer to perform loading and storing operations on the database table.

[0073] Optionally, the generating module 32 is configured to:

[0074] Based on the text file and the version file, generate an operation script file and a target database operation file associated with the version number of the database, wherein the content of the target database operation file is empty;

[0075] Determine the database operation code;

[0076] Adding the database operation code to the target database operation file;

[0077] Based on the summary file, a logic layer operation file is generated.

[0078] Optionally, the generating module 32 is configured to:

[0079] Based on the text file, generate an operation object corresponding to the database table;

[0080] Based on the operation object, a database operation code is determined.

[0081] Optionally, the device further includes an updating module, wherein the updating module is configured to:

[0082] Obtaining the version number of the database before the update from the version file;

[0083] Determine the old database operation file corresponding to the version number of the database before the update;

[0084] Comparing the old database operation file with the target database operation file to generate a database update operation file;

[0085] The database is updated based on the database update operation file.

[0086] Optionally, the database operation file is a file written using structured query language SQL.

[0087] Optionally, the logic layer operation file is a file written in C++ language.

[0088] Figure 3 The device shown can perform the aforementioned Figures 1 to 2 The database management method provided in the illustrated embodiment, the detailed execution process and technical effects can be found in the description of the aforementioned embodiment, which will not be repeated here.

[0089] In one possible design, the above Figure 3 The structure of the database management device shown can be realized as an electronic device, such as Figure 4 As shown, the electronic device may include: a processor 41 and a memory 42. The memory 42 stores executable code, and when the executable code is executed by the processor 41, the processor 41 can at least implement the above-mentioned Figures 1 to 2 The database management method provided in the illustrated embodiment.

[0090] Optionally, the electronic device may further include a communication interface 43 for communicating with other devices.

[0091] In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the aforementioned Figures 1 to 2 The database management method provided in the illustrated embodiment.

[0092] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Those skilled in the art can understand and implement the present invention without inventive effort.

[0093] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by a combination of hardware and software. Based on this understanding, the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a computer product. The present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0094] The database management method provided in the embodiment of the present invention can be executed by a certain program / software, which can be provided by the network side. The electronic device mentioned in the above embodiment can download the program / software to a local non-volatile storage medium, and when it needs to execute the above database management method, the program / software is read into the memory by the CPU, and then the CPU executes the program / software to implement the database management method provided in the above embodiment. The execution process can be referred to in the above embodiment. Figures 1 to 2 Instructions in .

[0095] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A database management method, characterized in that: include: Obtain table-related files and version files. The table-related files include text files and summary files. The text file records the database table identifier, the identifier of each field in the database table, the data volume, the index, and the logical variables to be created. The version file records the database version number. The summary file includes information used by the logic layer to load and store fields in the database table. After creating the fields in the database table, corresponding logical variables in the logic layer are created. The fields in the database table correspond to the logical variables in the logic layer. Based on the text file and the version file, an operation script file and a target database operation file associated with a database version number are generated, wherein the operation script file is used to assist in executing the target database operation file in the system; Based on the summary file, generate a logic layer operation file; The logic layer operation file is used to implement the logic layer's loading and storing operations on the fields in the database table; Based on the operation script file, the target database operation file and the logic layer operation file, a database is created or an already created database is updated, and the database is included in the game server.

2. The method according to claim 1, characterized in that The step of generating an operation script file, a target database operation file, and a logic layer operation file based on the text file, the summary file, and the version file includes: Based on the text file and the version file, generate an operation script file and a target database operation file associated with the version number of the database, wherein the content of the target database operation file is empty; Determine the database operation code; Adding the database operation code to the target database operation file; Based on the summary file, a logic layer operation file is generated.

3. The method according to claim 2, characterized in that The step of determining the database operation code includes: Based on the text file, generate an operation object corresponding to the database table; Based on the operation object, a database operation code is determined.

4. The method according to claim 2, characterized in that The method further comprises: Obtaining the version number of the database before the update from the version file; Determine the old database operation file corresponding to the version number of the database before the update; Comparing the old database operation file with the target database operation file to generate a database update operation file; The database is updated based on the database update operation file.

5. The method according to any one of claims 1 to 4, characterized in that The database operation file is a file written using the structured query language SQL.

6. The method according to any one of claims 1 to 4, characterized in that The logic layer operation file is a file written in C++ language.

7. A database management device, characterized in that: include: An acquisition module is used to acquire table-related files and version files. The table-related files include text files and summary files. The text files record the identifier of the database table, the identifier of each field in the database table, the data volume, the index, and the logical variables to be created. The version file records the version number of the database. The summary file includes information used by the logic layer to load and store fields in the database table. After the fields in the database table are created, the logical variables in the logic layer are created accordingly. The fields in the database table and the logical variables in the logic layer have a one-to-one correspondence. A generating module, configured to generate an operation script file and a target database operation file based on the text file and the version file, wherein the operation script file is used to assist in executing the target database operation file in the system; Based on the summary file, generate a logic layer operation file; The logic layer operation file is used to implement the logic layer's loading and storing operations on the fields in the database table; A creation module is used to create a database or update an already created database based on the operation script file, the target database operation file and the logic layer operation file, and the database is included in the game server.

8. An electronic device, characterized in that: include: A memory and a processor; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the database management method according to any one of claims 1 to 6.

9. A non-transitory machine-readable storage medium, characterized in that The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the database management method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and device for generating database change file

    CN108491218A

  • Code generation method and device, computer equipment and storage medium

    CN110147225A