Database schema generation method and device based on combinatorial optimization, equipment and medium

By obtaining database configuration parameters and conceptual data models, using graph data structures to generate nested key-value pair sets and building a combinatorial optimization model, the problems of low efficiency and accuracy in NoSQL database schema design are solved, and more efficient database schema generation and optimization are achieved.

CN116680254BActive Publication Date: 2025-10-17SHENZHEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310734144.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-19
Publication Date
2025-10-17
Estimated Expiration
2043-06-19

AI Technical Summary

Technical Problem

Existing NoSQL database schema designs rely on manual design, making it difficult to achieve optimal performance under specific loads. They also have low generation efficiency and accuracy, and are greatly affected by the level of designers.

Method used

By obtaining database configuration parameters, space constraints, initial workload and conceptual data model, using graph data structure to represent and generate nested key-value pair sets, building a combinatorial optimization model and inputting it into the preset solver for solution, the database schema and execution plan are generated.

Benefits of technology

Improves the efficiency and accuracy of database schema generation and optimizes database performance under specific loads.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116680254B_ABST
    Figure CN116680254B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a database schema generation method and device based on combinatorial optimization, equipment and medium. The present application relates to the technical field of database schema generation. It includes: obtaining database configuration parameters, spatial constraints, initial workload described by class SQL statements and initial conceptual data model described by text; obtaining workload and conceptual data model by representing the initial workload and the initial conceptual data model through graph data structure; generating a set of nested key-value pairs according to the workload through a nested key-value pair generation method; constructing a combinatorial optimization model according to the set of nested key-value pairs, the conceptual data model, the database configuration parameters and the spatial constraints; inputting the combinatorial optimization model into a preset solver to obtain a database schema and an execution plan of the workload under the database schema. The embodiments of the present application can improve the efficiency and accuracy of database schema generation.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of database schema generation, and particularly relates to a database schema generation method and device based on combinatorial optimization, equipment and medium. BACKGROUND

[0002] The nested key-value storage model is a widely used NoSQL data model. The existing NoSQL database schema design is mainly designed by manual design. The manual design cannot effectively capture the guidance information for the schema design in the workload, that is, the manually designed schema cannot play the optimal performance of the database under a specific load (the load refers to the operation on the database, for example, the delete, modify and other operations). Moreover, the manual design has the problem of low efficiency, and the level of the designer also seriously affects the quality of the design, so that the generation accuracy of the database schema is low. SUMMARY

[0003] The embodiments of the present application provide a database schema generation method and device based on combinatorial optimization, equipment and medium, aiming at solving the problems of low efficiency and accuracy of the database schema generation in the prior art method.

[0004] In a first aspect, the embodiments of the present application provide a database schema generation method based on combinatorial optimization, which comprises:

[0005] Obtaining a database configuration parameter, a space constraint, an initial workload described by a class SQL statement and an initial conceptual data model described by a text;

[0006] Obtaining a workload and a conceptual data model by representing the initial workload and the initial conceptual data model by a graph data structure;

[0007] Generating a nested key-value pair set by a nested key-value pair generation method according to the workload;

[0008] Constructing a combinatorial optimization model according to the nested key-value pair set, the conceptual data model, the database configuration parameter and the space constraint;

[0009] Inputting the combinatorial optimization model into a preset solver to obtain a database schema and an execution plan of the workload under the database schema.

[0010] In a second aspect, the embodiments of the present application further provide a database schema generation device based on combinatorial optimization, which comprises:

[0011] An obtaining unit, configured to obtain a database configuration parameter, a space constraint, an initial workload described by a class SQL statement and an initial conceptual data model described by a text;

[0012] a representation unit, configured to represent the initial workloads and the initial conceptual data model into workloads and conceptual data models through a graph data structure representation;

[0013] a generation unit, configured to generate a set of nested key-value pairs according to the workloads through a nested key-value pair generation method;

[0014] a construction unit, configured to construct a combinatorial optimization model according to the set of nested key-value pairs, the conceptual data model, the database configuration parameters and the spatial constraints;

[0015] a solution unit, configured to input the combinatorial optimization model into a preset solver to obtain a database schema and an execution plan of the workloads under the database schema.

[0016] In a third aspect, an embodiment of the present application further provides a computer device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the above method when executing the computer program.

