CN116204559A - Data storage and data query method and device, electronic equipment and medium - Google Patents

Data storage and data query method and device, electronic equipment and medium Download PDF

Info

Publication number
CN116204559A
CN116204559A CN202310228228.5A CN202310228228A CN116204559A CN 116204559 A CN116204559 A CN 116204559A CN 202310228228 A CN202310228228 A CN 202310228228A CN 116204559 A CN116204559 A CN 116204559A
Authority
CN
China
Prior art keywords
group
relationship
target
relation
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310228228.5A
Other languages
Chinese (zh)
Inventor
王天祺
刘昊骋
徐世界
徐靖宇
田建
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN202310228228.5A priority Critical patent/CN116204559A/en
Publication of CN116204559A publication Critical patent/CN116204559A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; Linked lists

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The disclosure provides a data storage and data query method, a data storage and data query device, electronic equipment and a medium, relates to the technical field of data processing, and particularly relates to the technical field of big data such as data mining and data processing. The specific implementation scheme is as follows: determining an object group to which an object recorded in the graph data belongs; determining a relation group of the object relation recorded in the graph data based on the object group of the object with the object relation; the resulting object groupings and relationship groupings are stored in a relational database. When the data storage method provided by the embodiment of the disclosure is used for data storage, the consumption of storage resources can be saved.

Description

