Data storage method, electronic device, and computer-readable storage medium

By dividing query field groups and extracting subquery field groups in the knowledge graph, and determining the storage location of predicate fields based on the number of queries, the data overflow and query self-connection problems caused by predicate field storage in the knowledge graph are solved, and a more efficient and accurate query process is achieved.

CN119783791APending Publication Date: 2025-04-08MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411844725.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

When storing predicate fields in the knowledge graph, the prior art can easily lead to data overflow and query self-connection, affecting query efficiency and accuracy.

Method used

By dividing multiple query fields in the query record of the knowledge graph into multiple query field groups, and extracting subquery field groups based on the query type and number of query times of the predicate field, determining the storage location of the predicate field in the preset table, and generating a second knowledge graph to optimize storage.

Benefits of technology

It effectively reduces data overflow, reduces the occurrence of query self-connection, and improves the efficiency and accuracy of knowledge graph query.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119783791A_ABST
    Figure CN119783791A_ABST
Patent Text Reader

Abstract

The present application provides a data storage method, an electronic device, and a computer-readable storage medium; the data storage method includes: dividing a plurality of query fields included in a query record of a first knowledge graph into a plurality of query field groups, the query field groups including a subject field type and a predicate field; for each query field group, extracting a plurality of sub-query field groups from the query field group according to the query type of the predicate field, each sub-query field group including a query field whose query times are greater than a query times threshold; for a query field in each sub-query field group, determining a first storage position of a predicate field of the query field in a preset table according to the query times of the query field, and storing the predicate field in a first storage position in the preset table; generating a second knowledge graph according to the preset table storing the predicate field. Through the present application, the storage position of the predicate field in the storage table in the knowledge graph can be optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to data storage technology, and more particularly to a data storage method, an electronic device, and a computer-readable storage medium. Background Art

[0002] Knowledge graph is a large-scale knowledge representation model based on semantic technology. The basic building block of knowledge graph is fact data, and each fact data is represented as a triple of "subject-predicate-object". Knowledge graph can organically integrate scattered information and build a complete and rich knowledge network, thereby providing support and guidance for various application scenarios. Through knowledge graph storage, the potential relationship between data can be mined to provide support for knowledge discovery and data mining. Therefore, the storage of knowledge graph has become a hot research issue. Summary of the invention

[0003] The embodiments of the present application provide a data storage method, an electronic device, and a computer-readable storage medium, which can optimize the storage position of a predicate field in a knowledge graph in a storage table.

[0004] The technical solution of the embodiment of the present application is implemented as follows:

[0005] The present invention provides a data storage method, the method comprising:

[0006] Divide the multiple query fields included in the query record of the first knowledge graph into multiple query field groups, each of the query fields includes a subject field type and a predicate field, and one query field group includes multiple query fields with the same subject field type;

[0007] For each of the query field groups, extract multiple sub-query field groups from the query field group according to the query type of the predicate field, each of the sub-query field groups includes the query field whose query times are greater than a query times threshold;

[0008] For the query field in each sub-query field group, determine the first storage position of the predicate field of the query field in a preset table according to the query times of the query field, and store the predicate field in the first storage position of the preset table;

[0009] A second knowledge graph is generated according to the preset table storing the predicate field.

[0010] The present application provides a data storage device, including:

[0011] A first determination module is used to divide the multiple query fields included in the query record of the first knowledge graph into multiple query field groups, each of the query fields includes a subject field type and a predicate field, and one query field group includes multiple query fields with the same subject field type;

[0012] A second determining module is configured to extract, for each query field group, a plurality of sub-query field groups from the query field group according to the query type of the predicate field, each of the sub-query field groups including the query field having a query number greater than a query number threshold;

[0013] a third determining module, configured to determine, for the query field in each sub-query field group, a first storage position of a predicate field of the query field in a preset table according to the query times of the query field, and store the predicate field in the first storage position of the preset table;

[0014] The graph generation module is used to generate a second knowledge graph according to the preset table storing the predicate field.

[0015] An embodiment of the present application provides an electronic device, the electronic device comprising:

[0016] A memory for storing computer executable instructions or computer programs;

[0017] The processor is used to implement the data storage method provided in the embodiment of the present application when executing the computer executable instructions or computer programs stored in the memory.

[0018] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions or a computer program for implementing the data storage method provided in the embodiment of the present application when executed by a processor.

[0019] An embodiment of the present application provides a computer program product, including computer executable instructions or a computer program. When the computer executable instructions or the computer program are executed by a processor, the data storage method provided by the embodiment of the present application is implemented.

[0020] The embodiments of the present application have the following beneficial effects:

[0021] By dividing the multiple query fields included in the query record of the first knowledge graph into multiple query field groups, each query field includes a subject field type and a predicate field, and a query field group includes multiple query fields with the same subject field type, it is achieved that the multiple query fields are divided into query field groups with different subject field types, and then for each query field group, multiple sub-query field groups are extracted from the query field group according to the query type of the predicate field, each sub-query field group includes a query field with a query count greater than a query count threshold, and multiple sub-query field groups can be mined based on the query type of the predicate field, and then for the query field in each sub-query field group, the first storage position of the predicate field of the query field in the preset table is determined according to the query count of the query field, and the predicate field is stored in the first storage position in the preset table, which can be based on the query type of the predicate field. The number of queries of the query field in each sub-query field group is used to determine the storage position of the predicate field in the storage table, and the storage position of different predicate fields of the same subject category is determined. Different predicate fields of the same subject category are stored in different columns as much as possible to reduce data overflow. Then, a second knowledge graph is generated according to the preset table storing the predicate field. In the process of querying using the second knowledge graph, the situation in which a node in the knowledge graph is connected to itself or other nodes through several edges can be reduced, that is, the query self-connection situation can be reduced, and accurate results can be found. In this way, the number of combined use queries of different predicate fields of the same subject category is taken into account, and different predicate fields of the same subject category are stored in different columns based on the number of queries, which reduces data overflow and optimizes the storage position of the predicate field in the storage table in the knowledge graph. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 This is a schematic diagram of an application mode of the data storage method provided in an embodiment of the present application;

[0023] Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0024] Figure 3A This is a first flow chart of the data storage method provided by an embodiment of the present application;

[0025] Figure 3B This is a second flow chart of the data storage method provided in an embodiment of the present application;

[0026] Figure 3C is a third flow chart of the data storage method provided in an embodiment of the present application;

[0027] Figure 3D This is a fourth flow chart of the data storage method provided in an embodiment of the present application;

[0028] Figure 4It is a schematic diagram of the knowledge graph provided in the related technology;

[0029] Figure 5 It is a schematic diagram of the DB2RDF knowledge graph storage mode provided in the related art;

[0030] Figure 6 It is a hash function table provided in the related art;

[0031] Figure 7 It is a flowchart of the data storage method provided in an embodiment of the present application.

[0032] It should be pointed out that the above-mentioned "first" and "second" are only used to distinguish different solutions, and do not represent the degree of superiority or inferiority of the solutions or the priority in the implementation process. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0034] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0035] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0036] It should be pointed out that the relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant national laws and regulations when applied in examples, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of authorization of laws and regulations and the personal information subject.

[0037] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0038] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0039] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0040] 1) Knowledge graph: Knowledge graph is a structured knowledge representation method that organizes and represents knowledge through a graphical model. Nodes in a knowledge graph usually represent entities (such as people, places, things, concepts, etc.), while edges represent the relationships between entities. The basic building block of a knowledge graph is fact data, and each fact data is represented as a triple of "subject-predicate-object" information.

[0041] 2) Relational database: refers to a database that uses a relational model to organize data. It stores data in the form of rows and columns. The relational model can be simply understood as a two-dimensional table model, and a relational database is a database composed of two-dimensional tables and the relationships between them.

[0042] 3) Resource Description Framework (Database to RDF, DB2RDF): It is an RDF knowledge graph storage solution based on a relational database, consisting of four storage tables: the primary hash table (dph table), the secondary hash table (ds table), the reverse primary hash table (rph table) and the reverse secondary hash table (rs table).

[0043] 4) Frequent item sets: are sets of items (or objects) that appear frequently in multiple transactions. For example, in shopping basket analysis, milk and bread are often purchased together, so <"bread", "milk"> is a frequent item set. The frequent items are "bread" and "milk".

[0044] 5) Frequent Itemset Growth Algorithm (FP-Grouth): It is an algorithm used for frequent item set mining. It constructs a frequent pattern tree (FP-Tree) and generates frequent item sets based on the structure of the frequent pattern tree.

[0045] 6) Query self-connection: When executing a knowledge graph query, the graph algorithm will generate a self-circulating path in the knowledge graph. This path is called self-connection in graph theory. A self-connection path means that a node in the graph is connected to itself or other nodes through several edges, making the query result non-unique and difficult to find accurate results.

[0046] In the related art, for the storage of predicate fields in the knowledge graph, a set of hash functions is used to map all predicate fields to the storage table, which will cause data overflow.

[0047] The embodiments of the present application provide a data storage method, an electronic device, and a computer-readable storage medium, which can optimize the storage position of a predicate field in a knowledge graph in a storage table.

[0048] The following describes an exemplary application of the electronic device provided by the embodiment of the present application. The electronic device provided by the embodiment of the present application can be implemented as various types of terminals such as a laptop computer, a tablet computer, a desktop computer, a set-top box, a smart phone, a smart speaker, a smart watch, a smart TV, and a vehicle-mounted terminal, and can also be implemented as a server. The following describes an exemplary application when the device is implemented as a server.