[0017] In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the above method.

[0018] The embodiment of the present application provides a database schema generation method and device based on combinatorial optimization, and a computer device and a computer readable storage medium. The method comprises the following steps: obtaining database configuration parameters, spatial constraints, an initial workload described by a class SQL statement and an initial conceptual data model described by a text; representing the initial workload and the initial conceptual data model into workloads and conceptual data models through a graph data structure representation; generating a set of nested key-value pairs according to the workloads through a nested key-value pair generation method; constructing a combinatorial optimization model according to the set of nested key-value pairs, the conceptual data model, the database configuration parameters and the spatial constraints; and inputting the combinatorial optimization model into a preset solver to obtain a database schema and an execution plan of the workloads under the database schema. The technical scheme of the embodiment of the present application can improve the database schema generation efficiency and accuracy by constructing a combinatorial optimization model according to the database configuration parameters, the spatial constraints, the workloads and the conceptual data model, and inputting the combinatorial optimization model into a preset solver to obtain a database schema and an execution plan of the workloads under the database schema. BRIEF DESCRIPTION OF DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and all other drawings obtained by those of ordinary skill in the art without creative labor based on the embodiments of the present application also belong to the protection scope of the present application.

[0020] Figure 1 A flowchart of a database schema generation method based on combination optimization provided by the embodiment of the present application is shown in the figure.

[0021] Figure 2 A sub-flowchart of a database schema generation method based on combination optimization provided by the embodiment of the present application is shown in the figure.

[0022] Figure 3 A schematic diagram of key-value pair merging in a database schema generation method based on combination optimization provided by the embodiment of the present application is shown in the figure.

[0023] Figure 4 A schematic diagram of query path deconstruction of a workload in a database schema generation method based on combination optimization provided by the embodiment of the present application is shown in the figure.

[0024] Figure 5 A sub-flowchart of a database schema generation method based on combination optimization provided by the embodiment of the present application is shown in the figure.

[0025] Figure 6 A schematic diagram of workload dependency in a database schema generation method based on combination optimization provided by the embodiment of the present application is shown in the figure.

[0026] Figure 7 A schematic block diagram of a database schema generation device based on combination optimization provided by the embodiment of the present application is shown in the figure.

[0027] Figure 8 A schematic block diagram of a computer device provided by the embodiment of the present application is shown in the figure. DETAILED DESCRIPTION

[0028] The technical solutions in the embodiments of the present application will be described clearly and completely below with the drawings in the embodiments of the present application. Obviously, the described embodiments are some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor also belong to the protection scope of the present application.

[0029] It should be understood that the terms "comprises" and "comprising," when used in this specification and the following claims, indicate the presence of the described features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0030] It should also be understood that the terms used in the specification and the appended claims are intended to describe certain embodiments and do not intentionally limit the application. As used in the description and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0031] It should also be further understood that the term "and / or" as used in the specification and the appended claims, means any one or more of the associated listed items, as well as all possible combinations of the items.

[0032] As used in the specification and the appended claims, the term "if' can be construed to mean "when" or "once," or "in response to a determination" or "in response to a detection" of, as appropriate, depending on the context. Similarly, the phrase "if it is determined" or "if [a described condition or event] is detected" can be construed to mean "once it is determined" or "in response to the determination" or "once [the described condition or event] is detected" or "in response to the detection," depending on the context.

[0033] Referring to Figure 1 , Figure 1 is a flowchart of a database schema generation method based on combinatorial optimization provided by an embodiment of the application. The database schema generation method based on combinatorial optimization of the embodiment of the application is applied to a database schema generation system. For example, the database schema generation method based on combinatorial optimization can be implemented by configuring a software program corresponding to the database schema generation system, thereby improving the efficiency and accuracy of database schema generation. It should be noted that the database schema generated by the database schema generation system in the embodiment is a NoSQL database schema. The database schema generation system includes an input module, a processing module, and an output module. As shown in Figure 1 the method includes the following steps S110-S150.

[0034] S110, obtaining database configuration parameters, spatial constraints, an initial workload described by a class SQL statement, and an initial conceptual data model described by text.