Data storage and data query method and device, electronic equipment and medium
Technical Field
The present disclosure relates to the field of data processing technologies, and in particular, to the field of big data technologies such as data mining and data processing.
Background
The graph data can conveniently describe the intricate and complex relationship between objects, and has wide application in daily life. For example, the graph data may be used to describe interactions between users of the application, affinities between people, and the like.
With the advent of the big data age, the data volume of various data has been increasing in an explosive manner, and the data volume of graph data is increasing.
In the prior art, various graph databases are generally used for storing graph data.
Disclosure of Invention
The disclosure provides a data storage method, a data query method, a data storage device, an electronic device and a medium.
According to an aspect of the present disclosure, there is provided a data storage method including:
determining an object group to which an object recorded in the graph data belongs;
determining a relation group of the object relation recorded in the graph data based on the object group of the object with the object relation;
the resulting object groupings and relationship groupings are stored in a relational database.
According to another aspect of the present disclosure, there is provided a data query method, including:
responding to a data query request, and analyzing the data query request to obtain an object identifier;
determining a target object group to which a first object represented by the obtained object identifier belongs from object groups stored in a relational database;
determining a target relationship group from relationship groups stored in the relationship database based on the determined target object group;
And querying the object relation which is matched with the data query request and is specific to the first object in the target relation group.
According to another aspect of the present disclosure, there is provided a data storage device comprising:
the object grouping determining module is used for determining an object grouping to which an object recorded in the graph data belongs;
a relationship group determining module, configured to determine, based on an object group to which an object having an object relationship belongs, a relationship group to which an object relationship recorded in the graph data belongs;
and the grouping storage module is used for storing the obtained object grouping and the relation grouping in the relation type database.
According to another aspect of the present disclosure, there is provided a data query apparatus including:
the object identification obtaining module is used for responding to the data query request and analyzing the data query request to obtain an object identification;
the target object grouping determining module is used for determining a target object grouping to which the first object represented by the obtained object identifier belongs from object groupings stored in the relational database;
a target relationship group determination module for determining a target relationship group from relationship groups stored in the relational database based on the determined target object group;
And the query module is used for querying the object relation which is matched with the data query request and is specific to the first object in the target relation group.
According to another aspect of the present disclosure, there is provided an electronic device including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the data storage method or the data query method described above.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the above-described data storage method or data query method.
According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the above-described data storage method or data query method.
From the above, when the scheme provided by the embodiment of the present disclosure is applied to data storage, the object group to which the object recorded in the graph data belongs is determined, and then the relationship group to which the object relationship recorded in the graph data belongs is determined based on the object group to which the object having the object relationship belongs, so that the obtained object group and the relationship group can be stored in the relationship database, and the storage of the graph data is successfully realized. Compared with the storage of the graph data in the graph database, the scheme provided by the embodiment of the disclosure can directly store the graph data in the relational database with smaller consumption of storage resources, so that the consumption of the storage resources is reduced.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
FIG. 1 is a schematic diagram of an interaction relationship network according to an embodiment of the present disclosure;
fig. 2 is a flowchart of a first data storage method according to an embodiment of the disclosure;
FIG. 3 is a schematic diagram of a first object relationship grouping flow provided by an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a second object relationship grouping flow provided by an embodiment of the present disclosure;
FIG. 5 is a flowchart illustrating a second data storage method according to an embodiment of the present disclosure;
fig. 6 is a flow chart of a data query method according to an embodiment of the disclosure;
FIG. 7 is a schematic diagram of a data storage device according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of a data query device according to an embodiment of the present disclosure;
fig. 9 is a block diagram of an electronic device used to implement a data storage method or a data query method of an embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
First, an execution body of an embodiment of the present disclosure will be described.
The implementation main body of the scheme provided by the embodiment of the disclosure is as follows: any one electronic device with the functions of calculation, storage and the like.
Some concepts involved in the schemes provided in the embodiments of the present disclosure are described below.
1. Graph data, object relationship
In the embodiment of the disclosure, the related graph data may be any type of graph data such as interactive relationship network data, knowledge graph data, and the like.
The graph data includes objects and object relationships between the objects, wherein the objects may be referred to as entities, nodes, etc., and the object relationships may be referred to as entity relationships, edges, etc.
In some cases, attributes of the object relationships, weights of the object relationships, and the like may also be recorded in the graph data, which is not limited by the present disclosure.
The following describes objects and object relationships recorded in the graph data more intuitively by taking the interaction relationship network shown in fig. 1 as an example.
Referring to fig. 1, a schematic diagram of an interaction relationship network according to an embodiment of the disclosure is provided.
ID1-ID6 in FIG. 1 represent objects recorded in an interactive relationship network; the line segments between the objects characterize the object relationships existing between the objects; the marked text on the object relationship represents the attribute of the object relationship, such as comment, praise, collection, attention, friend, sharing, forwarding and the like.
2. Source object and destination object of object relation
The object relationship may be directional, wherein for a unidirectional object relationship, a source object may be understood as an active object of the object relationship or an initiator of the object relationship, and a destination object may be understood as a passive object of the object relationship or a recipient of the object relationship; for a bi-directional object relationship, either object on either side of the object relationship may be referred to as the source object of the object relationship, and correspondingly, the other object may be referred to as the destination object of the object relationship.
The source object and the destination object are intuitively described below with reference to fig. 1.
Referring to fig. 1, the direction of the directed line segment in fig. 1 may represent the direction of the object relationship, and may include a unidirectional line segment and a bidirectional line segment, which are illustrated below.
For example, with respect to the comment relationship between ID2 and ID1, it can be seen that the directed line segment points from ID2 to ID1, and it can be understood that the directed line segment characterizes the object relationship from ID2 to ID1, i.e., the object characterized by ID2 initiates a comment to the object characterized by ID 1. In this case, ID2 may be referred to as a source object of the above-described object relationship, and ID1 may be referred to as a destination object of the above-described object relationship.
For another example, regarding the friend relationship between ID1 and ID6, it can be seen that the directed line segment is a bidirectional line segment between ID1 and ID6, and it can be understood that the directed line segment characterizes the object relationship between ID1 and ID6 as being mutual, that is, the object characterized by ID2 and the object characterized by ID1 are friends. In this case, ID1 may be referred to as a source object of the above object relationship, and ID6 may be referred to as a destination object of the above object relationship; alternatively, ID6 may be referred to as a source object of the above-described object relationship, and ID1 may be referred to as a destination object of the above-described object relationship.
The data storage method provided by the embodiment of the present disclosure is described in detail below.
Referring to fig. 2, a flowchart of a first data storage method according to an embodiment of the disclosure is provided, where the method includes the following steps S201 to S203.
Step S201: an object group to which the object recorded in the map data belongs is determined.
The map data may be full-size data to be stored, or may be incremental data based on stored map data.
Therefore, when determining an object group to which an object recorded in the map data belongs, the following two cases can be classified.
For the case where the map data is full data: in this case, an object group may be created first, and then an object group to which an object recorded in the map data belongs may be determined from the created object group. The detailed description will be given in the example shown in fig. 5, which will not be described in detail here.
For the case where the graph data is incremental data: in this case, the object group to which the object recorded in the map data belongs may be determined in the following manner.
In one embodiment, an object group having a number of objects included in an existing object group not greater than the number of expected group members may be determined, and an object group to which an object recorded in the map data belongs may be selected from the determined object group.
The above-described number of expected group members characterizes the number of objects contained within the expected group of objects, which may be empirically set by a worker.
The group having the smallest number of objects included in the determined object group may be determined as the object group to which the object recorded in the map data belongs, or any one of the determined object groups may be determined as the object group to which the object recorded in the map data belongs.
When the number of the objects contained in the object group is not greater than the number of the expected group members, the object group is indicated to have member vacancies, so that in this case, the object group with the member vacancies can be determined as the group to which the object belongs, and thus, the object group to which the object belongs can be reasonably selected according to the member vacancies of the object group.
In another embodiment, a new object group may be created and determined as the object group to which the object recorded in the graph data belongs, in the case that the number of objects included in each existing object group is not less than the expected group member number.
The number of the new object groups created can be determined according to the number of the objects in the graph data and the number of the expected group members, and can be 1 or more.
For example, a ratio of the number of objects in the graph data to the number of expected group members may be calculated, the resulting ratio is rounded up, and the rounded value is determined as the number of new object groups.
In this case, a new group may be created in a case where the number of objects included in each existing object group is not less than the number of expected group members, and the new group may be determined as the group to which the object belongs. Therefore, by creating a new group when no spare object group exists, the number of the members of the object group can be effectively prevented from exceeding the expectations, and the rationality and the stability of the scheme are improved.
In one embodiment of the present disclosure, the above-described object group may be in the form of an object group file in which an identification of the contained object is recorded.
Step S202: based on the object group to which the object having the object relationship belongs, a relationship group to which the object relationship recorded in the graph data belongs is determined.
Specifically, the relationship group to which the object relationship recorded in the graph data belongs may be determined according to the following division rule.
1. The source objects of the object relationships in the same relationship group belong to the same object group.
When the relationship group to which the object relationship belongs is determined according to the division rule, the object relationship of the source object belonging to the same object group can be divided into the same relationship group, that is, the same relationship group contains the object relationship of the source object belonging to the same object group.
The following describes the division manner under the above-mentioned division rule more intuitively with reference to fig. 3.
Referring to fig. 3, a schematic diagram of a first object relationship grouping flow is provided in an embodiment of the disclosure.
In fig. 3, 1,2, 3, 4, 5 represent the identification of objects recorded in the graph database, and for convenience of description, the object characterized by the identification X will be hereinafter referred to as object X; [1,2], [2,3], [2,4], [5,3], [4,1] represent object relationships recorded in the graph database, wherein [ X1, X2] characterizes the object relationship between the object X1 and the object X2.
Object group 1 includes objects 1 to 3, and object group 2 includes objects 4 and 5.
It can be seen that the source objects of the object relationships [1,2], [2,3], [2,4] are the object 1 or the object 2, and the object 1 and the object 2 belong to the object group 1, so that when the object relationships are divided according to the division rule, the object relationships are divided into the relationship group 1; the source object of the above object relationships [5,3] and [4,1] is the object 4 or the object 5, and since the object 4 and the object 5 belong to the object group 2, these relationships are divided into the relationship group 2 when divided according to the above-described division rule.
In this case, since one relationship group includes the object relationships of the source objects belonging to the same object group, when there is a query request for a source object belonging to a certain object group, the relationship group of the source object belonging to the object group of the included object relationship can be determined, and the object relationship of the source object can be conveniently queried from the determined relationship group, so that the efficiency in data query can be improved compared with the query of the object relationship from all the relationship groups.
2. The target objects of the object relationships in the same relationship group belong to the same object group.
When the relationship group to which the object relationship belongs is determined according to the rule, the object relationship of the object belonging to the same object group can be divided into the same relationship group, that is, the same relationship group contains the object relationship of the object belonging to the same object group.
The specific division manner under the division rule is similar to the foregoing manner, and only the source object is replaced by the destination object, which is not described herein.
In this case, since one relationship group includes the object relationships of the target objects belonging to the same object group, when there is a query request for a target object belonging to a certain object group, the relationship group of the target object belonging to the target group of the included object relationship can be determined, and the target object relationship can be conveniently queried from the determined relationship group, so that the efficiency in data query can be improved compared with the case of querying the target relationships from all the relationship groups.
3. The source objects of the object relationships in the same relationship group belong to the same object group, and the destination objects of the object relationships in the same relationship group belong to the same object group.
When the relationship group to which the object relationship belongs is determined according to the division rule, the object relationship that the source object belongs to the same object group and the destination object belongs to the same group can be divided into the same relationship group, that is, the same relationship group contains the object relationship that the source object belongs to the same object group and the destination object belongs to the same group.
The above-described division rule is more intuitively explained with reference to fig. 4.
Referring to fig. 4, a schematic diagram of a second object relationship grouping flow is provided in an embodiment of the disclosure.
In fig. 4, the relationship group (A1, A2) characterizes the object relationship in which the source object belongs to the object group A1 and the destination object belongs to the object group A2.
As can be seen from fig. 4, the source object of the object relationships [1,2], [2,3] is object 1 or object 2, and the destination object is object 2 or object 3, and since all of the objects 1-3 belong to the object group 1, these relationships are divided into the relationship groups (1, 1); the source object of the object relationship [2,4] is the object 2, the destination object is the object 4, and since the object 2 belongs to the object group 1 and the object 4 belongs to the object group 2, the object relationship is divided into the relationship groups (1, 2); similarly, the object relationships [4,1] are divided into the relationship groups (2, 1), and the object relationships [5,3] are divided into the relationship groups (2, 2), which will not be described again.
It can be seen that, when the relationship group to which the object belongs is determined according to the above-mentioned division rule, the number of relationship groups is the square of the number of object groups, and as shown in fig. 4, 2 object groups are included, and 2×2=4 relationship groups are included.
In this case, since one relationship group includes the object relationships in which the source objects belong to the same object group and the destination objects belong to the same group, when there is a query request for a source object belonging to a certain object group and a destination object belonging to a certain object group, the relationship groups in which the source object and the destination object of the included object relationships belong to the object groups can be determined, and further, the object relationships between the source object and the destination object can be conveniently queried from the determined relationship groups, and the efficiency in data query can be improved as compared with the case of querying the object relationships from all the relationship groups.
In one embodiment of the present disclosure, the relationship group may be in the form of a relationship group file in which an identification of the contained object relationships is recorded.
Step S203: the resulting object groupings and relationship groupings are stored in a relational database.
After the object group and the relation group are obtained, the access address of the relation database can be determined according to preset configuration information, so that the obtained object group and relation group are stored in the database.
The embodiments of the present disclosure are not limited to the specific types of relational databases described above.
In one case, the relational database may be a mysql database, and the configuration information may include a port of the mysql database and a db (database) name, so that the object group and the relational group can be stored in the database in the form of a mysql database table.
In another case, the relational database may be a sparksql database, in which case the configuration information may include the address of hdfs (Hadoop Distributed File System ) and the meta-store of hive, so that the object and relational groupings can be stored on the spark distributed clusters in the form of a hive data table.
From the perspective of storing the specific content of the relational database, the resulting object groupings and relationship groupings may be stored in the following manner.
In one embodiment, the object groupings and relationship groupings may be stored directly in the database.
In this case, the data table name of the object group stored in the database may be the identification of the object group, such as 1,2,3, etc.; the data table name of the relation group stored in the database may be an identifier, such as (1, 1), (1, 2), etc., that characterizes the relation between the relation group and the object group, wherein the relation group with the data table name (A1, A2) contains the object relation that the source object belongs to the object group A1 and the destination object belongs to the object group A2.
In another embodiment, for each resulting object group, a correspondence between the object group and its association group may be determined, and then the resulting object group, the relationship group, and the determined correspondence may be stored in the relationship-type data.
Wherein, the object relation contained in the association relation group is associated with the object contained in the object group. For example, the association group of the object group 1 may be a relationship group in which the source object of the included object relationship belongs to the object group 1, or may be a relationship group in which the destination object of the included object relationship belongs to the object group 1.
Therefore, when the embodiment is executed, not only the object group and the relation group are stored in the object relation database, but also the corresponding relation between each object group and the relation group thereof is stored, so that when the data query is carried out subsequently, the relation group of the object group can be determined according to the object group to which the object to be queried belongs and the corresponding relation, and further the object relation of the object to be queried can be directly queried in the relation group, and the query efficiency in the data query is improved.
From the above, when the scheme provided by the embodiment of the present disclosure is applied to data storage, the object group to which the object recorded in the graph data belongs is determined, and then the relationship group to which the object relationship recorded in the graph data belongs is determined based on the object group to which the object having the object relationship belongs, so that the obtained object group and the relationship group can be stored in the relationship database, and the storage of the graph data is successfully realized. Compared with the storage of the graph data in the graph database, the scheme provided by the embodiment of the disclosure can directly store the graph data in the relational database with smaller consumption of storage resources, so that the consumption of the storage resources is reduced.
In addition, because the scheme provided by the embodiment of the disclosure can realize that the graph data is stored in the relational database, when the downstream task is carried out, staff can directly process the graph data in the relational database by using the query language of the relational database without processing the graph data in the graph database by using the query language of the graph database, and further, the query languages of various graph databases are not required to be learned, so that the learning cost of the staff is reduced.
In addition, when determining the relationship group of the object relationship recorded in the graph data, the scheme provided by the embodiment of the disclosure is determined based on the object group of the object having the object relationship, so that the relationship group of the object relationship is associated with the object group of the object, and when carrying out data query based on the stored graph data, the target relationship group associated with the object group of the object to be queried can be determined from the relationship group, and then the object relationship of the object to be queried is queried from the target relationship group. Compared with the query of the object relationship from all the relationship groups, the query range is reduced, and the query efficiency in the data query is improved.
The following describes a method for specifying an object group to which an object recorded in the map data belongs when the map data is delta data.
On the basis of the embodiment shown in fig. 2, in the case where the map data is full-size data, an object group may be created first, and then an object group to which an object recorded in the map data belongs may be determined from the created object group. In view of the foregoing, embodiments of the present disclosure provide a second data storage method.
Referring to fig. 5, a flowchart of a second data storage method according to an embodiment of the disclosure is provided, where the method includes the following steps S501 to S504.
Step S501: the target number of object groups is determined based on at least one of the total amount of resources of the device, the number of objects recorded in the graph data, the number of expected groups, and the number of expected group members.
The total amount of resources of the device may include a total amount of storage resources and a total amount of total storage resources, and the expected number of groups and the expected number of group members may be empirically set by a worker.
As can be seen from the foregoing embodiment shown in fig. 2, on the one hand, the greater the number of object groups, the greater the number of relationship groups, and the lower the storage efficiency when storing the object groups and the relationship groups into the database; on the other hand, the fewer the objects or object relationships contained in each object group and relationship group, the fewer the object relationships contained in the target relationship group determined based on the object group to which the object to be queried belongs, that is, the smaller the query range, which is beneficial to improving the query rate.
In view of the above description, the embodiments of the present disclosure are not limited to a specific manner of determining the target number based on the above information, and are described below by way of example.
In this case, the ratio of the number of objects recorded in the graph data to the number of expected packets may be calculated first, the obtained ratio is rounded up to obtain a first number, the storage resource consumption when the graph data is stored based on the first number and the calculation resource when the data query is performed based on the graph data are determined, and then the first number is adjusted, and in the case where the storage resource consumption and the calculation resource consumption do not exceed the total storage resource amount and the total calculation resource amount, respectively, a second number is obtained when the sum of the storage resource consumption and the calculation resource consumption is minimized.
At this time, if the difference between the second number and the expected number of packets is not greater than the preset deviation, the adjusted second number may be determined as the target number.
In another case, after the first number is obtained, the first number may be adjusted, and in a case where the total storage resource consumption and the total computing resource consumption do not exceed the total storage resource consumption and the total computing resource consumption, respectively, a second number is obtained such that the storage resource consumption and the computing resource consumption are balanced.
At this time, if the difference between the second number and the expected number of packets is not greater than the preset deviation, the adjusted second number may be determined as the target number.
Step S502: a target number of object groups are created, and an object group to which an object recorded in the map data belongs is determined from the created object groups.
The embodiment of the present disclosure is not limited to a specific manner of determining an object group to which an object recorded in graph data belongs, and will be described below by way of example.
In one embodiment, objects recorded in the graph data may be randomly partitioned into groups of created objects.
Specifically, each object may be assigned a random number within a 1-target number, and then the object is divided into groups of objects identified as random numbers corresponding to the object.
In another embodiment, the object identification of the object recorded in the graph data may be subjected to a remainder processing, and the object recorded in the graph data may be divided into each created object group based on the resulting remainder.
Specifically, the objects may be partitioned into groups of objects identified as resulting remainders.
Step S503: based on the object group to which the object having the object relationship belongs, a relationship group to which the object relationship recorded in the graph data belongs is determined.
Step S504: the resulting object groupings and relationship groupings are stored in a relational database.
The steps S503 to S504 are the same as the steps S202 to S203 in the embodiment shown in fig. 2, and are not repeated here.
From the above, when the scheme provided by the embodiment of the present disclosure is applied to determine the group to which the object recorded in the graph data belongs, the target number of the object groups may be determined according to the total resource amount of the device, the number of the objects recorded in the graph data, the number of the expected groups, the number of the expected group members, and other various information, then the target number of the object groups may be created, and the object group to which the object recorded in the graph data belongs may be determined from the created object groups. Therefore, the number of the object groups can be determined according to various information such as the total resource amount of the equipment, the determined number of the object groups is more matched with the actual situation, and the flexibility and the reliability of the scheme are improved.
Corresponding to the data storage method, the embodiment of the disclosure also provides a data query method.
Referring to fig. 6, a flow chart of a data query method according to an embodiment of the disclosure is provided, where the method includes the following steps S601 to S604.
Step S601: and responding to the data query request, and analyzing the data query request to obtain the object identification.
The data query request may carry 1 object identifier or may carry a plurality of object identifiers, so that the number of object identifiers obtained by parsing the data query request in this step may be 1 or a plurality of object identifiers.
In addition, the obtained object identifier may include a source object identifier, a destination object identifier, and both the source object identifier and the destination object identifier.
When the object identifier comprises a source object identifier, a first object representing the object identifier is a source object, and the source object of the object relationship to be queried corresponding to the data query request is the first object;
when the object identifier comprises a target object identifier, a first object representing the object identifier is a target object, and the target object of the object relationship to be queried is the first object;
when the object identifier comprises a source object identifier and a destination object identifier, the first object representing the object identifier comprises a source object and a destination object, and the source object and the destination object of the object relationship to be queried are both the first object.
Step S602: and determining a target object group to which the first object characterized by the obtained object identification belongs from object groups stored in the relational database.
In this step, the obtained object identifier may be matched in the object group, and the object group matched to the obtained object identifier may be determined as the target object group to which the first object represented by the object identifier belongs.
Step S603: based on the determined target object groupings, a target relationship grouping is determined from the relationship groupings stored in the relational database.
In this step, the target relationship group can be determined according to the difference of the contents stored in the relationship database in the following two cases.
First, a case will be described in which only the object group and the relationship group are stored in the relational database.
As can be seen from the foregoing step S601, the obtained object identifiers may include different types of identifiers, and the target relationship group may be determined in the following manner according to the kind of the obtained object identifier.
In one embodiment, if the obtained object identifier includes a source object identifier and does not include a destination object identifier, a target relationship group including a source object of the object relationship belonging to the target object group may be determined from relationship groups stored in the relational database.
In this case, the source object representing the relationship between the objects to be queried corresponding to the data query request is the first object represented by the source object identifier.
Specifically, a target relationship group to which the source object of the contained object relationship belongs may be determined based on the object group and the data table name of the relationship group.
As can be seen from the foregoing embodiment shown in fig. 2, the data table names of the relationship groups may characterize the relationship between the relationship groups and the object groups, and specifically, the relationship group with the data table name (A1, A2) includes the object relationship that the source object belongs to the object group with the data table name A1 and the destination object belongs to the object group with the data table name A2.
Therefore, if the data table name of the target object group is 1, the relationship group of the data table name (1, n) includes the object relationship of the source object belonging to the target group, and the relationship group of the data table name (1, n) can be determined as the target relationship group. Where N may be any value.
If the object identifier includes a plurality of source object identifiers, the scheme shown in this embodiment may be executed for each source object identifier, and only the target object group needs to be determined as the target object group corresponding to the source object identifier.
The target relation group comprises the object relation of the first object because the source object belongs to the target object group and the first object characterized by the source identifier belongs to the target object group. In summary, in the case that the obtained object identifier includes the source object identifier and does not include the destination object identifier, after the above-mentioned target relationship group is obtained, the object relationship of the first object represented by the source identifier may be accurately queried from the target relationship group.
In another embodiment, if the obtained object identifier includes a destination object identifier and does not include a source object identifier, then a target relationship group is determined from the relationship group, in which the destination object of the included object relationship belongs to the target relationship group.
In this case, the destination object representing the relationship between the objects to be queried corresponding to the data query request is the first object represented by the destination object identifier.
The specific implementation is similar to the previous embodiment, and only the source object is replaced by the destination object, which is not described herein.
The target relation group comprises the object relation of the target object belonging to the target object group, and the first object characterized by the target identifier belongs to the target object group, so that the target relation group comprises the object relation of the first object. In summary, in the case that the obtained object identifier includes the destination object identifier and does not include the source object identifier, after the above-mentioned target relationship group is obtained, the object relationship of the first object represented by the destination identifier may be accurately queried from the target relationship group.
In yet another embodiment, if the obtained object identification includes a source object identification and a destination object identification, a target relationship group in which the source object of the included object relationship belongs to the first object group and the destination object belongs to the second object group is determined from the relationship groups.
Wherein the first object group is: the source object identification characterizes a target object group to which the object belongs, and the second object group is as follows: the destination identifies a target object group to which the characterized object belongs.
In this case, the source object representing the relationship between the objects to be queried corresponding to the data query request is the first object represented by the source object identifier, and the destination object is the first object represented by the destination object identifier.
Wherein, the target relation group of the source object belonging to the first object group and the target object belonging to the second object group of the contained object relation can be determined based on the object group and the data table name of the relation group.
The embodiments can be obtained on the basis of the first two embodiments, and will be briefly described by way of example.
For example, if the data table name of the first object group is 1 and the data table name of the second object group is 2, the relationship group whose data table name is (1, 2) may be determined as the target relationship group.
If the object identifier includes a plurality of pairs of source object identifiers and destination object identifiers, the scheme shown in this embodiment may be executed for each pair of source object identifiers and destination object identifiers, and only the first object group and the second object group need to be determined as the object groups corresponding to the source object identifier and the destination object identifier, respectively.
The target relation group comprises the object relation between the first object characterized by the source object identification and the first object characterized by the target object identification, because the target relation group comprises the object relation of the first object characterized by the source object identification and the second object group, and because the first object characterized by the source object identification belongs to the first object group and the first object characterized by the target object identification belongs to the second object group.
In summary, in the case that the obtained object identifier includes the source object identifier and the destination object identifier, after the above-mentioned target relationship group is obtained, the object relationship between the first object represented by the source object identifier and the first object represented by the destination object identifier may be accurately queried from the target relationship group.
The following describes a case where the object group, the relationship group, and the correspondence between the object group and its association relationship group are stored in the relationship database.
In this case, a target association group corresponding to the determined target object group may be obtained based on the correspondence between the object group stored in the relational database and its association group, and then the target association group may be determined as the target association group.
The object relationship contained in the target association relationship group is associated with the object contained in the target object group.
In this way, the target association relation group can be determined directly according to the stored object group, the relation group and the corresponding relation between the object group and the association relation group.
Because the target association relation group contains the association relation associated with the object contained in the target object group and the first object belongs to the target object group, the target association relation group contains the association relation associated with the first object, and the target association relation group is further directly determined as the target association relation group, so that the object relation of the first object can be conveniently and accurately inquired from the target association relation group.
Step S604: the object relationships that match the data query request and are directed to the first object are queried in the target relationship group.
In combination with the foregoing steps, if the obtained object identifier includes the source object identifier and does not include the destination object identifier, then in the determined target relationship group, the object relationship of the first object, which is matched with the data query request and is characterized by the source object identifier, may be queried. The other cases of the obtained object identification are the same and are not described in detail here.
From the above, when the scheme provided by the embodiment of the present disclosure is applied to perform data query, after the object identifier included in the data query request is resolved, a target object group to which the first object represented by the obtained object identifier belongs may be determined, and then, based on the determined target object group, a target relationship group is determined from the relationship groups, and finally, the object relationship which is matched with the data query request and is specific to the first object may be queried in the target relationship group.
When data inquiry is carried out, the object relation of the first object is inquired in the target relation group determined according to the target object group instead of inquiring the object relation of the first object in the whole relation group. Compared with the query of the object relationship from all the relationship groups, the query range is reduced, and the query efficiency in the data query is improved.
Corresponding to the data storage method, the embodiment of the disclosure also provides a data storage device.
Referring to fig. 7, a schematic structural diagram of a data storage device according to an embodiment of the present disclosure is provided, where the device includes the following modules 701-703.
An object group determining module 701, configured to determine an object group to which an object recorded in the graph data belongs;
a relationship group determining module 702, configured to determine, based on an object group to which an object having an object relationship belongs, a relationship group to which an object relationship recorded in the graph data belongs;
the grouping storage module 703 is configured to store the obtained object groupings and the relationship groupings in a relational database.
From the above, when the scheme provided by the embodiment of the present disclosure is applied to data storage, the object group to which the object recorded in the graph data belongs is determined, and then the relationship group to which the object relationship recorded in the graph data belongs is determined based on the object group to which the object having the object relationship belongs, so that the obtained object group and the relationship group can be stored in the relationship database, and the storage of the graph data is successfully realized. Compared with the storage of the graph data in the graph database, the scheme provided by the embodiment of the disclosure can directly store the graph data in the relational database with smaller consumption of storage resources, so that the consumption of the storage resources is reduced.
In addition, because the scheme provided by the embodiment of the disclosure can realize that the graph data is stored in the relational database, when the downstream task is carried out, staff can directly process the graph data in the relational database by using the query language of the relational database without processing the graph data in the graph database by using the query language of the graph database, and further, the query languages of various graph databases are not required to be learned, so that the learning cost of the staff is reduced.
In addition, when determining the relationship group of the object relationship recorded in the graph data, the scheme provided by the embodiment of the disclosure is determined based on the object group of the object having the object relationship, so that the relationship group of the object relationship is associated with the object group of the object, and when carrying out data query based on the stored graph data, the target relationship group associated with the object group of the object to be queried can be determined from the relationship group, and then the object relationship of the object to be queried is queried from the target relationship group. Compared with the query of the object relationship from all the relationship groups, the query range is reduced, and the query efficiency in the data query is improved.
In one embodiment of the present disclosure, the source objects of the object relationships in the same relationship group belong to the same object group.
In this case, since one relationship group includes the object relationships of the source objects belonging to the same object group, when there is a query request for a source object belonging to a certain object group, the relationship group of the source object belonging to the object group of the included object relationship can be determined, and the object relationship of the source object can be conveniently queried from the determined relationship group, so that the efficiency in data query can be improved compared with the query of the object relationship from all the relationship groups.
In one embodiment of the present disclosure, the destination objects of the object relationships in the same relationship group belong to the same object group.
In this case, since one relationship group includes the object relationships of the target objects belonging to the same object group, when there is a query request for a target object belonging to a certain object group, the relationship group of the target object belonging to the target group of the included object relationship can be determined, and the target object relationship can be conveniently queried from the determined relationship group, so that the efficiency in data query can be improved compared with the case of querying the target relationships from all the relationship groups.
In one embodiment of the present disclosure, source objects of object relationships in the same relationship group belong to the same object group and destination objects of object relationships in the same relationship group belong to the same object group.
In this case, since one relationship group includes the object relationships in which the source objects belong to the same object group and the destination objects belong to the same group, when there is a query request for a source object belonging to a certain object group and a destination object belonging to a certain object group, the relationship groups in which the source object and the destination object of the included object relationships belong to the object groups can be determined, and further, the object relationships between the source object and the destination object can be conveniently queried from the determined relationship groups, and the efficiency in data query can be improved as compared with the case of querying the object relationships from all the relationship groups.
In one embodiment of the present disclosure, the object grouping determining module 701 is specifically configured to determine the target number of object groupings based on at least one of the total resource amount of the device, the number of objects recorded in the graph data, the number of expected groupings, and the number of expected grouping members; and creating the target number of object groups, and determining the object groups to which the objects recorded in the graph data belong from the created object groups.
From the above, when the scheme provided by the embodiment of the present disclosure is applied to determine the group to which the object recorded in the graph data belongs, the target number of the object groups may be determined according to the total resource amount of the device, the number of the objects recorded in the graph data, the number of the expected groups, the number of the expected group members, and other various information, then the target number of the object groups may be created, and the object group to which the object recorded in the graph data belongs may be determined from the created object groups. Therefore, the number of the object groups can be determined according to various information such as the total resource amount of the equipment, the determined number of the object groups is more matched with the actual situation, and the flexibility and the reliability of the scheme are improved.
In one embodiment of the present disclosure, the object group determining module 701 is specifically configured to determine an object group that includes an object whose number of objects in the existing object group is not greater than the number of expected group members, and select, from the determined object groups, an object group to which an object recorded in the graph data belongs.
When the number of the objects contained in the object group is not greater than the number of the expected group members, the object group is indicated to have member vacancies, so that in this case, the object group with the member vacancies can be determined as the group to which the object belongs, and thus, the object group to which the object belongs can be reasonably selected according to the member vacancies of the object group.
In one embodiment of the present disclosure, the object group determining module 701 is specifically configured to create a new object group, and determine the new object group as an object group to which an object recorded in the graph data belongs, where the number of objects included in each existing object group is not less than the number of expected group members.
In this case, a new group may be created in a case where the number of objects included in each existing object group is not less than the number of expected group members, and the new group may be determined as the group to which the object belongs. Therefore, by creating a new group when no spare object group exists, the number of the members of the object group can be effectively prevented from exceeding the expectations, and the rationality and the stability of the scheme are improved.
In one embodiment of the disclosure, the packet storage module 703 is specifically configured to determine, for each obtained object packet, a correspondence between the object packet and an association packet thereof, where an object relationship included in the association packet is associated with an object included in the object packet; the resulting object groupings, relationship groupings, and the determined correspondence are stored in the relationship data.
Therefore, when the embodiment is executed, not only the object group and the relation group are stored in the object relation database, but also the corresponding relation between each object group and the relation group thereof is stored, so that when the data query is carried out subsequently, the relation group of the object group can be determined according to the object group to which the object to be queried belongs and the corresponding relation, and further the object relation of the object to be queried can be directly queried in the relation group, and the query efficiency in the data query is improved.
Corresponding to the data query method, the embodiment of the disclosure also provides a data query device.
Referring to fig. 8, a schematic structural diagram of a data query device according to an embodiment of the disclosure is provided, where the device includes the following modules 801 to 804.
An object identifier obtaining module 801, configured to respond to a data query request, and parse the data query request to obtain an object identifier;
a target object group determining module 802, configured to determine, from object groups stored in the relational database, a target object group to which the first object represented by the obtained object identifier belongs;
a target relationship group determination module 803 for determining a target relationship group from relationship groups stored in the relational database based on the determined target object group;
A query module 804, configured to query the target relationship group for an object relationship that matches the data query request and is specific to the first object.
From the above, when the scheme provided by the embodiment of the present disclosure is applied to perform data query, after the object identifier included in the data query request is resolved, a target object group to which the first object represented by the obtained object identifier belongs may be determined, and then, based on the determined target object group, a target relationship group is determined from the relationship groups, and finally, the object relationship which is matched with the data query request and is specific to the first object may be queried in the target relationship group.
When data inquiry is carried out, the object relation of the first object is inquired in the target relation group determined according to the target object group instead of inquiring the object relation of the first object in the whole relation group. Compared with the query of the object relationship from all the relationship groups, the query range is reduced, and the query efficiency in the data query is improved.
In one embodiment of the present disclosure, the target relationship group determining module 803 is specifically configured to determine, from relationship groups stored in the relational database, that a source object of the object relationship included in the target relationship group belongs to the target relationship group if the obtained object identifier includes a source object identifier and does not include a destination object identifier.
The target relation group comprises the object relation of the first object because the source object belongs to the target object group and the first object characterized by the source identifier belongs to the target object group. In summary, in the case that the obtained object identifier includes the source object identifier and does not include the destination object identifier, after the above-mentioned target relationship group is obtained, the object relationship of the first object represented by the source identifier may be accurately queried from the target relationship group.
In one embodiment of the present disclosure, the target relationship group determining module 803 is specifically configured to determine, from the relationship groups, that the target object of the object relationship included belongs to the target relationship group of the target relationship group if the obtained object identifier includes the target object identifier and does not include the source object identifier.
The target relation group comprises the object relation of the target object belonging to the target object group, and the first object characterized by the target identifier belongs to the target object group, so that the target relation group comprises the object relation of the first object. In summary, in the case that the obtained object identifier includes the destination object identifier and does not include the source object identifier, after the above-mentioned target relationship group is obtained, the object relationship of the first object represented by the destination identifier may be accurately queried from the target relationship group.
In one embodiment of the present disclosure, the target relationship group determining module 803 is specifically configured to determine, from the relationship groups, a target relationship group including a source object belonging to a first object group and a destination object belonging to a second object group, if the obtained object identifier includes the source object identifier and the destination object identifier, where the first object group is: the source object identification characterizes a target object group to which the object belongs, and the second object group is: the destination identifier characterizes a target object group to which the object belongs.
The target relation group comprises the object relation between the first object characterized by the source object identification and the first object characterized by the target object identification, because the target relation group comprises the object relation of the first object characterized by the source object identification and the second object group, and because the first object characterized by the source object identification belongs to the first object group and the first object characterized by the target object identification belongs to the second object group.
In summary, in the case that the obtained object identifier includes the source object identifier and the destination object identifier, after the above-mentioned target relationship group is obtained, the object relationship between the first object represented by the source object identifier and the first object represented by the destination object identifier may be accurately queried from the target relationship group.
In one embodiment of the present disclosure, the target relationship group determining module 803 is specifically configured to obtain a target relationship group corresponding to the determined target relationship group based on a corresponding relationship between an object group stored in the relational database and an association relationship group thereof, where an object relationship included in the target relationship group is associated with an object included in the target object group; and determining the target association relation group as a target relation group.
Because the target association relation group contains the association relation associated with the object contained in the target object group and the first object belongs to the target object group, the target association relation group contains the association relation associated with the first object, and the target association relation group is further directly determined as the target association relation group, so that the object relation of the first object can be conveniently and accurately inquired from the target association relation group.
In the technical scheme of the disclosure, the related processes of collecting, storing, using, processing, transmitting, providing, disclosing and the like of the personal information of the user accord with the regulations of related laws and regulations, and the public order colloquial is not violated.
According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
In one embodiment of the present disclosure, there is provided an electronic device including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the data storage method or the data query method described above.
In one embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute the above-described data storage method or data query method is provided.
In one embodiment of the present disclosure, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the above-described data storage method or data query method.
Fig. 9 shows a schematic block diagram of an example electronic device 900 that may be used to implement embodiments of the present disclosure. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 9, the apparatus 900 includes a computing unit 901 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 902 or a computer program loaded from a storage unit 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other by a bus 904. An input/output (I/O) interface 905 is also connected to the bus 904.
Various components in device 900 are connected to I/O interface 905, including: an input unit 906 such as a keyboard, a mouse, or the like; an output unit 907 such as various types of displays, speakers, and the like; a storage unit 908 such as a magnetic disk, an optical disk, or the like; and a communication unit 909 such as a network card, modem, wireless communication transceiver, or the like. The communication unit 909 allows the device 900 to exchange information/data with other devices through a computer network such as the internet and/or various telecommunications networks.
The computing unit 901 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 901 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 901 performs the respective methods and processes described above, such as the data storage method or the data query method described above. For example, in some embodiments, the data storage methods or data querying methods described above may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as the storage unit 908. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 900 via the ROM 902 and/or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the above-described data storage method or data query method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform the data storage method or the data query method described above in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), and the internet.
The computer system may include a client and a server. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel, sequentially, or in a different order, provided that the desired results of the disclosed aspects are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (19)

