Database optimization method and device, electronic equipment and storage medium
By analyzing database table relationships and generating CRUD business codes, the problem of low database optimization efficiency in the existing technology is solved, the database structure and code are streamlined, system performance and maintainability are improved, and development and maintenance costs are reduced.
Patent Information
- Application Number
- CN202410796658.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technology cannot effectively optimize database design and code implementation, resulting in the existence of many unnecessary data tables and functions, and low database optimization efficiency.
By scanning the target database, analyzing the correlation between database tables, establishing a data table correlation model, and generating CRUD business code through the template engine, optimizing the database structure and code.
Automatically identify and filter out the most useful data tables, streamline database structure and code, improve system performance and maintainability, reduce development and maintenance costs, and bring economic and competitive advantages.
Smart Images

Figure CN118626472A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a database optimization method, device, electronic equipment and storage medium. Background Art
[0002] With the rapid development of information technology, the complexity and scale of business systems continue to grow. Many companies face changes in business needs and iterative updates of system functions at different stages. In the iterative process of business systems, many functions are gradually abandoned or replaced as business needs change, but the relevant database tables and codes are often retained, causing the system to become large and complex, with a large number of redundant data tables and unnecessary codes. This redundancy and over-design not only increases the cost of system maintenance and management, but also reduces the performance and flexibility of the system, affecting the competitiveness and innovation ability of the enterprise. This has caused the problem of system redundancy and bulkiness.
[0003] However, traditional business system design often lacks in-depth analysis and understanding of data, resulting in the existence of many unnecessary data tables and functions. In addition, due to the complexity of the system, developers often find it difficult to fully understand the relationship between data tables in the system, making it impossible to effectively optimize database design and code implementation.
[0004] Therefore, there is a need for a database optimization method that can automatically identify and eliminate redundant data tables in the system, and generate lightweight, concise and efficient code to streamline the database structure of the business system, improve the performance and maintainability of the system, and reduce the cost of system development and maintenance. Summary of the invention
[0005] Each embodiment of the present invention provides a database optimization method to solve the problem that the prior art cannot effectively optimize database design and code implementation, resulting in many unnecessary data tables and functions and low database optimization efficiency. The technical solution is as follows: According to one aspect of the present invention, a database optimization method includes: scanning a target database to obtain multiple database tables; analyzing the multiple database tables through an algorithm to obtain the association relationship between the database tables; establishing a data table association model according to the association relationship between the database tables; generating a data model according to the data table association model through a template engine, generating CRUD business code according to the data model and optimizing the target database.
[0006] In one of the embodiments, the association relationship between the database tables is obtained by analyzing the plurality of database tables by an algorithm through the following steps: the database table having operation records within a set time is set as a base table by an algorithm; the data of all tables and base tables in the target database are traversed and compared, and a database table whose specific data is associated with the base table is obtained as a data association table; the data of all tables and base tables in the target database are traversed and compared, and a database table whose field naming is associated with the base table is obtained as a structure association table.
[0007] In one of the embodiments, establishing a data table association model according to the association relationships between the database tables is achieved by the following steps: obtaining multiple base tables in the target database and association tables corresponding to the base tables according to the association relationships between the database tables; the association tables include data association tables and structure association tables; adding the base tables and their corresponding association tables to the data table association model; performing hierarchical recursive analysis on the base tables and their corresponding association tables, and adding them to the data table association model.
[0008] In one of the embodiments, hierarchical recursive analysis is performed on each of the base tables and its corresponding data association table and structure association table, and adding a data table association model includes the following steps: taking the association table of each of the base tables as the current base table; analyzing the current base table through an algorithm to obtain a corresponding association table, and adding the current base table and the corresponding association table to the data table association model, until the data table association model is obtained when the association table corresponding to the current base table cannot be obtained.
[0009] In one of the embodiments, after analyzing the base table to obtain the corresponding association table, a search is performed in the data table association model to determine whether the association table already exists. If not, the association table is added to the data table association model.
[0010] In one of the embodiments, a data model is generated according to the data table association model through a template engine, and CRUD business code is generated according to the data model and the target database is optimized through the following steps: the data table association model is converted into a data model and organized into a data model package; a plurality of CRUD business codes are generated according to the data model package through a template engine; the CRUD business code includes a Vue front-end code and a Springboot back-end code.
[0011] In one of the embodiments, the vue front-end code and springboot back-end code in multiple curd business codes are run to perform corresponding additions, deletions, modifications and queries on the target database to obtain an optimized database.
[0012] According to one aspect of the present invention, a database optimization device includes: a database scanning module, which is used to scan a target database to obtain multiple database tables; an association analysis module, which is used to analyze the multiple database tables through an algorithm to obtain the association relationship between each of the database tables; an association model construction module, which is used to establish a data table association model according to the association relationship between each of the database tables; and a database optimization module, which is used to generate a data model according to the data table association model through a template engine, generate CRUD business code according to the data model and optimize the target database.
[0013] According to one aspect of the present invention, an electronic device includes at least one processor and at least one memory, wherein the memory stores computer-readable instructions; the computer-readable instructions are executed by one or more of the processors, so that the electronic device implements the database optimization method as described above.
[0014] According to one aspect of the present invention, a storage medium stores computer-readable instructions thereon, wherein the computer-readable instructions are executed by one or more processors to implement the database optimization method as described above.
[0015] The beneficial effects brought by the technical solution provided by the present invention are: In the above technical scheme, the present invention first scans the target database to obtain multiple database tables, then analyzes the multiple database tables through an algorithm to obtain the association relationship between the database tables, and then establishes a data table association model according to the association relationship between the database tables, generates a data model according to the data table association model through a template engine, generates CRUD business code according to the data model and optimizes the target database, and automatically identifies and screens out the most useful data tables through in-depth analysis of the data volume and update frequency in the database, and generates corresponding codes according to the association relationship between the data. This can not only help enterprises streamline the database structure and code implementation of the business system and improve the performance and maintainability of the system, but also effectively reduce the cost of system development and maintenance, bringing substantial economic and competitive advantages, thereby effectively solving the problem that the prior art cannot effectively optimize database design and code implementation, resulting in many unnecessary data tables and functions, and low database optimization efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in describing the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without creative work.
[0017] Figure 1 is a flow chart of a database optimization method according to an exemplary embodiment; Figure 2 yes Figure 1 Flow chart corresponding to step 130 in the embodiment; Figure 3 yes Figure 1 Flow chart corresponding to step 150 in the embodiment; Figure 4 It is a schematic diagram of a database optimization method in an application scenario; Figure 5 yes Figure 4 Flow chart of database table analysis algorithm in corresponding application scenarios; Figure 6 yes Figure 4 Schematic diagram of hierarchical recursive analysis in corresponding application scenarios; Figure 7 yes Figure 4 Schematic diagram of the process of preventing circular references in the corresponding application scenario; Figure 8 is a block diagram of a database optimization device according to an exemplary embodiment; Fig. 9 is a hardware structure diagram of an electronic device according to an exemplary embodiment; Fig.10 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0018] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be interpreted as limiting the present invention.
[0019] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present disclosure refers to the presence of the features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.
[0020] The present invention provides a database optimization method, which automatically identifies and screens out the most useful data tables by deeply analyzing the amount of data and update frequency in the database, and generates corresponding codes according to the association relationship between the data, thereby solving the problem that the prior art cannot effectively optimize database design and code implementation, resulting in many unnecessary data tables and functions, and low database optimization efficiency. The database optimization method is suitable for a database optimization device, which can be an electronic device. The database optimization method in the embodiment of the present invention can be applied to a variety of scenarios, such as project database optimization, etc.
[0021] See also Figure 1 , an embodiment of the present invention provides a database optimization method, which is applicable to electronic equipment.
[0022] In the following method embodiments, for ease of description, the execution subject of each step of the method is taken as an electronic device as an example for illustration, but this does not constitute a specific limitation.
[0023] like Figure 1 As shown, the method may include the following steps: Step 110, scan the target database to obtain multiple database tables.
[0024] Step 130: Analyze multiple database tables through an algorithm to obtain association relationships between the database tables.
[0025] In one possible implementation, such as Figure 2 As shown, step 130 may include the following steps: Step 210: Set the database table with operation records within a set time as a base table through an algorithm.
[0026] Step 230, traverse the data of all tables and base tables in the target database and compare them, and obtain the database table in which the specific data is associated with the base table as a data association table.
[0027] Step 250, traverse the data of all tables and base tables in the target database and compare them, and obtain a database table whose field names are associated with the base table as a structural association table.
[0028] Step 150: Establish a data table association model based on the association relationships between the database tables.
[0029] The data table association model is a tree structure formed through association analysis. The tree structure can describe the relationship between database tables to a certain extent and is used to indicate the actual effective and useful data tables in the database.
[0030] In one possible implementation, such as Figure 3 As shown, step 150 may include the following steps: Step 310: obtaining multiple base tables in the target database and associated tables corresponding to the base tables according to the associated relationships between the database tables.
[0031] Among them, the association table includes a data association table and a structure association table.
[0032] Step 330: Add each base table and its corresponding associated table to the data table association model.
[0033] Step 350: Perform hierarchical recursive analysis on each base table and its corresponding associated table, and add a data table association model.
[0034] In a possible implementation, hierarchical recursive analysis refers to taking the associated table of each base table as the current base table. The current base table is analyzed by an algorithm to obtain the corresponding associated table, and the current base table and the corresponding associated table are added to the data table associated model until the data table associated model is obtained when the associated table corresponding to the current base table cannot be obtained.
[0035] In a possible implementation, after analyzing the base table to obtain the corresponding association table, a search is performed in the data table association model to determine whether the association table already exists. If not, the association table is added to the data table association model.
[0036] In the above process, repeated references are avoided by searching in the data table association model, and an infinite loop caused by repeated association relationships is avoided, thereby improving accuracy and security.
[0037] Step 170, generate a data model according to the data table association model through the template engine, generate CRUD business code according to the data model and optimize the target database.
[0038] The data model is the database structure design and association relationship, which is used to indicate the association relationship between complete data tables.
[0039] In a possible implementation, the data table association model is converted into a data model and organized into a data model package, and a template engine is used to generate multiple curd business codes according to the data model package.
[0040] Among them, the CRUD business code includes the Vue front-end code and the Springboot back-end code.
[0041] Furthermore, the vue front-end code and springboot back-end code in multiple curd business codes are run to perform corresponding additions, deletions, modifications and queries on the target database to obtain an optimized database.
[0042] Through the above process, the present invention first scans the target database to obtain multiple database tables, then analyzes the multiple database tables through an algorithm to obtain the association relationship between the database tables, and then establishes a data table association model according to the association relationship between the database tables, generates a data model according to the data table association model through a template engine, generates CRUD business code according to the data model and optimizes the target database, and automatically identifies and screens out the most useful data tables through in-depth analysis of the data volume and update frequency in the database, and generates corresponding codes according to the association relationship between the data. This can not only help enterprises streamline the database structure and code implementation of the business system and improve the performance and maintainability of the system, but also effectively reduce the cost of system development and maintenance, bringing substantial economic and competitive advantages, thereby effectively solving the problem that the prior art cannot effectively optimize database design and code implementation, resulting in many unnecessary data tables and functions, and low database optimization efficiency.
[0043] In one application scenario, Figure 4 A flowchart of a database optimization method is shown. Figure 5 The flowchart of the database table analysis algorithm is shown. Figure 6 A schematic diagram showing hierarchical recursive analysis in database table analysis. Figure 7 A flowchart showing how to prevent circular references is shown.
[0044] like Figure 4As shown, first scan the database data, analyze the tables related to the database tables in the database through algorithms, and establish a data table association model. Analyze the data model based on the data table association model, and generate the CRUD business code vue+springboot through the template engine based on the data model. By scanning the database data, analyzing the association relationship between the database tables, establishing a data table association model, and generating the corresponding data model and business code, the database structure and code implementation of the business system are optimized, thereby improving the efficiency and maintainability of the system.
[0045] like Figure 5 As shown, the logic of the database table analysis algorithm may include the following steps: Step A1: After scanning the database data, the tables that have been operated in R years are used as base tables and hung under the root node, for example, root.child = Table A, Table B, Table C.
[0046] Step A1, Step A11: Taking Table A as an example, Table A is the first base table under the root, and two branches are derived for correlation analysis.
[0047] Step A3, Step A13: Traverse the fields of Table A.
[0048] The analysis of data relevance includes the following steps: Step A4: traverse the data of all databases, tables and fields.
[0049] Step A5: Analyze the relevance of field data.
[0050] Step A6: Record the table &A with associated data.
[0051] Step A7: Associate the table with associated data to Table A, for example, Table A.child = Table&A.
[0052] The analysis of structural relevance includes the following steps: Step A14: Traverse all databases, tables and fields.
[0053] Step A15: Analyze the relevance of field names.
[0054] Step A16: Record the table with associated data &&A.
[0055] Step A17: Associate the table with associated data to Table A, for example, A.child = Table&A, Table&&A.
[0056] Finally, we get the data table association model: Root.child = {table A.child = {table&A.child…}…}.
[0057] like Figure 6 As shown, hierarchical recursive analysis in database table analysis includes treating each layer of table as Figure 5 The base table in the table, all the tables associated with the base table are upgraded to the root node. For example, the first-level base table is Table A and Table B scanned according to the rules. At this time, the root is the simulation table. Table A and Table B are used as base tables for the first scan. After the first scan is completed, &A, &&A are used as base tables, and Table A is the root. Figure 5 In the database table analysis, the nth layer analyzes the hierarchical association relationships in the above process in turn until there is no data association and structural association in the database table analysis of a certain layer, and finally a data table association model is constructed.
[0058] like Figure 7 As shown, in order to increase the accuracy and security of the database table analysis algorithm, anti-circular reference is added. Figure 5 In the algorithm logic, there are repeated associations, resulting in an infinite loop. For example, table A.child = &A. and &A.child = table A. This situation is likely to occur. Therefore, in order to avoid repeated references, the present invention designs an anti-duplicate reference mechanism and introduces the concept of a record table. The record table refers to a table that has been recorded in the data table association model. The specific steps are as follows: Figure 5 Insert a judgment step into step A4 and step A14 in the above method: if the scanned table exists in the record table, then give up scanning the table; if the scanned table does not exist in the record table, then perform Figure 5 In step A4 and step A14, if it proceeds to step A7 and step A17, the scanned table will be recorded in the record table.
[0059] Furthermore, the data table association model is converted into a specific data model. The data model is the database table structure design plus the association relationship. The data model is organized and packaged and the template engine is called. The template engine generates specific CRUD business code from the data model, including the Vue front end + springboot back end.
[0060] Through the above process, the embodiment of the present invention deeply analyzes the amount of data and update frequency in the database, automatically identifies and screens out the most useful data tables, and generates corresponding codes according to the association relationship between the data. This can not only help enterprises streamline the database structure and code implementation of the business system and improve the performance and maintainability of the system, but also effectively reduce the cost of system development and maintenance, bringing substantial economic and competitive advantages, thereby effectively solving the problem that the prior art cannot effectively optimize database design and code implementation, resulting in the existence of many unnecessary data tables and functions and low database optimization efficiency.
[0061] In another application scenario, leading technology company A has a complex business system developed internally. As time goes by and the business develops, the system has undergone multiple functional iterations and changes. However, with business changes and replacements, some business lines have ceased operations, resulting in a large number of redundant business modules and data in the system. Company A uses the present invention to reversely reason about existing business modules, use advanced data analysis algorithms to scan the database, accurately identify abandoned business modules and redundant data, and then use powerful template engine technology to regenerate a lightweight existing business system.
[0062] Through the above process, Company A not only reduced the burden on the system, but also greatly saved development costs, maintenance efforts and server resource costs. After the optimization of the system, Company A's business system became more streamlined and efficient, greatly improving the system's performance and maintainability. Through the application of this innovative technology, Company A not only successfully dealt with the problems of system waste accumulation and inefficiency, but also gained huge advantages for its competitiveness in the industry.
[0063] The following is an embodiment of the device of the present invention, which can be used to execute the database optimization method involved in the present invention. For details not disclosed in the embodiment of the device of the present invention, please refer to the method embodiment of the database optimization method involved in the present invention.
[0064] See also Figure 8 , an embodiment of the present invention provides a database optimization device 800.
[0065] The device 800 includes but is not limited to: a database scanning module 810 , a correlation analysis module 830 , a correlation model building module 850 and a database optimization module 870 .
[0066] The database scanning module 810 is used to scan the target database to obtain multiple database tables.
[0067] The association analysis module 830 is used to analyze the multiple database tables through an algorithm to obtain the association relationship between the database tables.
[0068] The association model building module 850 is used to build a data table association model according to the association relationships between the database tables.
[0069] The database optimization module 870 is used to generate a data model according to the data table association model through a template engine, generate CRUD business code according to the data model and optimize the target database.
[0070] It should be noted that, in the database optimization provided in the above embodiment, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the database optimization device will be divided into different functional modules to complete all or part of the functions described above.
[0071] In addition, the database optimization device and the database optimization method provided in the above embodiments belong to the same concept, and the specific manner in which each module performs operations has been described in detail in the method embodiments and will not be repeated here.
[0072] Fig. 9 The present invention schematically illustrates the structure of an electronic device according to an exemplary embodiment.
[0073] It should be noted that the electronic device is only an example adapted to the present invention and cannot be considered to provide any limitation on the scope of use of the present invention. The electronic device cannot be interpreted as requiring dependence on or having Fig. 9 One or more components of exemplary electronic device 2000 are shown.
[0074] The hardware structure of the electronic device 2000 may vary greatly due to differences in configuration or performance, such as Fig. 9 As shown, the electronic device 2000 includes: a power supply 210 , an interface 230 , at least one memory 250 , and at least one central processing unit (CPU) 270 .
[0075] Specifically, the power supply 210 is used to provide operating voltage for each hardware device on the electronic device 2000 .
[0076] The interface 230 includes at least one wired or wireless network interface 231 for interacting with external devices. Of course, in other examples adapted by the present invention, the interface 230 may further include at least one serial-to-parallel conversion interface 233, at least one input-output interface 235, and at least one USB interface 237, etc. Fig. 9 As shown, this is not intended to be a specific limitation.
[0077] The memory 250 is a carrier for storing resources, which may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 251, an application 253 and data 255, etc. The storage method may be temporary storage or permanent storage.
[0078] Among them, the operating system 251 is used to manage and control various hardware devices and application programs 253 on the electronic device 2000 to enable the central processor 270 to calculate and process the massive data 255 in the memory 250. It can be WindowsServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0079] The application program 253 is a computer-readable instruction that performs at least one specific task based on the operating system 251, and may include at least one module ( Fig. 9 (not shown), each module may respectively contain computer-readable instructions for the electronic device 2000. For example, the database optimization device may be regarded as an application 253 deployed on the electronic device 2000.
[0080] The data 255 may be signal information, etc., stored in the memory 250 .
[0081] The central processor 270 may include one or more processors and is configured to communicate with the memory 250 through at least one communication bus to read the computer-readable instructions stored in the memory 250, thereby realizing the operation and processing of the mass data 255 in the memory 250. For example, the database optimization method is completed by the central processor 270 reading a series of computer-readable instructions stored in the memory 250.
[0082] In addition, the present invention can also be implemented by hardware circuits or hardware circuits combined with software. Therefore, the implementation of the present invention is not limited to any specific hardware circuits, software, or a combination of the two.
[0083] See also Fig.10 In an embodiment of the present invention, an electronic device 4000 is provided. The electronic device 4000 may include: a desktop computer, a laptop computer, a server, etc. with sensor recognition capability.
[0084] exist Fig.10 In the embodiment, the electronic device 4000 includes at least one processor 4001 and at least one memory 4003.
[0085] The data interaction between the processor 4001 and the memory 4003 can be realized through at least one communication bus 4002. The communication bus 4002 may include a path for transmitting data between the processor 4001 and the memory 4003. The communication bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The communication bus 4002 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0086] Optionally, the electronic device 4000 may further include a transceiver 4004, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception, etc. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present invention.
[0087] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of the present invention. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0088] The memory 4003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program instructions or codes in the form of instructions or data structures and can be accessed by the electronic device 4000, but is not limited to this.
[0089] The memory 4003 stores computer-readable instructions, and the processor 4001 can read the computer-readable instructions stored in the memory 4003 through the communication bus 4002 .
[0090] The computer-readable instructions are executed by one or more processors 4001 to implement the database optimization method in the above-mentioned embodiments.
[0091] In addition, an embodiment of the present invention provides a storage medium on which computer-readable instructions are stored. The computer-readable instructions are executed by one or more processors to implement the database optimization method as described above.
[0092] A computer program product is provided in an embodiment of the present invention. The computer program product includes computer-readable instructions. The computer-readable instructions are stored in a storage medium. One or more processors of an electronic device read the computer-readable instructions from the storage medium, load and execute the computer-readable instructions, so that the electronic device implements the database optimization method as described above.
[0093] Compared with the related art, the present invention has the following beneficial effects: 1. The present invention first scans a target database to obtain multiple database tables, then analyzes the multiple database tables through an algorithm to obtain the association relationship between the database tables, then establishes a data table association model according to the association relationship between the database tables, generates a data model according to the data table association model through a template engine, generates CRUD business code according to the data model and optimizes the target database, and automatically identifies and screens out the most useful data tables through in-depth analysis of the data volume and update frequency in the database, and generates corresponding codes according to the association relationship between the data. This can not only help enterprises streamline the database structure and code implementation of the business system and improve the performance and maintainability of the system, but also effectively reduce the cost of system development and maintenance, bringing substantial economic and competitive advantages, thereby effectively solving the problem that the prior art cannot effectively optimize database design and code implementation, resulting in many unnecessary data tables and functions and low database optimization efficiency.
[0094] 2. The present invention can automatically optimize: by scanning database data and intelligent analysis algorithms, the system can automatically identify and clean up redundant data tables in the business system, thereby optimizing the database structure. This automated optimization process greatly reduces the burden on developers and improves the efficiency and maintainability of the system.
[0095] 3. The present invention proposes a database-driven intelligent code generation system, which aims to automatically identify and filter out the most useful data tables by deeply analyzing the amount of data and update frequency in the database, and generate corresponding codes according to the association between the data. The system can not only help enterprises streamline the database structure and code implementation of the business system, improve the performance and maintainability of the system, but also effectively reduce the cost of system development and maintenance, bringing substantial economic and competitive advantages to enterprises.
[0096] 4. The present invention can simplify code generation: it can automatically generate CRUD business codes that meet business requirements. This automatic code generation method not only saves a lot of repetitive work for developers, but also ensures the consistency and standardization of the code, thereby improving development efficiency.
[0097] 5. The present invention can improve system performance: by optimizing the database structure and streamlining the code implementation, the system performance has been significantly improved. Cleaning up redundant data tables and streamlining code logic make the system run more efficiently and respond more quickly, thereby improving user experience and business processing efficiency.
[0098] 6. The present invention can reduce development costs: The automated database optimization and code generation process greatly reduces the cost of system development and maintenance. Developers no longer need to manually identify and clean up redundant data tables, nor do they need to manually write a large amount of repeated code, thus saving a lot of time and human resources.
[0099] 7. The present invention can improve the maintainability of the system: The optimized database structure and automatically generated code make the system easier to maintain. The overall architecture of the system is clearer and the code logic is more concise, making subsequent maintenance work easier and more efficient.
[0100] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0101] The above descriptions are only some embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A database optimization method, characterized in that: The method comprises: Scan the target database and obtain multiple database tables; Analyze the multiple database tables through an algorithm to obtain the association relationship between the database tables; Establishing a data table association model according to the association relationships between the database tables; A data model is generated according to the data table association model through a template engine, a CRUD business code is generated according to the data model, and the target database is optimized.
2. The database optimization method according to claim 1, characterized in that: The step of analyzing the plurality of database tables by an algorithm to obtain the association relationship between the database tables includes: The database table having operation records within a set time is set as a base table through an algorithm; Traversing and comparing the data of all tables and base tables in the target database, and obtaining a database table in which specific data is associated with the base table as a data association table; The data of all tables and base tables in the target database are traversed and compared, and a database table whose field names are associated with the base table is obtained as a structure association table.
3. The database optimization method according to claim 1, characterized in that: The step of establishing a data table association model according to the association relationships between the database tables comprises: According to the association relationships between the database tables and the database tables, a plurality of base tables in the target database and association tables corresponding to the base tables are obtained; the association tables include a data association table and a structure association table; Adding each of the base tables and the corresponding association tables to a data table association model; A hierarchical recursive analysis is performed on each of the base tables and the corresponding associated tables, and a data table association model is added.
4. The database optimization method according to claim 3, characterized in that: The step of performing hierarchical recursive analysis on each of the base tables and the corresponding data association tables and structure association tables and adding a data table association model includes: Taking the associated table of each base table as the current base table; The current base table is analyzed by an algorithm to obtain a corresponding association table, and the current base table and the corresponding association table are added to a data table association model until the data table association model is obtained when the association table corresponding to the current base table cannot be obtained.
5. The database optimization method according to claim 3, characterized in that: The method further comprises: After analyzing the base table to obtain the corresponding association table, a search is performed in the data table association model to determine whether the association table already exists. If not, the association table is added to the data table association model.
6. The database optimization method according to claim 1, characterized in that: The step of generating a data model according to the data table association model by using a template engine, generating CRUD business code according to the data model and optimizing the target database includes: Convert the data table association model into a data model and organize it into a data model package; A plurality of CRUDS business codes are generated according to the data model package through a template engine; the CRUDS business codes include a Vue front-end code and a Springboot back-end code.
7. The database optimization method according to claim 6, characterized in that: The method further comprises: Run the Vue front-end code and Springboot back-end code in multiple Curd business codes, perform corresponding additions, deletions, modifications and queries on the target database, and obtain an optimized database.
8. A database optimization device, characterized in that: The device comprises: A database scanning module is used to scan the target database and obtain multiple database tables; An association analysis module, used to analyze the plurality of database tables through an algorithm to obtain associations between the database tables; An association model building module, used to establish a data table association model according to the association relationships between the database tables; The database optimization module is used to generate a data model according to the data table association model through a template engine, generate CRUD business code according to the data model and optimize the target database.
9. An electronic device, characterized in that: include: at least one processor and at least one memory, wherein: The memory has computer-readable instructions stored thereon; The computer-readable instructions are executed by one or more of the processors so that the electronic device implements the database optimization method according to any one of claims 1 to 7.
10. A storage medium having computer-readable instructions stored thereon, characterized in that: The computer-readable instructions are executed by one or more processors to implement the database optimization method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data recovery method and device, equipment and storage medium
CN111382198A
Multi-level data model code generation method and system, storage medium and electronic equipment
CN117742681A