[0035] In the embodiment of the present application, the input module acquires database configuration parameters, space constraints, an initial workload described by a class SQL statement, and an initial conceptual data model described by text, wherein the database configuration parameters include index time, network transmission time, and the like; the space constraints are the storage space occupied by the generated database schema; the initial workload includes queries, insertions, deletions, and modifications, and the like; and the initial conceptual data model includes the cardinality of the relationship between entities, the estimated number of entities, the attributes of entities, and the types and sizes of the attributes. It should be noted that the entities in the initial conceptual data model refer to the entities in the ER diagram. Taking the relationship between students and courses as an example, the cardinality of the relationship between the above entities is described, the students and courses represent two entities, and in data modeling, the cardinality of the relationship between entities refers to the proportional relationship between the number of values of a certain attribute in one entity and the number of values of a certain attribute in another entity in the relationship between the two entities. The cardinality of the relationship between entities is usually divided into three types, including 1:1, 1:N, and N:M, which represent one-to-one relationship, one-to-many relationship, and many-to-many relationship, respectively.

[0036] In the embodiment of the present application, the input module acquires database configuration parameters, space constraints, an initial workload described by a class SQL statement, and an initial conceptual data model described by text, wherein the database configuration parameters include index time, network transmission time, and the like; the space constraints are the storage space occupied by the generated database schema; the initial workload includes queries, insertions, deletions, and modifications, and the like; and the initial conceptual data model includes the cardinality of the relationship between entities, the estimated number of entities, the attributes of entities, and the types and sizes of the attributes. It should be noted that the entities in the initial conceptual data model refer to the entities in the ER diagram. Taking the relationship between students and courses as an example, the cardinality of the relationship between the above entities is described, the students and courses represent two entities, and in data modeling, the cardinality of the relationship between entities refers to the proportional relationship between the number of values of a certain attribute in one entity and the number of values of a certain attribute in another entity in the relationship between the two entities. The cardinality of the relationship between entities is usually divided into three types, including 1:1, 1:N, and N:M, which represent one-to-one relationship, one-to-many relationship, and many-to-many relationship, respectively.

[0037] In the embodiment of the present application, the input module acquires database configuration parameters, space constraints, an initial workload described by a class SQL statement, and an initial conceptual data model described by text, wherein the database configuration parameters include index time, network transmission time, and the like; the space constraints are the storage space occupied by the generated database schema; the initial workload includes queries, insertions, deletions, and modifications, and the like; and the initial conceptual data model includes the cardinality of the relationship between entities, the estimated number of entities, the attributes of entities, and the types and sizes of the attributes. It should be noted that the entities in the initial conceptual data model refer to the entities in the ER diagram. Taking the relationship between students and courses as an example, the cardinality of the relationship between the above entities is described, the students and courses represent two entities, and in data modeling, the cardinality of the relationship between entities refers to the proportional relationship between the number of values of a certain attribute in one entity and the number of values of a certain attribute in another entity in the relationship between the two entities. The cardinality of the relationship between entities is usually divided into three types, including 1:1, 1:N, and N:M, which represent one-to-one relationship, one-to-many relationship, and many-to-many relationship, respectively.

[0038] In the embodiment of the present application, the input module acquires database configuration parameters, space constraints, an initial workload described by a class SQL statement, and an initial conceptual data model described by text, wherein the database configuration parameters include index time, network transmission time, and the like; the space constraints are the storage space occupied by the generated database schema; the initial workload includes queries, insertions, deletions, and modifications, and the like; and the initial conceptual data model includes the cardinality of the relationship between entities, the estimated number of entities, the attributes of entities, and the types and sizes of the attributes. It should be noted that the entities in the initial conceptual data model refer to the entities in the ER diagram. Taking the relationship between students and courses as an example, the cardinality of the relationship between the above entities is described, the students and courses represent two entities, and in data modeling, the cardinality of the relationship between entities refers to the proportional relationship between the number of values of a certain attribute in one entity and the number of values of a certain attribute in another entity in the relationship between the two entities. The cardinality of the relationship between entities is usually divided into three types, including 1:1, 1:N, and N:M, which represent one-to-one relationship, one-to-many relationship, and many-to-many relationship, respectively.

[0039] In the embodiment of the present application, the input module acquires database configuration parameters, space constraints, an initial workload described by a class SQL statement, and an initial conceptual data model described by text, wherein the database configuration parameters include index time, network transmission time, and the like; the space constraints are the storage space occupied by the generated database schema; the initial workload includes queries, insertions, deletions, and modifications, and the like; and the initial conceptual data model includes the cardinality of the relationship between entities, the estimated number of entities, the attributes of entities, and the types and sizes of the attributes. It should be noted that the entities in the initial conceptual data model refer to the entities in the ER diagram. Taking the relationship between students and courses as an example, the cardinality of the relationship between the above entities is described, the students and courses represent two entities, and in data modeling, the cardinality of the relationship between entities refers to the proportional relationship between the number of values of a certain attribute in one entity and the number of values of a certain attribute in another entity in the relationship between the two entities. The cardinality of the relationship between entities is usually divided into three types, including 1:1, 1:N, and N:M, which represent one-to-one relationship, one-to-many relationship, and many-to-many relationship, respectively. Figure 2As shown, step S130 includes the following steps: S131, if the workload is a preset workload, generating an initial nested key-value pair for the workload by a materialized view manner; S132, traversing each key-value pair in a preset nested key-value pair set to determine whether the key-value pair can be merged with the initial nested key-value pair to obtain a merging result; S133, generating a nested key-value pair set according to the merging result, the preset nested key-value pair set and the initial nested key-value pair. Specifically, step S133 is to determine whether the merging result is a new nested key-value pair that can be generated by merging; if the merging result is the new nested key-value pair that can be generated by merging, the initial nested key-value pair is put into the preset nested key-value pair set for merging to generate a nested key-value pair set; if the merging result is the new nested key-value pair that cannot be generated by merging, the initial nested key-value pair is deconstructed to generate a deconstructed key-value pair, and the nested key-value pair set is generated according to the deconstructed key-value pair and the preset nested key-value pair set. More specifically, a query path composed of nodes corresponding to the initial nested key-value pair is deconstructed to obtain a first query path and a second query path; the first query path and the second query path are split and deconstructed according to a split point of the first query path and the second query path to obtain a first deconstructed path and a second deconstructed path; the first deconstructed path and the second deconstructed path are used to generate the initial nested key-value pair by the materialized view manner, and the step of traversing each key-value pair in the preset nested key-value pair set to determine whether the key-value pair can be merged with the initial nested key-value pair to obtain a merging result is returned until the path cannot be split and deconstructed.

[0040] It should be noted that, in the embodiment, the preset workload is other than the Insert statement and the Delete statement, that is, the Insert statement and the Delete statement are not the preset workload, and the preset workload includes a query statement, an update statement, a modification statement and the like.

[0041] For the convenience of understanding, the process of step S130 in a specific actual application will be introduced as follows:

[0042] The selection list following the Select predicate of the query statement is denoted as an array S[], the path list following the From predicate is denoted as an array P[], and the condition list following the Where predicate is denoted as an array W[]. For example, in the statement "Select A.*", S[0] represents A.ID; in the statement "From A.B.C", P[0] represents A and P[2] represents C.

[0043] (a) generating an initial nested key-value pair for the workload by a materialized view manner;

[0044] First, it is judged whether the attribute represented by W[0] is the primary key of its corresponding entity. If not, a key-value pair <w[0], w[0].entity.ID> is generated, where "w[0].entity.ID" represents whether the attribute represented by "W[0]" is the primary key of its corresponding entity. The key-value pair can be used as a secondary index. If yes, a nested key-value pair KV is generated, which contains all entities in the path P[]. For an entity in P[], if its attribute appears in S[] or W[], then all attributes of the corresponding entity in P[] need to be included in the nested key-value pair KV when generating the nested key-value pair KV. Otherwise, only the primary key field of the entity needs to be included.

[0045] (b) Merging key-value pairs

[0046] The initial nested key-value pair generated in step (a) is added to the generated key-value pair set SC, where the key-value pair set SC is a preset nested key-value pair set. When adding to the SC set, each key-value pair in each set SC is traversed to determine whether the key-value pair can be merged with the initial nested key-value pair. Specifically, it is determined whether the key-value pair and the initial nested key-value pair have the same prefix node. If the key-value pair and the initial nested key-value pair have the same prefix node, the merging result is set to be able to merge to generate a new nested key-value pair. If the key-value pair and the initial nested key-value pair do not have the same prefix node, the merging result is set to be unable to merge to generate the new nested key-value pair. As shown in Figure 3 the same prefix nodes A and B are merged to generate a new nested key-value pair.

[0047] (c) Generating key-value pairs by deconstructing the query path

[0048] The query path P[] corresponding to the workload is deconstructed, as shown in Figure 4As shown, the query path P[] is split into two parts P'[] and P''[], so that the query can be executed along the P'[] path first and then along the P''[] path to complete the entire query. When the path is deconstructed, the split point is each entity corresponding to the W[] list, for example, when W[1]="B.attr1=?" and W[2]="B.attr2>?", W[1] and W[2] correspond to the same entity, and only need to be split at the B entity. At the same time, the W[] list also needs to be split into two parts, W'[] and W''[], and in this example, needs to be split from W[1], and W[1] is the first element of W''[]. After the deconstruction is executed, S[], W'[], and P'[] are used as inputs of (a) to execute step (a) to generate new initial nested key-value pairs, and the cycle is repeated until the query path corresponding to the workload cannot be deconstructed.

[0049] S140, constructing a combinatorial optimization model according to the nested key-value pair set, the conceptual data model, the database configuration parameter, and the spatial constraint.

[0050] In an embodiment of the present application, after the nested key-value pair set is generated, a combinatorial optimization model is constructed according to the nested key-value pair set, the conceptual data model, the database configuration parameter, and the spatial constraint. Specifically, as shown in Figure 5 S140, constructing a combinatorial optimization model according to the nested key-value pair set, the conceptual data model, the database configuration parameter, and the spatial constraint.

[0051] Further, in actual application, a directed graph G is used to represent the front-back dependency relationship between the key-value pairs in the nested key-value pair set, for example, when a query Q1 generates a set of nested key-value pairs {kv1-7}, these key-value pairs need to complete the Q1 query and have the following Figure 6 dependency relationship, as shown. Understandably, in Figure 6Among them, three paths can complete the Q1 query, which are: start->KV1->KV3->KV4->end, start->KV1->KV2->end, start->KV1->KV3->KV5->KV7->KV6->end, these dependencies together with the spatial constraints constitute the constraint conditions of the combined optimization model. It should be noted that the spatial constraint is also taken as a constraint condition because the design result can be denormalized when modeling, so the spatial constraint will be given in the input module.

[0052] Further, the objective function of the combined optimization model is the calculation of the cost, and the calculation of the cost needs to be combined with the specific implementation of the database, therefore, when constructing the objective function, the database configuration parameters, the conceptual data model and the workload need to be considered comprehensively. It should be noted that when constructing the objective function, the workload only includes Insert statements and Delete statements.

[0053] S150, input the combined optimization model into a preset solver to obtain a database mode and an execution plan of the workload under the database mode.

[0054] In the embodiment of the application, the combined optimization model is input into a preset solver to obtain a database mode and an execution plan of the workload under the database mode, wherein the preset solver is software used to solve mathematical programming problems, including gurobi, sci, glpk; the preset solver solves the minimum value of the total response time; the execution plan is a set of operations for a certain workload under the generated database mode. For example, when the workload is query Q1, the generated database mode contains nested key-value pairs KV1, KV2, KV3 and KV4. When query Q1 needs to be executed, the stored execution plan is: first execute KV1 query, then execute KV2, and then execute KV4. Similarly, when the workload is deletion, the execution plan is: find the position of the key-value pair to be deleted->delete; when the workload is insertion, the execution plan is: find the position to be inserted->insert.

[0055] It should be noted that the generated database mode is a nested key-value storage model, for example, a key-value pair storage database or a document type database in a NoSQL database mode; it should also be noted that the user converts the execution plan into an execution operation under the database mode according to the execution plan combined with the operation of the database mode, inputs the execution operation into the database mode, and executes the execution operation to obtain an operation result. It should also be noted that the execution plan is an execution paradigm, and the execution operation can replace the values in the execution paradigm to obtain different operation results.

[0056] Figure 7 is a schematic block diagram of a database schema generation apparatus 200 based on combinatorial optimization provided by an embodiment of the present application. As shown in Figure 7 corresponding to the above database schema generation method based on combinatorial optimization, the present application also provides a database schema generation apparatus 200 based on combinatorial optimization. The database schema generation apparatus 200 based on combinatorial optimization includes units for executing the above database schema generation method based on combinatorial optimization, and the apparatus can be configured in a computer device. Specifically, please refer to Figure 7 , the database schema generation apparatus 200 based on combinatorial optimization includes an acquisition unit 201, a representation unit 202, a generation unit 203, a construction unit 204, and a solving unit 205.

[0057] The acquisition unit 201 is configured to acquire database configuration parameters, spatial constraints, an initial workload described by a class SQL statement, and an initial conceptual data model described by text; the representation unit 202 is configured to represent the initial workload and the initial conceptual data model by a graph data structure to obtain a workload and a conceptual data model; the generation unit 203 is configured to generate a set of nested key-value pairs according to the workload by a nested key-value pair generation method; the construction unit 204 is configured to construct a combinatorial optimization model according to the set of nested key-value pairs, the conceptual data model, the database configuration parameters, and the spatial constraints; and the solving unit 205 is configured to input the combinatorial optimization model into a preset solver to obtain a database schema and an execution plan of the workload in the database schema.

[0058] In some embodiments, such as the present embodiment, the generation unit 203 includes a first generation subunit, a judgment unit, and a second generation subunit.

[0059] The first generation subunit is configured to generate an initial nested key-value pair from the workload by a materialized view method if the workload is a preset workload; the judgment unit is configured to traverse each key-value pair in a preset set of nested key-value pairs to determine whether the key-value pair can be merged with the initial nested key-value pair to obtain a merging result; and the second generation subunit is configured to generate a set of nested key-value pairs according to the merging result, the preset set of nested key-value pairs, and the initial nested key-value pair.

[0060] In some embodiments, such as the present embodiment, the second generation subunit includes a third generation subunit and a fourth generation subunit.

[0061] The third generating sub-unit is configured to, if the merging result is that the new nested key-value pair can be generated, put the initial nested key-value pair into a preset nested key-value pair set for merging to generate a nested key-value pair set.

[0062] In some embodiments, for example in the present embodiment, the fourth generating sub-unit comprises a querying unit, a deconstructing unit and a fifth generating sub-unit.

[0063] The querying unit is configured to deconstruct a query path composed of nodes corresponding to the initial nested key-value pair to obtain a first query path and a second query path; the deconstructing unit is configured to split and deconstruct the first query path and the second query path according to a split point to obtain a first deconstructed path and a second deconstructed path; and the fifth generating sub-unit is configured to generate the initial nested key-value pair through the materialized view mode by using the first deconstructed path and the second deconstructed path, and return to execute the step of iterating through each key-value pair in the preset nested key-value pair set to determine whether the key-value pair can be merged with the initial nested key-value pair to obtain a merging result, until the path cannot be split and deconstructed.

[0064] In some embodiments, for example in the present embodiment, the judging unit comprises a judging sub-unit, a first setting unit and a second setting unit.

[0065] The judging sub-unit is configured to determine whether the key-value pair has the same prefix node as the initial nested key-value pair; the first setting unit is configured to, if the key-value pair has the same prefix node as the initial nested key-value pair, set the merging result as that the new nested key-value pair can be generated; and the second setting unit is configured to, if the key-value pair does not have the same prefix node as the initial nested key-value pair, set the merging result as that the new nested key-value pair cannot be generated.

[0066] In some embodiments, for example in the present embodiment, the constructing unit 204 comprises a first serving unit, a second serving unit and a constructing sub-unit.

[0067] Among them, the first unit is used to use the nested key-value pair set as the discrete decision space of the combinatorial optimization model, and set the decision variables of the combinatorial optimization model to preset types; the second unit is used to use the dependency relationship in the nested key-value pairs and the spatial constraints as constraints of the combinatorial optimization model; the construction subunit is used to construct the overall response time function of the workload based on the database configuration parameters, the conceptual data model and the workload, and use the overall response time function of the workload as the objective function of the combinatorial optimization model.

[0068] In some embodiments, such as this embodiment, the database schema generation apparatus 200 based on combinatorial optimization further includes an acquisition execution unit.

[0069] The acquisition and execution unit is used to acquire an execution operation and execute the execution operation to obtain an operation result.

[0070] The specific implementation of the database schema generation device 200 based on combinatorial optimization in the embodiment of the present invention corresponds to the above-mentioned database schema generation method based on combinatorial optimization, which will not be described in detail here.

[0071] The above-mentioned database schema generation device based on combinatorial optimization can be implemented in the form of a computer program. The computer program can be used in Figure 8 Runs on the computer equipment shown.

[0072] See also Figure 8 , Figure 8 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 300 is a server. Specifically, the server can be a standalone server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.

[0073] See Figure 8 The computer device 300 includes a processor 302 , a memory, and a network interface 305 connected via a system bus 301 , wherein the memory may include a storage medium 303 and an internal memory 304 .

[0074] The storage medium 303 may store an operating system 3031 and a computer program 3032. When the computer program 3032 is executed, the processor 302 may execute a database schema generation method based on combinatorial optimization.

[0075] The processor 302 is configured to provide computing and control capabilities to support the operation of the entire computer device 300.

[0076] The internal memory 304 provides an environment for the operation of the computer program 3032 in the storage medium 303, and the computer program 3032, when executed by the processor 302, can cause the processor 302 to perform a database schema generation method based on combinatorial optimization.

[0077] The network interface 305 is configured to perform network communication with other devices. Those skilled in the art can understand that the network interface 305 can be implemented in various forms, such as a network card, a modem, and the like. Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device 300 to which the scheme of the present application is applied. The specific computer device 300 can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0078] The processor 302 is configured to execute the computer program 3032 stored in the memory to implement the flow steps of the embodiments of the above method.

[0079] It should be understood that, in the embodiments of the present application, the processor 302 can be a central processing unit (CPU), and the processor 302 can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.

[0080] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments of the method can be completed by a computer program instructing related hardware. The computer program can be stored in a storage medium, which is a computer readable storage medium. The computer program is executed by at least one processor in the computer system to implement the flow steps of the embodiments of the above-mentioned method.

[0081] Therefore, the present application also provides a storage medium. The storage medium can be a computer readable storage medium. The storage medium stores a computer program. The computer program is executed by the processor to cause the processor to execute any embodiment of the above-mentioned database schema generation method based on combinatorial optimization.

[0082] The storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, and various computer readable storage media that can store program codes.

[0083] Those skilled in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been described in the above description in a general manner. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0084] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and actual implementation can have another division manner. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0085] The steps in the method embodiments of the present application can be adjusted, combined and reduced in sequence according to actual needs. The units in the device embodiments of the present application can be combined, divided and reduced according to actual needs. In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit.

[0086] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a storage medium. Based on such understanding, the technical solutions of the present application essentially or the parts that make contributions to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a terminal or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application.

[0087] In the above embodiments, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0088] It will be apparent to those skilled in the art that various modifications and variations can be made to the present application without departing from the spirit or scope of the application. Thus, it is intended that the present application cover modifications and variations of this application provided they come within the scope of the appended claims and their equivalents.

[0089] The above descriptions are only the specific embodiments of the application, but the protection scope of the application is not limited to this. Any skilled person in the art can easily think of various equivalent modifications or replacements within the technical range disclosed by the application, and these modifications or replacements should be covered in the protection scope of the application. Therefore, the protection scope of the application should be subject to the protection scope of the claims.

Claims

1. A database schema generation method based on combinatorial optimization, characterized in that: include: Obtain database configuration parameters, space constraints, initial workload described by SQL-like statements, and initial conceptual data model described in text; Representing the initial workload and the initial conceptual data model through a graph data structure to obtain a workload and a conceptual data model; Generate a nested key-value pair set according to the workload using a nested key-value pair generation method; Constructing a combination optimization model based on the nested key-value pair set, the conceptual data model, the database configuration parameters, and the spatial constraints; Inputting the combinatorial optimization model into a preset solver for solving to obtain a database schema and an execution plan of the workload under the database schema; The step of constructing a combinatorial optimization model based on the nested key-value pair set, the conceptual data model, the database configuration parameters, and the spatial constraints includes: Using the nested key-value pair set as a discrete decision space of a combinatorial optimization model, and setting the decision variables of the combinatorial optimization model to a preset type; Using the dependency relationship in the nested key-value pairs and the space constraint as constraint conditions of the combinatorial optimization model; An overall response time function of the workload is constructed according to the database configuration parameters, the conceptual data model, and the workload, and the overall response time function of the workload is used as an objective function of the combined optimization model.

2. The method according to claim 1, characterized in that The step of generating a nested key-value pair set according to the workload by using a nested key-value pair generation method includes: If the workload is a preset workload, generating an initial nested key-value pair from the workload by means of a materialized view; Traversing each key-value pair in the preset nested key-value pair set to determine whether the key-value pair can be merged with the initial nested key-value pair to obtain a merged result; A nested key-value pair set is generated according to the merging result, the preset nested key-value pair set and the initial nested key-value pairs.

3. The method according to claim 2, characterized in that The step of generating a nested key-value pair set according to the merging result, the preset nested key-value pair set, and the initial nested key-value pair comprises: If the merging result is that a new nested key-value pair can be generated by merging, then the initial nested key-value pair is placed in a preset nested key-value pair set for merging to generate a nested key-value pair set; If the merging result is that the new nested key-value pair cannot be merged to generate the new nested key-value pair, the initial nested key-value pair is deconstructed to generate a deconstructed key-value pair, and the nested key-value pair set is generated according to the deconstructed key-value pair and the preset nested key-value pair set.

4. The method according to claim 3, characterized in that The step of deconstructing the initial nested key-value pairs to generate deconstructed key-value pairs, and generating the nested key-value pair set according to the deconstructed key-value pairs and the preset nested key-value pair set includes: Deconstructing the query path composed of the nodes corresponding to the initial nested key-value pairs to obtain a first query path and a second query path; Splitting and deconstructing the path according to the splitting points of the first query path and the second query path to obtain a first deconstructed path and a second deconstructed path; The first deconstruction path and the second deconstruction path are used to generate the initial nested key-value pairs through the materialized view method, and the step of traversing each key-value pair in the preset nested key-value pair set to determine whether the key-value pair can be merged with the initial nested key-value pair to obtain a merged result is returned until the path cannot be split and deconstructed.

5. The method according to claim 2, characterized in that The step of determining whether the key-value pair can be merged with the initial nested key-value pair to obtain a merged result includes: Determine whether the key-value pair has the same prefix node as the initial nested key-value pair; If the key-value pair and the initial nested key-value pair have the same prefix node, the merge result is set to be merged to generate a new nested key-value pair; If the key-value pair and the initial nested key-value pair do not have the same prefix node, the merging result is set to be unable to be merged to generate the new nested key-value pair.

6. The method according to claim 1, characterized in that After the step of inputting the combinatorial optimization model into a preset solver to solve and obtain a database schema and an execution plan of the workload under the database schema, the method further includes: An execution operation is acquired, and the execution operation is executed to obtain an operation result.

7. A database schema generation device based on combinatorial optimization, characterized in that: include: An acquisition unit, used to acquire database configuration parameters, space constraints, an initial workload described by a SQL-like statement, and an initial conceptual data model described by a text; a representation unit, configured to represent the initial workload and the initial conceptual data model through a graph data structure to obtain a workload and a conceptual data model; A generating unit, configured to generate a nested key-value pair set according to the workload by using a nested key-value pair generating method; A construction unit, configured to construct a combination optimization model according to the nested key-value pair set, the conceptual data model, the database configuration parameters, and the spatial constraints; A solving unit, configured to input the combinatorial optimization model into a preset solver for solving to obtain a database schema and an execution plan of the workload under the database schema; The building blocks include: The first unit is used to use the nested key-value pair set as a discrete decision space of a combinatorial optimization model, and set the decision variables of the combinatorial optimization model to a preset type; The second unit is used to use the dependency relationship in the nested key-value pairs and the space constraint as constraint conditions of the combinatorial optimization model; A construction subunit is used to construct an overall response time function of the workload based on the database configuration parameters, the conceptual data model and the workload, and use the overall response time function of the workload as the objective function of the combined optimization model.

8. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 6 when executing the computer program.

9. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Database function calling method and system, computer equipment and storage medium

    CN110502530A

  • Database configuration tuning method, apparatus and device, and readable storage medium

    CN116150128A