[0049] See also Figure 1 , Figure 1 This is a schematic diagram of an application mode of the data storage method provided in an embodiment of the present application, for example, Figure 1 The server 200, network 300, terminal 400 and database 500 are involved. The terminal 400 is connected to the server 200 via the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two. The database 500 stores query records of the knowledge graph.

[0050] During the data storage process, the terminal 400 responds to the user's data storage instruction and sends a data storage request to the server 200. The server 200 responds to the data storage request and obtains the query record of the first knowledge graph from the database 500, and divides the multiple query fields included in the query record of the first knowledge graph into multiple query field groups, each query field includes a subject field type and a predicate field, and a query field group includes multiple query fields with the same subject field type; for each query field group, multiple sub-query field groups are extracted from the query field group according to the query type of the predicate field, and each sub-query field group includes a query field with a query number greater than the query number threshold; for the query field in each sub-query field group, the first storage position of the predicate field of the query field in the preset table is determined according to the query number of the query field, and the predicate field is stored in the first storage position in the preset table; according to the preset table storing the predicate field, a second knowledge graph is generated, and the storage result is returned to the terminal 400. In this way, the technician can understand the storage result through the terminal 400, and the constructed second knowledge graph can meet the search requirements of the target scenario. For example: if the target scenario is an online interactive scenario such as social media, the constructed second knowledge graph can provide users with personalized search results and recommended content.

[0051] In some embodiments, the data storage method of the embodiments of the present application can also be applied in the following application scenarios: in the financial, medical and other field scenarios, using the data storage method of the present application, the knowledge graph generated based on the data storage results can analyze the relationships and attributes between entities and provide data-based decision support; in the Internet of Things scenario, using the data storage method of the present application, the knowledge graph generated based on the data storage results can achieve intelligent linkage and optimization of devices through relationship management between entities.

[0052] In some embodiments, a node may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, 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 (CDN), and big data and artificial intelligence platforms. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.

[0053] See also Figure 2 , Figure 2 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, the electronic device may be a server, Figure 2The electronic device 600 shown includes: at least one processor 410, a memory 450, and at least one network interface 420. The various components in the electronic device 600 are coupled together via a bus system 440. It is understood that the bus system 440 is used to achieve connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, the bus system 440 is not described in detail. Figure 2 Various buses are labeled as bus system 440 .

[0054] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0055] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices that are physically remote from the processor 410.

[0056] The memory 450 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.

[0057] In some embodiments, memory 450 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.

[0058] The operating system 451 includes system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., which are used to implement various basic businesses and process hardware-based tasks.

[0059] The network communication module 452 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420. Exemplary network interfaces 420 include: Bluetooth, Wireless Authentication (WiFi), and Universal Serial Bus (USB).

[0060] In some embodiments, the device provided in the embodiments of the present application can be implemented in software. Figure 2 A data storage device 455 stored in a memory 450 is shown, which may be software in the form of a program or plug-in, including the following software modules: a first determination module 4551, a second determination module 4552, a third determination module 4553, and a graph generation module 4554. These modules are logical, and therefore may be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.

[0061] In some embodiments, the terminal or server can implement the data storage method provided by the embodiment of the present application by running various computer executable instructions or computer programs. For example, computer executable instructions can be commands, machine instructions or software instructions at the microprogram level. The computer program can be a native program or software module in the operating system; it can be a local (Native) application (APPlication, APP), that is, a program that needs to be installed in the operating system to run, such as a cloud computing APP or an instant messaging APP; it can also be a small program that can be embedded in any APP, that is, a program that can be run only by downloading it to a browser environment. In short, the above-mentioned computer executable instructions can be instructions in any form, and the above-mentioned computer program can be an application, module or plug-in in any form.

[0062] The data storage method provided in the embodiment of the present application will be explained in combination with the exemplary application and implementation of the server device provided in the embodiment of the present application.

[0063] The data storage method provided by the embodiment of the present application is described below. As mentioned above, the electronic device implementing the data storage method of the embodiment of the present application can be a terminal, a server, or a combination of the two. Therefore, the execution subject of each step will not be repeatedly described below.

[0064] See also Figure 3A , Figure 3A This is a first flow chart of the data storage method provided in the embodiment of the present application, which will be combined with Figure 3A The steps shown are explained.

[0065] In step 301, multiple query fields included in the query record of the first knowledge graph are divided into multiple query field groups.

[0066] Here, each query field includes a subject field type and a predicate field, and a query field group includes multiple query fields with the same subject field type.

[0067] The first knowledge graph is the knowledge graph to be queried. The knowledge graph is a structured knowledge representation method that organizes and represents knowledge through a graphical model. Nodes in a knowledge graph usually represent entities (such as people, places, things, concepts, etc.), while edges represent the relationship between entities. The basic building block of the knowledge graph is fact data, and each fact data is represented as a triple of "subject-predicate-object" information. The subject field type indicates the category to which the subject field belongs. For example, the subject field type can be a person, a company, an operating system, etc. The predicate field indicates the predicate of the category to which the subject field belongs. The query field format is <subject field type: predicate field>. For example, taking the subject field type as an operating system, the predicate field is "version", and the query field can be expressed as <operating system: version>.

[0068] When the query records of the first knowledge graph accumulate to a certain amount of data, the query records of the first knowledge graph are cleaned and filtered to obtain multiple query fields of different subject field types, and multiple query fields of the same subject field type are divided into a query field group to obtain query field groups of different subject field types. For example, taking the subject field type of operating system as an example, a query field group can be expressed as:

[0069]

[0070] Continue to refer Figure 3A In step 302, for each query field group, multiple sub-query field groups are extracted from the query field group according to the query type of the predicate field.

[0071] Here, each sub-query field group includes query fields whose query times are greater than a query times threshold.

[0072] The query fields with query times greater than the query times threshold are used to characterize frequently queried query fields. Frequently queried query fields can be characterized as frequent item sets, which are sets of items (or items) that frequently appear in transactions. For example, in shopping basket analysis, milk and bread are often purchased together, so <"bread", "milk"> is a frequent item set. Frequent items are "bread", "milk".

[0073] In some embodiments, see Figure 3B , Figure 3B This is a second flow chart of the data storage method provided in an embodiment of the present application. Figure 3A Step 302 shown may be performed by Figure 3B Steps 3021 to 3024 are implemented as described in detail below.

[0074] In step 3021, a first preset number of sub-query field groups is determined, and a query type of a predicate field in the query field group is determined according to the first preset number.

[0075] Here, the query type includes the first query type to the Nth query type, N is a first preset number, the i-th query type represents a query in the form of a predicate field set including i predicate fields, N is equal to the first preset number, i is a positive integer less than or equal to N, and the predicate field set including i predicate fields is composed of i query fields.

[0076] For ease of understanding, the following example is provided. Assuming that the first preset number N is 3, the query types for determining the predicate field include the first query type to the third query type, and the first query type represents a query in the form of a predicate field set containing a predicate field, that is, a query in the form of a query field, which can be expressed as:

[0077] <Operating System: Kernel>

[0078] The second query type represents a query in the form of a predicate field set containing two predicate fields, that is, a query in the form of two query fields, which can be expressed as:

[0079] <Operating System: Open Source><Operating System: Developer>

[0080] The third query type represents a query in the form of a predicate field set containing three predicate fields, that is, a query in the form of three query fields, which can be expressed as:

[0081]

[0082] In some embodiments, step 3021 may be implemented in the following manner: determining a preset maximum number of columns of a preset table, where the preset maximum number of columns is the maximum value of a column storing predicate fields; determining the total number of predicate fields of different predicate types in the query field group; and calculating a first preset number of sub-query field groups based on the total number and the preset maximum number of columns.

[0083] The preset table is a storage table for storing subject field types, subject fields, predicate fields, and object fields. The preset maximum number of columns is the maximum value of the column used to store the predicate field. For example, the preset maximum number of columns is 3, and the maximum value of the column storing the predicate field is 3.

[0084] According to the predicate types to which different predicate fields belong, the total number of predicate fields in the query field group is determined, and the total number is the sum of the numbers of predicate fields in all predicate types. The total number is divided by the preset maximum number of columns, and the obtained ratio result is rounded up to obtain the first preset number of sub-query field groups.

[0085] For example, the preset maximum number of columns of the preset table is k columns, the first total number of predicate fields in the query field group is n, and the ceiling function ceil is used. Through the calculation formula N=ceil(n / k), the first preset number of subquery field groups is N.

[0086] Assume that the preset maximum number of columns of the preset table is 3 columns, the query field group includes predicate fields of two predicate types, the number of predicate fields in each predicate type is 10, and the total number of predicate fields in the query field group is 20. Using the ceiling function ceil, through the calculation formula N=ceil(20 / 3), the first preset number of sub-query field groups is 7. The first preset number 7 is used as the total number of query types of predicate fields, and the query types include the first query type to the seventh query type.

[0087] In the embodiment of the present application, the first preset number of sub-query field groups is calculated based on the first total number of predicate fields and the preset maximum number of columns, and the first preset number is used as the second total number of query types of the predicate fields. This can reasonably plan the types and quantities of predicate fields, optimize the structure of the storage table, avoid unnecessary waste of columns, and improve the storage efficiency of the predicate fields.

[0088] Continue to refer Figure 3B In step 3022, for each query type and the query times of each predicate field, the combined query times of each predicate field set of the query type are determined.

[0089] The number of combined queries refers to the number of queries in which multiple predicate fields in each predicate field set in a query type appear at the same time, and each predicate field set includes one or more query fields. For each query type, the number of queries for each predicate field in each predicate field set of the query type is determined, and the number of queries for each predicate field is the number of queries in which the predicate field appears alone. A frequent item set growth algorithm (FP-Grouth) can be used to construct a frequent pattern tree based on the number of queries for each predicate field in each predicate field set, and a frequent item set list including the number of combined queries of the predicate field set is generated based on the structure of the frequent pattern tree, and the number of combined queries for each predicate field set of each query type is determined through the frequent item set list.

[0090] For example, taking the second query type as an example, each predicate field set of the second query type may include two query fields: "<operating system: is open source><operating system: developer>", <operating system: kernel><operating system: version>". Among them, the query number of the predicate field "is open source" is 100, that is, the query number of the predicate field "is open source" appearing alone is 100. The query number of the predicate field "developer" is 46, that is, the query number of the predicate field "developer" appearing alone is 46. In addition to appearing alone, predicate fields also appear in combination, for example: the predicate field set "<operating system: is open source><operating system: developer>", the number of combined appearances is independent of the number of individual appearances, and the frequent item set growth algorithm is used to count the number of occurrences of each predicate field in different situations, and construct a frequent pattern tree (Frequent Pattern Tree) according to the number of occurrences. The FP-tree is a frequent pattern tree. According to the structure of the frequent pattern tree, the number of combined queries of the predicate field set is obtained by excluding the predicate fields that appear alone and outside the combination. The frequent item set growth algorithm determines that the number of queries for the predicate field "is open source" and the predicate field "developer" to appear at the same time is 74, that is, the number of combined queries for the predicate field set "<operating system: is open source><operating system: developer>" is 74; the number of queries for the predicate field "kernel" is 98, that is, the number of queries for the predicate field "kernel" to appear alone is 98. The number of queries for the predicate field "version" is 80, that is, the number of queries for the predicate field "version" to appear alone is 80. In addition to appearing alone, the predicate field also appears in combination, and the number of combined appearances is independent of the number of queries for appearing alone. The frequent item set growth algorithm determines that the number of queries for the predicate field "kernel" and the predicate field "version" to appear at the same time is 68, that is, the number of combined queries for the predicate field set "<operating system: kernel><operating system: version>" is 68.

[0091] In step 3023, a target predicate field included in a predicate field set whose combined query times are greater than a query times threshold is extracted from the multiple predicate field sets of the query type.

[0092] The combined query times are compared with a preset query times threshold, a target predicate field set whose combined query times are greater than the query times threshold is determined, and a target predicate field is extracted from the target predicate field set.

[0093] For example, taking the second query type as an example, the preset query count threshold is 20, the combined query count of the predicate field set "<operating system: is open source><operating system: developer>" is 35, the combined query count of the predicate field set "<operating system: kernel><operating system: version>" is 15, the combined query count of the predicate field set "<operating system: is open source><operating system: developer>" is greater than 20, the target predicate field set is "<operating system: is open source><operating system: developer>", and the target predicate fields are "is open source" and "developer".

[0094] In step 3024, based on the query field corresponding to each target predicate field, a sub-query field group corresponding to the query type is determined.

[0095] For each target predicate field, the query field corresponding to the target predicate field is determined, and the query field groups corresponding to the target predicate field are grouped into a predicate field set, and a sub-query field group corresponding to the query type is determined based on each predicate field set. For the first query type to the Nth query type, the sub-query field group corresponding to each query type is determined respectively, and the sub-query field groups corresponding to the N query types are obtained.

[0096] For example, taking the second query type as an example, the target predicate fields are "is open source", "developer", "kernel", and "version". The query field corresponding to the target predicate field "is open source" is "<operating system: is open source>", and the query field corresponding to the target predicate field "developer" is "<operating system: developer>". The query field group is formed into a predicate field set "<operating system: is open source><operating system: developer>"; the query field corresponding to the target predicate field "kernel" is "<operating system: kernel>", and the query field corresponding to the target predicate field "version" is "<operating system: version>". The query field group is formed into a predicate field set "<operating system: kernel><operating system: version>", and the sub-query field group corresponding to the second query type is determined based on each predicate field set. A sub-query field group can be expressed as:

[0097] <Operating System: Open Source><Operating System: Developer> <Operating System: Kernel><Operating System: Version>

[0098] In an embodiment of the present application, for each query type, when the first query count of the predicate field set of the query type is greater than the query count threshold, the target predicate field included in the predicate field set is extracted, and based on the query field corresponding to each target predicate field, the sub-query field group corresponding to the query type is determined, so that the predicate fields with higher query counts are combined into sub-query field groups, and the combined query counts between different predicate fields are fully considered. When the storage location of the predicate field is subsequently determined based on multiple sub-query field groups, the predicate fields with higher combined query counts are avoided from being stored in the same column, thereby reducing the query self-join situation of the knowledge graph.

[0099] Continue to refer Figure 3A In step 303, for the query field in each sub-query field group, according to the query times of the query field, the first storage position of the predicate field of the query field in the preset table is determined, and the predicate field is stored in the first storage position in the preset table.

[0100] Here, the first storage location is a location in the preset table for storing the predicate field.

[0101] In some embodiments, the sub-query field groups include a first sub-query field group to an N-th sub-query field group, N is a first preset number, the i-th query type corresponding to the i-th sub-query field group represents a query in the form of a predicate field set including i predicate fields, and i is a positive integer less than or equal to N; see Figure 3C , Figure 3C This is a third flow chart of the data storage method provided in an embodiment of the present application. Figure 3A Step 303 shown may be performed by Figure 3C Steps 3031 to 3034 are implemented as described in detail below.

[0102] In step 3031, K first predicate fields of the first query type are extracted from the first sub-query field group.

[0103] Here, the first sub-query field group includes the first predicate field of the first query type, and K is the number of columns in the preset table for storing predicate fields, that is, the preset maximum number of columns is K. The first sub-query field group represents a query in the form of a predicate field set including 1 predicate field, and K first predicate fields are extracted from the first sub-query field group according to the query times of the query fields from high to low.

[0104] For example, the preset maximum number of columns K is 3, the number of columns used to store predicate fields is 3, and the first subquery field group can be expressed as:

[0105] <Operating system: open source> 100 <Operating System: Kernel> 98 <Operating System: Version> 80 <Operating System: Supporting Central Processing Unit> 76

[0106] Extract 3 first predicate fields: "is open source", "kernel", and "version" from the first sub-query field group according to the query times of the query fields from high to low.

[0107] In step 3032, sort the K first predicate fields in descending order according to the query times to obtain the first sorting result.

[0108] Sort the K first predicate fields in descending order according to the query times of the query fields corresponding to the K first predicate fields to obtain the first sorting result.

[0109] For example, K is 3, and the 3 first predicate fields are "is open source", "kernel", and "version". The query times of the query fields corresponding to the first predicate field "is open source" is 100, the query times of the query fields corresponding to the first predicate field "kernel" is 98, and the query times of the query fields corresponding to the first predicate field "version" is 80. Sort the 3 first predicate fields in descending order according to the query times to obtain the first sorting result, and the first sorting result can be expressed as:

[0110] 1 <Operating System: Kernel> 2 <Operating System: Version> 3 <Operating System: Supports Central Processing Unit>

[0111] In step 3033, take the m-th column of the first row of the preset table as the first storage location of the m-th first predicate field in the first sorting result.

[0112] Here, 0 < m ≤ K. For the first row of the preset table, take the m-th column in the first row used to store the predicate field as the first storage location of the m-th first predicate field in the first sorting result.

[0113] For example, the preset maximum number of columns K is 3. The first first predicate field in the first sorting result is "is open source", the second first predicate field is "kernel", and the third first predicate field is "version". Take the first column in the first row of the preset table used to store the predicate field as the first storage location of the first predicate field "is open source". Take the second column in the first row of the preset table used to store the predicate field as the first storage location of the first predicate field "kernel". Take the third column in the first row of the preset table used to store the predicate field as the first storage location of the first predicate field "version". The first row of the preset table can be expressed as:

[0114]

[0115] Among them, the first column used to store the predicate field in the first row of the preset table is the predicate 1 column, and the predicate 1 column is used as the storage location of the predicate field "is open source". The second column used to store the predicate field in the first row of the preset table is the predicate 2 column, and the predicate 2 column is used as the storage location of the predicate field "kernel". The third column used to store the predicate field in the first row of the preset table is the predicate 3 column, and the predicate 3 column is used as the storage location of the predicate field "version".

[0116] In step 3034, the first predicate field is used as the predicate field with a determined storage position, and based on the predicate field with a determined storage position and the query count of the predicate field set in the i-th sub-query field group, the first storage position of the unstored predicate field in the i-th sub-query field group in the i-th row of the preset table is determined.

[0117] After determining the first storage position of the predicate field in the first sub-query field group in the first row of the preset table, the first storage position of the predicate field not stored in the i-th sub-query field group is determined in the i-th row of the preset table by using the first predicate field with the determined storage position and the number of queries of the predicate field set in the i-th sub-query field group.

[0118] In some embodiments, see Figure 3D , Figure 3D This is a fourth flow chart of the data storage method provided in an embodiment of the present application. Figure 3C Step 3034 shown may be performed by Figure 3D Steps 30341 to 30343 are implemented as described in detail below.

[0119] In step 30341, for the mth column of the ith row, determine the second predicate field in the ith sub-query field group that satisfies the first condition.