1. A data storage method, comprising:
determining an object group to which an object recorded in the graph data belongs;
determining a relation group of the object relation recorded in the graph data based on the object group of the object with the object relation;
the resulting object groupings and relationship groupings are stored in a relational database.
2. The method of claim 1, wherein,
the source objects of the object relationships in the same relationship group belong to the same object group; and/or
The target objects of the object relationships in the same relationship group belong to the same object group.
3. The method according to claim 1 or 2, wherein the determining an object group to which the object recorded in the graph data belongs comprises:
determining a target number of object groups based on at least one of a total resource amount of the device, a number of objects recorded in the graph data, a number of expected groups, and a number of expected group members;
and creating the target number of object groups, and determining the object groups to which the objects recorded in the graph data belong from the created object groups.
4. The method according to claim 1 or 2, wherein the determining an object group to which the object recorded in the graph data belongs comprises:
determining an object group with the number of objects contained in the existing object group not greater than the number of expected group members, and selecting an object group to which the object recorded in the graph data belongs from the determined object group;
or (b)
And under the condition that the number of objects contained in each existing object group is not less than the number of expected group members, creating a new object group, and determining the new object group as the object group to which the objects recorded in the graph data belong.
5. The method of claim 1 or 2, wherein the storing the resulting object groupings and relationship groupings in a relational database comprises:
for each obtained object group, determining a corresponding relation between the object group and an association relation group thereof, wherein the object relation contained in the association relation group is associated with the object contained in the object group;
the resulting object groupings, relationship groupings, and the determined correspondence are stored in the relationship data.
6. A data query method, comprising:
responding to a data query request, and analyzing the data query request to obtain an object identifier;
determining a target object group to which a first object represented by the obtained object identifier belongs from object groups stored in a relational database;
determining a target relationship group from relationship groups stored in the relationship database based on the determined target object group;
and querying the object relation which is matched with the data query request and is specific to the first object in the target relation group.
7. The method of claim 6, wherein the determining a target relationship group from relationship groups stored within the relational database based on the determined target object group comprises:
If the obtained object identifier comprises a source object identifier and does not comprise a target object identifier, determining that a source object of the contained object relationship belongs to a target relationship group of the target object group from relationship groups stored in the relationship database;
or (b)
If the obtained object identifier comprises a target object identifier and does not comprise a source object identifier, determining a target relation group of a target object of the contained object relation belonging to the target object group from the relation group;
or (b)
If the obtained object identifier includes a source object identifier and a destination object identifier, determining, from the relationship group, that a source object of the contained object relationship belongs to a first object group and a destination object belongs to a target relationship group of a second object group, where the first object group is: the source object identification characterizes a target object group to which the object belongs, and the second object group is: the destination identifier characterizes a target object group to which the object belongs.
8. The method of claim 6, wherein the determining a target relationship group from relationship groups stored within the relational database based on the determined target object group comprises:
Obtaining a target association relation group corresponding to the determined target object group based on the corresponding relation between the object group stored in the relation database and the association relation group, wherein the object relation contained in the target association relation group is associated with the object contained in the target object group;
and determining the target association relation group as a target relation group.
9. A data storage device, comprising:
the object grouping determining module is used for determining an object grouping to which an object recorded in the graph data belongs;
a relationship group determining module, configured to determine, based on an object group to which an object having an object relationship belongs, a relationship group to which an object relationship recorded in the graph data belongs;
and the grouping storage module is used for storing the obtained object grouping and the relation grouping in the relation type database.
10. The apparatus of claim 9, wherein,
the source objects of the object relationships in the same relationship group belong to the same object group; and/or
The target objects of the object relationships in the same relationship group belong to the same object group.
11. The device according to claim 9 or 10, wherein,
the object grouping determining module is specifically configured to determine a target number of object groupings based on at least one of a total resource amount of the device, a number of objects recorded in the graph data, a number of expected groupings, and a number of expected grouping members; and creating the target number of object groups, and determining the object groups to which the objects recorded in the graph data belong from the created object groups.
12. The device according to claim 9 or 10, wherein,
the object grouping determining module is specifically configured to determine an object grouping, where the number of objects included in the existing object grouping is not greater than the number of expected grouping members, and select, from the determined object groupings, an object grouping to which an object recorded in the graph data belongs; or under the condition that the number of the objects contained in each existing object group is not less than the number of the expected group members, creating a new object group, and determining the new object group as the object group to which the objects recorded in the graph data belong.
13. The device according to claim 9 or 10, wherein,
the grouping storage module is specifically configured to determine, for each obtained object grouping, a correspondence between the object grouping and an association relationship grouping thereof, where an object relationship included in the association relationship grouping is associated with an object included in the object grouping; the resulting object groupings, relationship groupings, and the determined correspondence are stored in the relationship data.
14. A data query device, comprising:
the object identification obtaining module is used for responding to the data query request and analyzing the data query request to obtain an object identification;
The target object grouping determining module is used for determining a target object grouping to which the first object represented by the obtained object identifier belongs from object groupings stored in the relational database;
a target relationship group determination module for determining a target relationship group from relationship groups stored in the relational database based on the determined target object group;
and the query module is used for querying the object relation which is matched with the data query request and is specific to the first object in the target relation group.
15. The apparatus of claim 14, wherein,
the target relation group determining module is specifically configured to determine, from relation groups stored in the relational database, that a source object of an included object relation belongs to a target relation group of the target object group if the obtained object identifier includes a source object identifier and does not include a destination object identifier; or if the obtained object identifier comprises a target object identifier and does not comprise a source object identifier, determining a target relation group of a target object of the contained object relation belonging to the target object group from the relation group; or if the obtained object identifier comprises a source object identifier and a destination object identifier, determining a target relation group of which the source object belongs to a first object group and the destination object belongs to a second object group of the contained object relation from the relation group, wherein the first object group is as follows: the source object identification characterizes a target object group to which the object belongs, and the second object group is: the destination identifier characterizes a target object group to which the object belongs.
16. The apparatus of claim 14, wherein,
the target relation group determining module is specifically configured to obtain a target relation group corresponding to the determined target relation group based on a corresponding relation between the object group stored in the relation database and the relation group, where the object relation contained in the target relation group is associated with an object contained in the target object group; and determining the target association relation group as a target relation group.
17. An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-5 or 6-8.
18. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-5 or 6-8.
19. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-5 or 6-8.
CN202310228228.5A 2023-03-10 2023-03-10 Data storage and data query method and device, electronic equipment and medium Pending CN116204559A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310228228.5A CN116204559A (en) 2023-03-10 2023-03-10 Data storage and data query method and device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310228228.5A CN116204559A (en) 2023-03-10 2023-03-10 Data storage and data query method and device, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN116204559A true CN116204559A (en) 2023-06-02