[0120] Here, the first condition includes that the i-th subquery field group is different from the subquery field group of the predicate field whose storage position has been determined in the m-th column, and the second predicate field in the i-th subquery field group and the predicate field whose storage position has been determined in the m-th column do not belong to the same predicate field set. In addition, the second predicate field is not a predicate field whose storage position has been determined. For the m-th column in the second row of the preset table for storing the predicate field, the second predicate field that meets the first condition is determined from the second subquery field group. For the m-th column in the third row of the preset table for storing the predicate field, the second predicate field that meets the first condition is determined from the third subquery field group, and so on.

[0121] For example, the first row of the preset table can be expressed as:

[0122]

[0123] For the mth column for storing the predicate field in the second row of the preset table, a second predicate field satisfying the first condition is determined from the second sub-query field group. The second sub-query field group can be expressed as:

[0124]

[0125] Taking the first column for storing predicate fields in the second row of the preset table as an example, since the first column for storing predicate fields in the first row of the preset table is "is open source", the predicate field "is open source" is a predicate field with a determined storage location. The second predicate field that meets the first condition is determined from the second sub-query field group, that is, the second sub-query field group is different from the sub-query field group of the predicate field "is open source" with a determined storage location in the first column, and the second predicate field in the second sub-query field group does not belong to the same predicate field set as the predicate field "is open source" with a determined storage location in the first column. Since the predicate fields "kernel" and "version" are both predicate fields with determined storage locations, they are not second predicate fields that meet the first condition. The predicate field set "<operating system: kernel><operating system: support central processing unit>" is found from the second sub-query field group, that is, the second sub-query field group is different from the sub-query field group of the predicate field "is open source" whose storage location has been determined in the first column, and the predicate field "support central processing unit" in the second sub-query field group does not belong to the same predicate field set as the predicate field "is open source" whose storage location has been determined in the first column, so the predicate field "support central processing unit" is the second predicate field that meets the first condition. By analogy, the second predicate fields that meet the first condition also include: "file system", "release", "mapping", and "old version".

[0126] In step 30342, when there is only one second predicate field in the i-th subquery field group, the m-th column of the i-th row is used as the first storage position of the second predicate field.

[0127] If there is only one second predicate field that meets the first condition in the i-th subquery field group, the m-th column for storing predicate fields in the i-th row of the preset table is used as the first storage position of the second predicate field.

[0128] In step 30343, when there are multiple second predicate fields in the i-th sub-query field group, a target second predicate field with the largest number of queries is selected from the multiple second predicate fields, and the m-th column of the i-th row is used as the first storage position of the target second predicate field, and the m+1-th column of the i-th row is used as the first storage position of the second predicate field with the largest number of queries among the remaining second predicate fields, until the first storage position of each second predicate field is determined.

[0129] If there are multiple second predicate fields that meet the first condition in the i-th sub-query field group, the query times of the predicate field set where each second predicate field is located are determined, and the second predicate field with the largest query times in the predicate field set is used as the target second predicate field, and the m-th column for storing predicate fields in the i-th row of the preset table is used as the first storage position of the target second predicate field. The remaining second predicate fields are used as unstored predicate fields, and the process of determining the second predicate field with the largest query times that meets the first condition in the i-th sub-query field group is performed for the m+1-th column of the i-th row, and the remaining second predicate fields are unstored second predicate fields other than the target second predicate field.

[0130] For example, the first row of the preset table can be expressed as:

[0131]

[0132] Taking the first column for storing the predicate field in the second row of the preset table as an example, it is determined from the second sub-query field group that there are two second predicate fields that meet the first condition: "support central processing unit" and "file system". The second sub-query field group can be expressed as:

[0133]

[0134] The query times of the predicate field set "<operating system: kernel><operating system: supporting central processor>" where the second predicate field "supporting central processor" is located is 54, and the query times of the predicate field set "<operating system: kernel><operating system: file system>" where the second predicate field "file system" is located is 32. The query times of the predicate field set where the second predicate field "supporting central processor" is located is the largest. The second predicate field "supporting central processor" is used as the target second predicate field, and the first column for storing predicate fields in the second row of the preset table is used as the first storage location of the target second predicate field "supporting central processor". The second predicate field "file system" is used as an unstored predicate field. For the second column of the second row, the process of determining the second predicate field with the largest query times that meets the first condition in the second sub-query field group is performed. The second predicate field "file system" is an unstored second predicate field other than the target second predicate field.

[0135] In an embodiment of the present application, when determining the first storage position of the predicate field in the i-th sub-query field group in the i-th row in the preset table, for the m-th column of the i-th row, the second predicate field that meets the first condition is preferentially stored in the m-th column of the i-th row in the preset table, thereby reducing the storage of predicate fields with a high number of combined query uses in the same column, thereby reducing the self-join of queries in the knowledge graph, and also avoiding storing the same predicate field in the same column, thereby reducing data overflow and optimizing the storage method of the knowledge graph.

[0136] In some embodiments, when there is no second predicate field satisfying the first condition in the i-th sub-query field group, the following steps may be further performed: when i+1≤N, extract the target second predicate field from the i+1-th sub-query field group, and use the m-th column of the i-th row as the first storage position of the target second predicate field; when there is no second predicate field satisfying the first condition in each sub-query field group, use the m-th column of the i-th row as the first storage position of the predicate field with the least number of queries in the i-th sub-query field group.

[0137] For the mth column for storing the predicate field in the i-th row of the preset table, if there is no second predicate field satisfying the first condition in the i-th sub-query field group, first determine the size relationship between the number of rows i and the first preset number N, and if i+1≤N, determine the target second predicate field from the i+1th sub-query field group, and use the mth column of the i-th row as the first storage position of the target second predicate field. If there is no second predicate field satisfying the first condition in each sub-query field group, determine the predicate field with the least query times in the predicate field set from the i-th sub-query field group, and use the mth column of the i-th row as the first storage position of the predicate field.

[0138] In an embodiment of the present application, when there is no second predicate field satisfying the first condition in the i-th sub-query field group, if i+1≤N, the target second predicate field is extracted from the i+1-th sub-query field group, which can ensure that the predicate field satisfying the first condition is stored in the m-th column of the i-th row in the preset table, thereby reducing the storage of predicate fields with a high number of combined query uses in the same column, thereby reducing the query self-join of the knowledge graph, and avoiding storing the same predicate field in the same column, thereby reducing data overflow and optimizing the storage method of the knowledge graph.

[0139] In some embodiments, after the predicate field is stored in the first storage position in the preset table, the following steps may also be performed: based on the first storage position, determine the second storage position of the object field associated with each predicate field in the preset table, and store the object field to the second storage position; based on the first storage position, determine the third storage position of the subject field type corresponding to each predicate field in the preset table, and store the subject field type to the third storage position; based on the first storage position, determine the fourth storage position of the subject field of the subject field type corresponding to each predicate field in the preset table, and store the subject field to the fourth storage position.

[0140] After determining the first storage position of the predicate field, the row storage position and column storage position corresponding to the first storage position of the predicate field can be determined. For the object field associated with the predicate field, the column after the column storage position of the predicate field is used as the column storage position of the object field, and then the row storage position of the object field is determined according to the row storage position of the predicate field, thereby determining the second storage position of the object field in the preset table. For the subject field type corresponding to the predicate field, a column position (such as the second column) can be specified in the preset table as the column storage position of the subject field type, and then the row storage position of the subject field type is determined according to the row storage position of the predicate field, thereby determining the third storage position of the subject field type in the preset table. For the subject field of the subject field type corresponding to the predicate field, a column position (such as the first column) can be specified in the preset table as the column storage position of the subject field, and then the row storage position of the subject field is determined according to the row storage position of the predicate field, thereby determining the fourth storage position of the subject field in the preset table.

[0141] For example, the preset table can be expressed as:

[0142]

[0143] Predicate 1 column, Predicate 2 column, and Predicate 3 column are used to store predicate fields, and Object 1 column, Object 2 column, and Object 3 column are used to store object fields. The predicate field "is open source" is stored in Predicate 1 column. The object field associated with the predicate field "is open source" is "1934". The column after the column storage position of the predicate field "is open source" is used as the column storage position of the object field, that is, Object 1 column. Then, according to the row storage position of the predicate field "is open source", the row storage position of the object field "1934" is determined, and the object field "1934" is stored in the first row of Object 1 column. The subject field type associated with the predicate field "is open source" is "operating system". In the preset table, the second column is specified as the column storage position of the subject field type. Then, according to the row storage position of the predicate field "is open source", the row storage position of the subject field type "operating system" is determined, and the subject field type "operating system" is stored in the first row of the subject field type column. The subject field of the subject field type corresponding to the predicate field "is open source" is "Ubuntu". The first column is designated as the column storage position of the subject field in the preset table, and then the row storage position of the subject field "Ubuntu" is determined according to the row storage position of the predicate field "is open source", and the subject field "Ubuntu" is stored in the first row of the subject field column.

[0144] Continue to refer Figure 3A In step 304, a second knowledge graph is generated according to a preset table storing predicate fields.

[0145] In some embodiments, step 304 can be implemented in the following manner: use the preset table as the first preset table, and determine the subject field and the object field based on the first preset table; obtain the object field identifier of the object field, and store the object field identifier and the object field in association with each other to obtain a second preset table; perform column conversion on the first preset table to obtain a third preset table; obtain the subject field identifier of the subject field, and store the subject field identifier and the subject field in association with each other to obtain a fourth preset table; generate a second knowledge graph based on the mapping relationships corresponding to the first preset table, the second preset table, the third preset table, and the fourth preset table, respectively.

[0146] The second knowledge graph is a knowledge graph to be constructed, and the second knowledge graph is constructed according to the resource description framework (Database to RDF, DB2RDF). The DB2RDF storage mode consists of 4 storage tables, namely the main hash table (dph table), the secondary hash table (ds table), the reverse main hash table (rph table) and the reverse secondary hash table (rs table). The first preset table is the main hash table (dph table), and the multiple predicate fields, subject fields and object fields stored can be determined according to the first preset table. A corresponding object field identifier is assigned to each object field, and a corresponding subject field identifier is assigned to each subject field. The second preset table is a secondary hash table (ds table), which is used to associate and store object field identifiers with object fields.

[0147] The third preset table is a reverse primary hash table (rph table), which is used to store the input edge information from the object field via the predicate field to the subject field. According to the actual scenario requirements, the subject field column and the object field column in the first preset table can be converted to each other to obtain the third preset table. The fourth preset table is a reverse secondary hash table (rs table), which is used to associate and store the subject field identifier with the subject field. The first preset table, the second preset table, the third preset table, and the fourth preset table are stored in the graph database, and the second knowledge graph is constructed in the graph database using the data stored in the four preset tables.

[0148] In an embodiment of the present application, multiple query fields included in the query record of the first knowledge graph are divided into multiple query field groups, each query field includes a subject field type and a predicate field, and a query field group includes multiple query fields of the same subject field type, thereby implementing the division of multiple query fields into query field groups of different subject field types, and then for each query field group, multiple sub-query field groups are extracted from the query field group according to the query type of the predicate field, each sub-query field group includes a query field whose query times are greater than a query times threshold, and multiple sub-query field groups can be mined based on the query type of the predicate field, and then for the query field in each sub-query field group, the first storage position of the predicate field of the query field in the preset table is determined according to the query times of the query field, and the predicate field is stored in the first storage position in the preset table. , it can determine the storage position of the predicate field in the storage table based on the query times of the query field in each sub-query field group, realize the determination of the storage position of different predicate fields of the same subject category, and try to store different predicate fields of the same subject category in different columns to reduce data overflow. Then, according to the preset table storing the predicate field, a second knowledge graph is generated. In the process of querying using the second knowledge graph, it can reduce the situation that a node in the knowledge graph is connected to itself or other nodes through several edges, that is, reduce the query self-connection situation, and find accurate results. In this way, the query times of the combination of different predicate fields of the same subject category are taken into account, and different predicate fields of the same subject category are stored in different columns based on the query times, which reduces data overflow and optimizes the storage position of the predicate field in the storage table in the knowledge graph.

[0149] Below, the data storage method provided in an embodiment of the present application will be described in an exemplary application in a knowledge graph storage scenario based on a relational database.

[0150] Relational databases have become the mainstream database products for data management today. They have replaced hierarchical databases and network databases, and absorbed object-oriented databases and eXtensible Markup Language (XML) databases. Commercial relational databases include Oracle databases, Microsoft databases (SQL Server), etc., and open source relational databases include PostgreSQL databases and MySQL databases. In related technologies, knowledge graphs mainly use storage solutions based on relational databases, such as: Database to RDF (DB2RDF) is an RDF knowledge graph storage solution based on relational databases. This solution is flexible in the "row dimension", that is, the storage mode will not change as the number of rows in the relational table increases. The DB2RDF solution can also extend this flexibility to the "column dimension", that is, the columns of the relational table are used as storage locations for predicates and objects without binding the columns to the predicates. When inserting new data, the predicate can be dynamically mapped and stored in a column, and it can ensure that the same predicate is mapped to the same column.

[0151] Example, reference Figure 4 , Figure 4 It is a schematic diagram of the knowledge graph provided in the related art. The knowledge graph includes a subject node, a predicate on a one-way edge emitted by the subject node, and an object node.

[0152] Among them, a unidirectional edge refers to a directional relationship, indicating an association in one direction from one entity to another entity. The unidirectional edge emitted by the subject node "Name 1" contains the predicates "born", "died", and "founder". The predicate "born" corresponds to the object "1850", the predicate "died" corresponds to the object "1934", and the predicate "founder" points to the subject node "Enterprise 2".

[0153] The one-way edge emitted by the subject node "Name 2" contains the predicates "birth", "address", "founder", and "position". The predicate "birth" corresponds to the object "1973", the predicate "address" corresponds to the object "place name 3", the predicate "founder" points to the subject node "Company 1", and the predicate "position" points to the subject node "Company 1".

[0154] The one-way edge emitted by the subject node "Enterprise 1" contains predicates "industry", "employees", and "headquarters". The predicate "industry" corresponds to multiple objects "software" and "Internet", the predicate "employees" corresponds to the object "57100", and the predicate "headquarters" corresponds to the object "place name 1".

[0155] The one-way edge emitted by the subject node "Enterprise 2" contains predicates "industry", "employees", and "headquarters". The predicate "industry" corresponds to multiple objects "software", "organization", and "hardware". The predicate "employees" corresponds to the object "377757", and the predicate "headquarters" corresponds to the object "place name 2".

[0156] On the one-way edge emitted by the subject node "operating system", there are predicates "developer", "cartography", "kernel", "old version", and "new version". The predicate "developer" points to the subject node "Enterprise 1", the predicate "cartography" corresponds to the object "Open Graphics Library", the predicate "kernel" corresponds to the object "Linux", the predicate "old version" corresponds to the object "8.0", and the predicate "new version" corresponds to the object "8.1".

[0157] Example, reference Figure 5 , Figure 5 It is a schematic diagram of the DB2RDF knowledge graph storage mode provided in the related art. The DB2RDF knowledge graph storage mode consists of a primary hash table 501 (direct primary hash, dph table), a secondary hash table 502 (direct secondary hash, ds table), a reverse primary hash table 503 (reverse primary hash, rph table) and a reverse secondary hash table 504 (reverse secondary hash, rs table). The primary hash table 501 is the main storage table, in which a row stores a subject (subject column) and all its predicates (predicate column) and objects (object column). The number of columns i satisfies the condition 0≤i≤k, and k is the graph coloring result value or a given value. If the number of predicates of a subject is greater than k, then a row is not enough to accommodate the next subject entity, and the k+1 to 2k predicates and objects will be stored in the next row, and so on. This situation is called data overflow. For a row that can store the next subject entity, the overflow flag spill of the row is 0. For the overflowed subject entity, the overflow flag spill of all rows of the subject entity is 1. For example, in Figure 5 In the main hash table 501, except for the subject entity "operating system" which overflows, the remaining subject entities are stored in one row.

[0158] For multi-valued predicates in the primary hash table 501, that is, the same predicate has multiple objects, a unique identification id value is generated at the corresponding object, and the id value and each corresponding object are stored in a row of the secondary hash table 502. For example, in the primary hash table 501, the predicate "industry" (predicate 1 column) corresponding to the subject "enterprise 1" is a multi-valued predicate, and the id value is stored in its object column (object 1 column) as lid:1, and the two objects "software" and "Internet" associated with lid:1 are stored in the secondary hash table 502.

[0159] The main hash table 501 implements column sharing of the relational table: on the one hand, the same predicates of different subject entities are always assigned to the same column; on the other hand, multiple different predicates can be stored in the same column. For example, the predicate "founder" corresponding to the subject "name 1" and "name 2" are both assigned to the predicate 3 column, which also stores the predicates "kernel" and "cartography" of the subject "operating system". Since the DB2RDF storage solution has a "column sharing" mechanism, when the number of columns in the relational table reaches the upper limit, it can store a number of predicates far exceeding the upper limit, and can also effectively solve the problem of predicate sparsity null values ​​in the horizontal table solution. In actual knowledge graphs, different subjects often have different predicate sets, for example: the predicate "birth" is associated with the subject "person", and the predicate "employee" is associated with the subject "enterprise".

[0160] From the perspective of the graph data model, the primary hash table 501 and the secondary hash table 502 actually store the outbound edge information of the subject entity node (from the subject via the predicate to the object). In order to improve the query processing efficiency, the inbound edge information of the subject entity node (from the object via the predicate to the subject) also needs to be stored. Therefore, the DB2RDF storage solution also provides a reverse primary hash table 503 and a reverse secondary hash table 504.

[0161] The resource description framework query language SPARQL in the DB2RDF solution is converted into the equivalent structured query SQL as follows:

[0162] SELECT t. Subject

[0163] FROM dph AS t

[0164] WHERE t.predl='died'AND t.val1='1934'

[0165] AND t.pred2='born'AND t.val2='1850'

[0166] AND t.pred3='founder'

[0167] For star queries of the knowledge graph, the DB2RDF storage solution only needs to query the main hash table (dph table) without performing a join operation.

[0168] The above article explains the use of the DB2RDF storage solution to store knowledge graphs. The following article will explain the predicate storage process of the knowledge graph. In the DB2RDF storage solution, the mapping of predicates to relational table columns is an issue that needs to be considered. Because the maximum number of columns in a relational table is fixed, the optimization goal of column mapping is: the number of columns used should not exceed a certain predetermined value, and the situation where two different predicates of the same subject are assigned to the same column is minimized, thereby reducing overflow, because overflow will cause self-joins during queries. Query self-join is when executing a knowledge graph query, the graph algorithm will generate a self-looping path in the knowledge graph. This path is called a self-join in graph theory. The self-join path means that a node in the graph is connected to itself or other nodes through several edges, making the query result non-unique and difficult to find accurate results.

[0169] One method of mapping predicates to columns of a relational table is to use a set of hash functions to map predicates to a set of column numbers, and store the predicate and its object in the first empty column in this set of columns. In a row corresponding to a subject, if the hash function calculates that all columns in this set of columns are occupied by the predicate that previously stored the subject when storing a predicate (and its object), an overflow occurs and the predicate is stored in the next row. For an example, refer to Figure 6 , Figure 6 is a hash function table provided in the related art. The hash function table includes a predicate column 601, a hash function h1 column 602, and a hash function h2 column 603, and maps the five predicates "developer", "new version", "kernel", "old version", and "cartography" to the column number group. Figure 5 As shown in the main hash table 501 in, the triples of the subject "operating system" are stored. When storing ("operating system", "developer", "enterprise 1"), a new row is inserted into the main hash table for the subject "operating system", and the predicate "developer" is stored in the predicate 1 column according to the value of the hash function h1. When storing ("operating system", "new version", "8.1"), the predicate "new version" is stored in the predicate 2 column according to the value of the hash function h1; when storing ("operating system", "kernel", "Linux"), the predicate "kernel" is mapped by the hash function h1. To the Predicate 1 column, but this column is occupied by the Predicate "Developer", so the Predicate "Kernel" is stored in the Predicate 3 column according to the value of the hash function h2; when storing (operating system", "old version", "8.0"), the Predicate "old version" is mapped to the Predicate k column by the hash function h1; when storing (operating system", "cartography", "Open Graphics Library"), the Predicate "cartography" is mapped to the Predicate 3 column by the hash function h1, and is mapped to the Predicate 2 column by the hash function h2, but these two columns are already occupied, and an overflow occurs at this time, and the Predicate "cartography" is stored in the Predicate 3 column of the next row.

[0170] In the related art, in the process of storing knowledge graphs based on relational databases, the following problems exist: (1) The different usage frequencies of predicates in different subject categories are not considered, and the same predicates in different subject categories are mapped to the same column. (2) The combined usage frequencies of different predicates in the same subject category are not considered, and the same predicates in the same subject category are assigned to the same column, resulting in data overflow and self-join when querying the knowledge graph.

[0171] In view of the problems existing in the related art, the embodiment of the present application proposes a data storage method, which includes the following improvements compared with the related art:

[0172] Through the frequent item sets (the subquery field group) of the usage frequency of different predicates (the predicate field) of different subject categories (the subject field type above), the predicates are assigned to the row and column indexes (the first storage position above) of the relationship table (the preset table above) according to the frequent item sets, avoiding mapping the same predicates of different subject categories to the same column, or assigning the same predicates of the same subject category to the same column. Based on the generated predicate row and column index tables of each subject category, the storage of the knowledge graph is constructed to reduce overflow and minimize the self-join of knowledge graph queries.

[0173] The embodiment of the present application constructs a predicate row and column index table (including subject category, predicate, column index, and row index) to store row and column index values ​​of different predicates of different subject categories. The predicate row and column index table is shown in Table 1:

[0174] Table 1

[0175] Subject Category predicate Column Index Row Index operating system Developers 1 1 database Developers 3 1 enterprise industry 4 1 people born 1 1

[0176] Before building the knowledge graph storage, it is necessary to collect the usage query record data of different subject categories and different predicates in the existing business system (the query records of the first knowledge graph mentioned above). After accumulating data for a period of time, use the frequent pattern mining algorithm to mine the frequent item sets of predicates for each subject category (the sub-query field group mentioned above), and then generate the predicate row and column index table of each subject category based on the combination of frequent item sets. Finally, complete the storage of the knowledge graph based on the index table.

[0177] refer to Figure 7 , Figure 7 The electronic device implementing the data storage method of the embodiment of the present application may be a server, combined with Figure 7 The steps of the present invention are used to explain the knowledge graph storage process provided in the embodiment of the present application.

[0178] In step 701, historical predicate query data of different subject categories is collected.

[0179] For example, query records of predicate usage of different subject categories of an existing business system are collected (the query records of the first knowledge graph above), and the business system is a relational database. When the query records accumulate to a certain amount of data, the collected query records are cleaned. Cleaning query records means deleting abnormal records that do not meet the specifications, such as: records of query errors (SQL syntax errors, abnormal errors in the business system, etc.), records of queries that do not return data, etc. The cleaning process is to filter out records where the query is normal and returns valid data, obtain real and valid query records, and generate a table containing the query id and predicate query fields. The format of the predicate query (the query field above) is <Subject field type: predicate>, and the predicate query record table is shown in Table 2:

[0180] Table 2

[0181]

[0182] Continue to refer Figure 7 , in step 702, the predicate frequent itemsets of each subject category are mined.

[0183] For example, each query record in the predicate query record table contains multiple subject categories. For each subject category, first filter out the predicate query records of each subject category (the query field group above). For example, filter out the data whose subject category is "operating system" as shown in Table 3:

[0184] Table 3

[0185] 6 <Operating System: Kernel>, <Operating System: Version> 7 <Operating System: Kernel>, <Operating System: Version>, <Operating System: Graphics> 8 <Operating System: Version>, <Operating System: Drawing> 10 <Operating System: Kernel>, <Operating System: Version> ...... ......

[0186] For example, since a frequent itemset mining algorithm can only process one subject field type, before the mining algorithm is executed, the predicate query records of each subject category must be filtered out. The specific process of filtering the predicate query records of each subject category is as follows:

[0187] Assuming that the subject category to be mined is "operating system", the original predicate query record table is shown in Table 4:

[0188] Table 4

[0189]

[0190]

[0191] Exclude the query records whose subject category is not "operating system" row by row, that is, exclude the query records whose subject category is "enterprise" and "database", and filter out the data whose subject category is "operating system" as shown in Table 5:

[0192] Table 5

[0193] 1 <Operating System: Version>, <Operating System: Drawing> 3 <Operating System: Kernel>, <Operating System: Version>

[0194] For example, the FP-Growth algorithm is used to mine frequent item sets for all predicates belonging to the same subject category. It is set that the number of columns for storing predicates in the storage table (the preset table mentioned above) is k, and there are n predicates in this subject category. The ceil function is used, and through the calculation formula s=ceil(n / k), it is determined that there are s rows (the first preset number mentioned above) in the storage table for storing predicates in this subject category, that is, s frequent item sets are mined in this subject category (the subquery field groups mentioned above include the first subquery field group to the Nth subquery field group).

[0195] For example, the predicates of the subject category "operating system" are stored as 3 rows, and the FP-Growth algorithm is used to mine the predicate frequent itemsets of the subject category "operating system" (the subquery field group above). The predicate frequent itemsets are sorted in descending order according to the number of queries. The sample data is shown in Table 6:

[0196] Table 6

[0197] Frequent 1-item set (first subquery field group):

[0198] <Operating system: open source> 100 <Operating System: Kernel> 98 <Operating System: Version> 80 <Operating System: Supports Central Processing Unit> 76 <Operating System: File System> 65 <Operating System: Developer> 46 <Operating System: Release> 22 <Operating System: Older Version> 12

[0199] Frequent 2-item sets (second subquery field group):

[0200]

[0201] Frequent 3-item sets (third subquery field group):

[0202]

[0203]

[0204] Continue to refer Figure 7 , in step 703, an index table is generated according to the predicate frequent itemsets.

[0205] For example, in the first row of the storage table (the preset table mentioned above), the predicates are assigned to the column index of the storage table from high to low according to the number of frequent 1-item set queries. When assigning the i-th row index of the storage table, the predicate combination of the frequent i-item set (the i-th subquery field group mentioned above) is considered. If the predicates that are frequently used in combination (the number of queries of the predicate field set mentioned above is high) are assigned to the same column of the storage table, the query of the knowledge graph will produce a self-join phenomenon. Try to avoid assigning predicates belonging to the same frequent i-item set to the same column of the storage table.

[0206] For example, the predicate mapping assignment algorithm is as follows:

[0207] According to the predicates in the first i-1 rows, columns 1 to k in the storage table, the predicates in the i-th row, column m are mapped to the column index in the storage table row by row. For example, if i is 3 and i-1 is 2, the column index of the predicate in the third row of the storage table is allocated according to the predicates in the first two rows (row 1 and row 2) in the storage table. When constructing the column index of the predicate in the i-th row, column m, first exclude the allocated predicates, and find the predicates that do not belong to the same frequent i-item set as the predicate in the i-1th row, column m (the second predicate field that satisfies the first condition above).

[0208] (1) When there are multiple predicates that meet the conditions (the second predicate field that meets the first condition above), the predicate that forms a frequent i-item set with other predicates outside the first i-1 rows and m columns and has the most queries in the frequent i-item set is assigned first, so as to minimize the probability of assigning predicates belonging to the same frequent i-item set to the same column. If there is no frequent i-item set with other predicates outside the first i-1 rows and m columns, search from the frequent i+1 item set. If i is already the largest number of frequent item sets, search from the i-1 frequent item sets.

[0209] (2) When there is a predicate that satisfies the condition (the second predicate field that satisfies the first condition above), the predicate is assigned to the mth column of the storage table, where m is the number of the column to be stored.

[0210] (3) If there is no predicate that meets the condition (the second predicate field that meets the first condition above), the predicate with the lowest query count in the frequent i-item set is assigned to the storage table.

[0211] For example, the sample data demonstration steps of the predicate mapping assignment algorithm are as follows:

[0212] 1) Build the predicate mapping stored in row 1

[0213] According to the frequent 1-item set (the first subquery field group in the above text) in descending order of query times, the predicates in the frequent 1-item set (the first predicate field in the above text) are mapped to columns 1 to k in the first row of the storage table (the first storage position in the above text), assuming that k is 3, and firstly construct the predicate mapping index table stored in the first row, as shown in Table 7:

[0214] Table 7

[0215] Subject Category predicate Column Index Row Index operating system Is open source 1 1 operating system Kernel 2 1 operating system Version 3 1

[0216] The first row of the subject "Ubuntu" is stored as shown in Table 8:

[0217] Table 8

[0218]

[0219]

[0220] 2) Construct the predicate mapping stored in row 2

[0221] According to the frequent 2-item set (the second subquery field group above), the predicate stored in the second row of the storage table is allocated. First, the predicate stored in the predicate 1 column in the second row is allocated, as shown in Table 8. The predicate stored in the predicate 1 column in the first row is "is open source". As shown in Table 6, there is "<operating system: is open source><operating system: developer>" in the frequent 2-item set. According to the predicate mapping allocation algorithm, the predicates that have been allocated (the predicate fields with determined storage locations above) and the predicate "developer" are excluded. There are multiple candidate predicates (the second predicate fields that meet the first condition above): "support central processing unit", "file system", "release", "mapping", "old version". The candidate predicates and the predicates "kernel" and "version" other than the predicate 1 column in the first row constitute the frequent 2-item set as shown in Table 9:

[0222] Table 9

[0223]

[0224] Among them, "<operating system: kernel><operating system: support central processing unit>" has the largest number of queries, so the predicate "support central processing unit" is stored in the predicate 1 column in the second row. The storage results of the predicate 1 column in the second row are shown in Table 10:

[0225] Table 10

[0226]

[0227] Secondly, assign the predicates stored in the Predicate 2 column in the second row, as shown in Table 6. The predicates in the frequent 2-item set with the predicate "kernel" are: "version", "supported CPU", "file system", "developer", "mapping", "release", and "old version", as shown in Table 11:

[0228] Table 11

[0229]

[0230] Excluding the above predicates and the already assigned predicates, there is no predicate that meets the assignment condition (the second predicate field that meets the first condition above), so according to the set "<operating system: kernel><operating system: old version>" with the lowest query times in the frequent 2-item set, the predicate "old version" is stored in the predicate 2 column in the second row. The storage result of the predicate 2 column in the second row is shown in Table 12:

[0231] Table 12

[0232]

[0233] Next, the predicates stored in the predicate 3 column in the second row are assigned, as shown in Table 6. The predicates in the frequent 2-item set with the predicate "version" are: "kernel", "file system", and "developer". Excluding the above predicates and the assigned predicates, there are two candidate predicates: "release" and "map". The candidate predicates and the predicates other than the predicate 3 column in the first row "is open source", "supports CPU", "kernel", and "old version" constitute a frequent 2-item set as shown in Table 13:

[0234] Table 13

[0235] <Operating System: Kernel><Operating System: Graphics Drawing> 29 <Operating System: Kernel><Operating System: Release> 28

[0236] Among them, "<operating system: kernel><operating system: mapping>" has the largest number of queries, so the predicate "mapping" is stored in the predicate 3 column in the second row. The storage result of the predicate 3 column in the second row is shown in Table 14:

[0237] Table 14

[0238]

[0239] 3) Construct the predicate mapping stored in row 3

[0240] According to the frequent three-item set (the third subquery field group above), the predicate stored in the third row of the storage table is allocated. First, the predicate stored in the predicate 1 column in the third row is allocated, as shown in Table 14. The predicate "is open source" is stored in the predicate 1 column in the first row, and the predicate "supports central processing unit" is stored in the predicate 1 column in the second row. As shown in Table 6, the frequent three-item set contains "<operating system: is open source><operating system: supports central processing unit><operating system: file system>". Excluding the predicate "file system" and the already allocated predicates, there are two candidate predicates: "developer" , "release", in addition, the candidate predicates and the predicates <"kernel", "old version"><"version", "mapping"> outside the predicate 1 column in the 1st and 2nd rows can form 4 combinations (the candidate predicates above and the predicates that have been assigned, and the predicates on the same predicate column constitute a combination): <"developer", "kernel", "old version">, <"developer", "version", "mapping">, <"release", "kernel", "old version">, <"release", "version", "mapping">, the frequent item set combinations existing in the frequent 3 item sets are shown in Table 15:

[0241] Table 15

[0242]

[0243] Among them, there are only two frequent item set combinations of the predicate "release", so the predicate "release" is stored in the predicate 1 column in the 3rd row. The dph table storing the knowledge graph data is shown in Table 16:

[0244] Table 16

[0245]

[0246]

[0247] Secondly, the predicates stored in the Predicate 2 column in the third row are assigned, as shown in Table 15. The Predicate 2 column in the first row stores the predicate "kernel", and the Predicate 2 column in the second row stores the predicate "old version". As shown in Table 6, there is "<operating system: kernel><operating system: release><operating system: old version>" in the frequent three-item set. Excluding the predicate "release" and the predicates that have been assigned, there are two candidate predicates: "developer" and "file system". In addition, the candidate predicates and the predicates <"is open source", "supports CPU"><"version", "mapping"> outside the Predicate 2 column in the first and second rows can form 4 combinations: <"developer", "is open source", "supports CPU">, <"developer", "version", "mapping">, <"file system", "is open source", "supports CPU">, <"file system", "version", "mapping">, and the frequent item set combinations existing in the frequent three-item set are shown in Table 17:

[0248] Table 17

[0249]

[0250] Among them, there is only one frequent item set combination of the predicate "file system", so the predicate "file system" is stored in the predicate 2 column in the third row. The storage result of the predicate 2 column in the third row is shown in Table 18:

[0251] Table 18

[0252]

[0253] The remaining predicate "developer" is stored in the predicate 3 column in the 3rd row. The storage result of the predicate 3 column in the 3rd row is shown in Table 19:

[0254] Table 19

[0255]

[0256] Finally, the predicate index table is shown in Table 20:

[0257] Table 20

[0258]

[0259]

[0260] Continue to refer Figure 7, in step 704, a knowledge graph storage is constructed based on the index table.

[0261] For example, after constructing the predicate index table of each subject category, the knowledge graph is constructed according to the index table and the DB2RDF storage mode. The traditional DB2RDF storage solution consists of four storage tables, namely the main hash table (dph table), the secondary hash table (ds table), the reverse main hash table (rph table) and the reverse secondary hash table (rs table). The main hash table is the main storage table. For multi-valued predicates in the main hash table, that is, there are multiple objects for the same predicate, a unique identification id value is generated at the corresponding object, and the id value and each corresponding object are stored in a row of the secondary hash table. The main hash table and the secondary hash table actually store the outbound edge information (from subject to object via predicate) of the entity node (subject) in the knowledge graph. In order to improve the query processing efficiency, it is also necessary to store the inbound edge information of the entity node (from object to subject via predicate). For this purpose, the DB2RDF solution provides a reverse main hash table and a reverse secondary hash table. The subject-predicate-object triples in the main hash table and the secondary hash table can be reversely converted to obtain a reverse main hash table and a reverse secondary hash table. According to the predicate index table, the data of the knowledge graph is stored in the main hash table and the reverse main hash table. When the data in the four storage tables is stored, the construction of the knowledge graph is completed.

[0262] In the application scenario of the above-mentioned knowledge graph storage, by mining frequent item sets with different usage frequencies of different predicates in different subject categories, assigning predicates to row and column indexes according to frequent item sets, and using index tables instead of hash functions to generate predicate-to-column mappings, the problem that hash functions do not consider the frequency of use of predicate combinations is solved, thereby minimizing the situation of query self-joins during the use of knowledge graphs.

[0263] The following is a description of an exemplary structure of the data storage device 455 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 2As shown, the software modules stored in the data storage device 455 of the memory 450 may include: a first determination module 4551, which is used to divide the multiple query fields included in the query record of the first knowledge graph into multiple query field groups, each query field includes a subject field type and a predicate field, and a query field group includes multiple query fields with the same subject field type; a second determination module 4552, which is used to extract multiple sub-query field groups from the query field group according to the query type of the predicate field for each query field group, and each sub-query field group includes a query field whose query number is greater than the query number threshold; a third determination module 4553, which is used to determine, for the query field in each sub-query field group, according to the query number of the query field, the first storage position of the predicate field of the query field in the preset table, and store the predicate field in the first storage position in the preset table; a graph generation module 4554, which is used to generate a second knowledge graph according to the preset table storing the predicate field.

[0264] In some embodiments, the second determination module 4552 is further configured to determine a first preset number of sub-query field groups, and determine the query type of the predicate field in the query field group according to the first preset number, the query type including the first query type to the Nth query type, N being the first preset number, the i-th query type representing a query in the form of a predicate field set including i predicate fields, and i being a positive integer less than or equal to N; for each query type and the query times of each predicate field, determining the combined query times of each predicate field set of the query type; extracting, from the multiple predicate field sets of the query type, the target predicate field included in the predicate field set whose combined query times are greater than the query times threshold; and determining the sub-query field group corresponding to the query type based on the query field corresponding to each target predicate field.

[0265] In some embodiments, the second determination module 4552 is further used to determine a preset maximum number of columns of a preset table, where the preset maximum number of columns is the maximum value of a column storing predicate fields; determine the total number of predicate fields of different predicate types in the query field group; and calculate a first preset number of sub-query field groups based on the total number and the preset maximum number of columns.

[0266] In some embodiments, the sub-query field group includes a first sub-query field group to an Nth sub-query field group, where N is a first preset number, and the ith query type corresponding to the ith sub-query field group represents querying in the form of a predicate field set including i predicate fields, and i is a positive integer less than or equal to N; the third determination module 4553 is further configured to extract K first predicate fields of the first query type from the first sub-query field group, where the first sub-query field group includes the first predicate fields of the first query type, and K is the preset maximum number of columns of the columns for storing predicate fields in the preset table; perform a descending order sorting on the K first predicate fields according to the query times to obtain a first sorting result; use the mth column of the first row of the preset table as the first storage position of the mth first predicate field in the first sorting result, where 0 < m ≤ K; use the first predicate field as the predicate field with the determined storage position, and based on the predicate field with the determined storage position and the query times of the predicate field set in the ith sub-query field group, determine the first storage position of the un-stored predicate field in the ith sub-query field group in the ith row of the preset table.

[0267] In some embodiments, the third determination module 4552 is further configured to, for the mth column of the ith row, determine a second predicate field in the ith sub-query field group that satisfies a first condition; the first condition includes that the ith sub-query field group is different from the sub-query field group of the predicate field with the determined storage position in the mth column, and the second predicate field in the ith sub-query field group and the predicate field with the determined storage position in the mth column do not belong to the same predicate field set; in the case where there is one second predicate field in the ith sub-query field group, use the mth column of the ith row as the first storage position of the second predicate field; in the case where there are multiple second predicate fields in the ith sub-query field group, select a target second predicate field with the largest query times from the multiple second predicate fields, use the mth column of the ith row as the first storage position of the target second predicate field, and use the (m + 1)th column of the ith row as the first storage position of the second predicate field with the largest query times among the remaining second predicate fields until the first storage position of each second predicate field is determined.

[0268] In some embodiments, in the case where there is no second predicate field in the ith sub-query field group that satisfies the first condition, the third determination module 4552 is further configured to, in the case where i + 1 ≤ N, extract a target second predicate field from the (i + 1)th sub-query field group and use the mth column of the ith row as the first storage position of the target second predicate field; in the case where there is no second predicate field in each sub-query field group that satisfies the first condition, use the mth column of the ith row as the first storage position of the predicate field with the least query times in the ith sub-query field group.

[0269] In some embodiments, the third determination module 4552 is also used to, after storing the predicate field in the first storage position in the preset table, determine the second storage position of the object field associated with each predicate field in the preset table based on the first storage position, and store the object field to the second storage position; determine the third storage position of the subject field type corresponding to each predicate field in the preset table based on the first storage position, and store the subject field type to the third storage position; determine the fourth storage position of the subject field of the subject field type corresponding to each predicate field in the preset table based on the first storage position, and store the subject field to the fourth storage position.

[0270] In some embodiments, the graph generation module 4554 is also used to use the preset table as the first preset table, and determine the subject field and the object field based on the first preset table; obtain the object field identifier of the object field, and store the object field identifier and the object field in association with each other to obtain a second preset table; perform column conversion on the first preset table to obtain a third preset table; obtain the subject field identifier of the subject field, and store the subject field identifier and the subject field in association with each other to obtain a fourth preset table; and generate a second knowledge graph based on the mapping relationships corresponding to the first preset table, the second preset table, the third preset table, and the fourth preset table, respectively.

[0271] The embodiment of the present application provides a computer program product, which includes computer executable instructions or computer programs, and the computer executable instructions or computer programs are stored in a computer-readable storage medium. The processor of the electronic device reads the computer executable instructions or computer programs from the computer-readable storage medium, and the processor executes the computer executable instructions or computer programs, so that the electronic device executes the data storage method described above in the embodiment of the present application.

[0272] The present application embodiment provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions or computer programs are stored. When the computer-executable instructions or computer programs are executed by a processor, the processor will be caused to execute the data storage method provided by the present application embodiment, for example, Figure 3A The data storage method is shown.

[0273] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface storage, optical disk, or CD-ROM; or it may be various devices including one or any combination of the above memories.

[0274] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0275] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).

[0276] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.

[0277] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A data storage method, characterized in that: The method comprises: Divide the multiple query fields included in the query record of the first knowledge graph into multiple query field groups, each of the query fields includes a subject field type and a predicate field, and one query field group includes multiple query fields with the same subject field type; For each of the query field groups, extract multiple sub-query field groups from the query field group according to the query type of the predicate field, each of the sub-query field groups includes the query field whose query times are greater than a query times threshold; For the query field in each sub-query field group, determine the first storage position of the predicate field of the query field in a preset table according to the query times of the query field, and store the predicate field in the first storage position of the preset table; A second knowledge graph is generated according to the preset table storing the predicate field.

2. The method according to claim 1, characterized in that The step of extracting a plurality of sub-query field groups from the query field group according to the query type of the predicate field comprises: Determine a first preset number of the sub-query field groups, and determine a query type of the predicate field in the query field group according to the first preset number, the query type including a first query type to an Nth query type, the i-th query type represents a query in the form of a predicate field set including i predicate fields, N is equal to the first preset number, and i is a positive integer less than or equal to N; For each query type and the query times of each predicate field, determine the combined query times of each predicate field set of the query type; Extracting, from the plurality of predicate field sets of the query type, a target predicate field included in the predicate field set whose combined query times are greater than a query times threshold; Based on the query field corresponding to each of the target predicate fields, a sub-query field group corresponding to the query type is determined.

3. The method according to claim 2, characterized in that The determining a first preset number of the sub-query field groups includes: Determine a preset maximum number of columns of the preset table, wherein the preset maximum number of columns is the maximum value of a column storing a predicate field; Determining the total number of predicate fields of different predicate types in the query field group; A first preset number of the sub-query field groups is calculated according to the total number and the preset maximum number of columns.

4. The method according to claim 1, characterized in that: The sub-query field groups include a first sub-query field group to an N-th sub-query field group, where N is a first preset number, and the i-th query type corresponding to the i-th sub-query field group represents a query in the form of a predicate field set including i predicate fields, and i is a positive integer less than or equal to N; The step of determining, for the query field in each sub-query field group, a first storage position of the predicate field of the query field in a preset table according to the query times of the query field, comprises: Extracting K first predicate fields of the first query type from the first sub-query field group, wherein the first sub-query field group includes the first predicate field of the first query type, and K is a preset maximum number of columns in a preset table for storing predicate fields; Sort the K first predicate fields in descending order according to the number of queries to obtain a first sorting result; The mth column of the first row of the preset table is used as the first storage position of the mth first predicate field in the first sorting result, <m≤K; The first predicate field is used as the predicate field with a determined storage position, and based on the predicate field with a determined storage position and the number of queries of the predicate field set in the i-th sub-query field group, a first storage position of the unstored predicate field in the i-th sub-query field group in the i-th row of the preset table is determined.

5. The method according to claim 4, characterized in that The determining, based on the predicate field of the determined storage position and the query times of the predicate field set in the i-th sub-query field group, of the first storage position of the unstored predicate field in the i-th sub-query field group in the i-th row of the preset table comprises: For the mth column of the i-th row, determine a second predicate field in the i-th sub-query field group that satisfies a first condition; the first condition includes that the i-th sub-query field group is different from the sub-query field group of the predicate field whose storage position has been determined in the m-th column, and the second predicate field in the i-th sub-query field group does not belong to the same predicate field set as the predicate field whose storage position has been determined in the m-th column; When there is only one second predicate field in the i-th subquery field group, using the m-th column of the i-th row as the first storage position of the second predicate field; In the case that there are multiple second predicate fields in the i-th sub-query field group, a target second predicate field with the largest number of queries is selected from the multiple second predicate fields, and the m-th column of the i-th row is used as the first storage position of the target second predicate field, and the m+1-th column of the i-th row is used as the first storage position of the second predicate field with the largest number of queries among the remaining second predicate fields, until the first storage position of each second predicate field is determined.

6. The method according to claim 5, characterized in that In the case that the second predicate field that satisfies the first condition does not exist in the i-th sub-query field group, the method further includes: In the case that i+1≤N, extract the target second predicate field from the i+1th subquery field group, and use the mth column of the i-th row as the first storage position of the target second predicate field; When there is no second predicate field satisfying the first condition in each of the sub-query field groups, the mth column of the i-th row is used as the first storage position of the predicate field with the least number of queries in the i-th sub-query field group.

7. The method according to claim 1, characterized in that After storing the predicate field in the first storage location in the preset table, the method further includes: Based on the first storage position, determining a second storage position of the object field associated with each of the predicate fields in the preset table, and storing the object field in the second storage position; Based on the first storage position, determining a third storage position of the subject field type corresponding to each of the predicate fields in the preset table, and storing the subject field type in the third storage position; Based on the first storage position, a fourth storage position of a subject field of the subject field type corresponding to each of the predicate fields in the preset table is determined, and the subject field is stored in the fourth storage position.

8. The method according to claim 7, characterized in that The generating a second knowledge graph according to the preset table storing the predicate field comprises: Using the preset table as a first preset table, and determining a subject field and an object field based on the first preset table; Obtaining an object field identifier of the object field, and storing the object field identifier and the object field in association with each other to obtain a second preset table; Perform column conversion on the first preset table to obtain a third preset table; Obtaining a subject field identifier of the subject field, and storing the subject field identifier in association with the subject field to obtain a fourth preset table; A second knowledge graph is generated based on the mapping relationships corresponding to the first preset table, the second preset table, the third preset table, and the fourth preset table respectively.

9. An electronic device, characterized in that: The electronic device comprises: A memory for storing computer executable instructions or computer programs; A processor, used to implement the data storage method according to any one of claims 1 to 8 when executing the computer executable instructions or computer programs stored in the memory.

10. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer programs are executed by a processor, the data storage method according to any one of claims 1 to 8 is implemented.