Family

ID=86509352

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310228228.5A Pending CN116204559A (en) 2023-03-10 2023-03-10 Data storage and data query method and device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN116204559A (en)

Similar Documents

Publication Publication Date Title
CN113342345A (en) Operator fusion method and device of deep learning framework
CN112866391A (en) Message pushing method and device, electronic equipment and storage medium
CN113051446A (en) Topological relation query method, device, electronic equipment and medium
CN116955361A (en) Method and system for searching key range in memory
CN112559631A (en) Data processing method and device of distributed graph database and electronic equipment
CN113312539B (en) Method, device, equipment and medium for providing search service
EP3822818A1 (en) Method, apparatus, device and storage medium for intelligent response
CN115905322A (en) Service processing method and device, electronic equipment and storage medium
CN116204559A (en) Data storage and data query method and device, electronic equipment and medium
CN113239054B (en) Information generation method and related device
CN113900731B (en) Request processing method, device, equipment and storage medium
CN115328917A (en) Query method, device, equipment and storage medium
CN114969444A (en) Data processing method and device, electronic equipment and storage medium
CN111680508B (en) Text processing method and device
CN114116924A (en) Data query method based on map data, map data construction method and device
CN114357180A (en) Knowledge graph updating method and electronic equipment
CN114048863A (en) Data processing method, data processing device, electronic equipment and storage medium
CN113393288A (en) Order processing information generation method, device, equipment and computer readable medium
CN113778645A (en) Task scheduling method, device and equipment based on edge calculation and storage medium
CN111737593A (en) Method, device, equipment and storage medium for acquiring cross-group communication relationship diagram
US20230061914A1 (en) Rule based machine learning for precise fraud detection
CN112817990B (en) Data processing method, device, electronic equipment and readable storage medium
CN117390061A (en) Information query method and device, electronic equipment and storage medium
CN114359610B (en) Entity classification method, device, equipment and storage medium
CN113032402B (en) Method, device, equipment and storage medium for storing data and acquiring data

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination