A method, device, equipment and storage medium for storing associated data
By constructing node information tables and sample association information tables in the database, and optimizing the storage and reading process using the attribute identification set, the problems of large storage space and low reading efficiency of data tables are solved, and efficient associated data storage and reading are achieved.
Patent Information
- Application Number
- CN202210750490.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-28
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-06-28
AI Technical Summary
When storing the associated data corresponding to sample data, the data table occupies a large storage space and low data reading efficiency, especially when reading a character string containing a longer associated data identification.
By obtaining the node attributes of each data node in the target database, determining the attribute identification according to the preset numerical interval, building a node information table, and obtaining the attribute identification set based on the associated node attributes of the sample, building a sample association information table, reducing storage space and improving reading efficiency.
It effectively reduces the storage space of data tables, improves the reading efficiency of associated data, and avoids the time-consuming data reading caused by long strings.
Smart Images

Figure CN115098506B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, apparatus, device and storage medium for storing associated data. Background Art
[0002] With the development of computer technology, databases have been widely used to store sample data and multiple associated data corresponding to the sample data.
[0003] In the prior art, there are two common approaches to storing associated data corresponding to sample data. The first approach is to record each associated data identifier corresponding to each sample identifier in a data table, similar to logging data. Multiple associated data items may exist for the same sample identifier. The second approach is to combine multiple associated data identifiers corresponding to each sample using a pre-defined delimiter. For a given sample identifier, a single, long string of characters represents all associated data identifiers.
[0004] However, the data table in the first method occupies a large storage space, and the data reading efficiency is low due to too many data items. In the second method, when reading data, the character string representing all associated data identifiers needs to be split. Since the character string is long, the data reading also takes a long time and the reading efficiency is low. Summary of the Invention
[0005] The present invention provides a storage method, device, equipment and storage medium for associated data, which can reduce the storage space of a data table and improve the reading efficiency of associated data.
[0006] According to one aspect of the present invention, a method for storing associated data is provided, comprising:
[0007] Obtain each data node and multiple node attributes corresponding to each data node in the target database, and determine attribute identifiers corresponding to each node attribute for each data node according to a preset value range;
[0008] Constructing a node information table corresponding to each of the data nodes according to a plurality of node attributes corresponding to each of the data nodes and an attribute identifier corresponding to each of the node attributes;
[0009] According to the associated node attributes corresponding to each sample in the target database and each node information table, the attribute identification set corresponding to each sample under different associated nodes is obtained;
[0010] A sample association information table is constructed based on the attribute identification set corresponding to each sample under different association nodes and the sample identification of each sample.
[0011] According to another aspect of the present invention, there is provided a storage device for associated data, the device comprising:
[0012] The attribute identifier determination module is used to obtain each data node and multiple node attributes corresponding to each data node in the target database, and determine the attribute identifier corresponding to each node attribute for each data node according to a preset numerical range;
[0013] A node information table construction module is used to construct a node information table corresponding to each data node according to a plurality of node attributes corresponding to each data node and an attribute identifier corresponding to each node attribute;
[0014] An identification set acquisition module is used to obtain the attribute identification set corresponding to each sample under different associated nodes based on the associated node attributes corresponding to each sample in the target database and each node information table;
[0015] The association information table construction module is used to construct a sample association information table according to the attribute identification set corresponding to each sample under different association nodes and the sample identification of each sample.
[0016] According to another aspect of the present invention, an electronic device is provided, comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor so that the at least one processor can perform the method for storing associated data according to any embodiment of the present invention.
[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for storing associated data according to any embodiment of the present invention when executed.
[0021] The technical solution provided by the embodiment of the present invention obtains each data node and multiple node attributes corresponding to each data node in the target database, determines the attribute identifier corresponding to each node attribute for each data node according to a preset numerical range, constructs a node information table corresponding to each data node according to the multiple node attributes corresponding to each data node and the attribute identifier corresponding to each node attribute, obtains the attribute identifier set corresponding to each sample under different associated nodes according to the associated node attributes corresponding to each sample in the target database and each node information table, and constructs the sample associated information table according to the attribute identifier set corresponding to each sample under different associated nodes and the sample identifier of each sample. This technical means can reduce the storage space of the data table and improve the reading efficiency of the associated data.
[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0024] Figure 1 is a flowchart of a method for storing associated data provided according to an embodiment of the present invention;
[0025] Figure 2 is a flowchart of another method for storing associated data provided by an embodiment of the present invention;
[0026] Figure 3 is a flowchart of another method for storing associated data provided by an embodiment of the present invention;
[0027] Figure 4 1 is a schematic structural diagram of a storage device for associated data provided according to an embodiment of the present invention;
[0028] Figure 5 It is a structural diagram of an electronic device that implements the method for storing associated data according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] Figure 1 This is a flowchart of a method for storing associated data provided by the first embodiment of the present invention. This embodiment is applicable to the case of storing sample associated data in a database. The method can be executed by a storage device for associated data. The storage device for associated data can be implemented in the form of hardware and / or software. The storage device for associated data can be configured in an electronic device with data processing capabilities (such as a terminal or server). Figure 1 As shown, the method includes:
[0032] Step 110: Obtain each data node and multiple node attributes corresponding to each data node in the target database, and determine attribute identifiers corresponding to each node attribute for each data node according to a preset numerical range.
[0033] In this embodiment, the target database may be a database for storing sample data and sample-related data. The data node may be understood as a data storage module in the target database, used to store user-entered data tables and data. Specifically, the data node may be a sample attribute. For example, if the sample is a person, the data node may be a specific person attribute, such as hobbies, awards, etc.
[0034] In a specific embodiment, each data node may correspond to multiple node attributes. For example, if the data node is a hobby, the corresponding node attributes may include swimming, painting, watching movies, reading, and singing. For example, if the data node is an award, the corresponding node attributes may include academic awards, competition awards, sports awards, and photography awards.
[0035] After obtaining multiple node attributes corresponding to each data node, attribute identifiers corresponding to each node attribute may be determined for each data node according to a fixed numerical range.
[0036] In this step, taking a data node as an example, assuming that the preset numerical range includes m (m>0) integers, each integer can be used in turn as an attribute identifier corresponding to each node attribute in the data node.
[0037] Step 120: Construct a node information table corresponding to each of the data nodes according to the plurality of node attributes corresponding to each of the data nodes and the attribute identifier corresponding to each of the node attributes.
[0038] In this step, a node information table corresponding to each data node may be constructed according to the mapping relationship between the node attributes and the attribute identifiers in each data node.
[0039] In a specific embodiment, taking a data node as an example, the node information table corresponding to the data node may be as shown in Table 1:
[0040] Table 1
[0041] Property ID Node properties 1 Attribute A 2 Attribute B 3 Attribute C …… Attribute L m Attribute M
[0042] As shown in Table 1, the node information table corresponding to the data node stores each node attribute and the corresponding attribute identifier (ie, attribute ID).
[0043] Step 130: According to the associated node attributes corresponding to each sample in the target database and each node information table, obtain the attribute identification set corresponding to each sample under different associated nodes.
[0044] In this step, the associated node attributes corresponding to each sample can be determined based on the associated data corresponding to each sample. For example, if the sample is a person who likes watching a certain type of movie, reading books by a certain author, and has won a writing award and a first prize in photography, the associated nodes corresponding to this person can be determined to be "Hobbies" and "Awards," and the corresponding associated node attributes can be "Watching Movies," "Reading," "Academic Awards," and "Photography Awards."
[0045] In this embodiment, taking a sample as an example, after obtaining the associated node attributes corresponding to the sample, the attribute identifiers corresponding to each associated node attribute (i.e., associated node attribute identifiers) can be obtained from the aforementioned node information tables. Multiple associated node attribute identifiers corresponding to the sample under a specific associated node are combined to obtain the attribute identifier set corresponding to the sample under that associated node. Using the same method, the attribute identifier sets corresponding to different associated nodes can be obtained for the sample.
[0046] In a specific embodiment, assuming that the sample is a person, the associated node attributes corresponding to the person are "watching movies", "reading", "academic awards" and "photography awards", assuming that the attribute identifier corresponding to "watching movies" is "a" and the attribute identifier corresponding to "reading" is "b", then it can be determined that the attribute identifier set of the person under the associated node "hobbies" is "a&b"; assuming that the attribute identifier corresponding to "academic awards" is "c" and the attribute identifier corresponding to "photography awards" is "d", then it can be determined that the attribute identifier set of the person under the associated node "awards" is "c&d".
[0047] Therefore, the attribute identification set corresponding to each sample under different associated nodes can be obtained through the above method.
[0048] Step 140: Construct a sample association information table based on the attribute identification sets corresponding to each sample under different association nodes and the sample identification of each sample.
[0049] In this embodiment, a sample association information table may be constructed based on the mapping relationship between each sample identifier, each associated node, and the attribute identifier set corresponding to the sample under the associated node, as shown in Table 2:
[0050] Table 2
[0051] Sample ID Associated Node A Associated Node B 1 <![CDATA[X1]]> <![CDATA[X2]]> 2 <![CDATA[Y1]]> <![CDATA[Y2]]> …… …… ……
[0052] In Table 2, two association nodes are taken as an example. X1 represents the attribute identification set corresponding to sample 1 under association node A, X2 represents the attribute identification set corresponding to sample 1 under association node B, Y1 represents the attribute identification set corresponding to sample 2 under association node A, and Y2 represents the attribute identification set corresponding to sample 2 under association node B.
[0053] In a specific embodiment, after the associated data is stored in the above manner, if a user's associated data query request for a certain sample is received, the attribute identification sets corresponding to the sample can be obtained in the above sample associated information table, and then the attribute identification sets can be split to obtain multiple node attribute identifications. Finally, the node attribute information corresponding to each node attribute identification is obtained according to the above node information table, and this node attribute information is fed back to the user as result data.
[0054] In this embodiment, there is no need to record the associated data identifier corresponding to each sample identifier one by one. By constructing a node information table and a sample association information table, the storage space occupied by the data table can be reduced; secondly, by limiting the identifier of the node attribute according to a preset numerical range, the problem of complex character strings in the attribute identifier concentration, which leads to a long time spent on data reading, can be avoided.
[0055] The technical solution provided by the embodiment of the present invention obtains each data node and multiple node attributes corresponding to each data node in the target database, determines the attribute identifier corresponding to each node attribute for each data node according to a preset numerical range, constructs a node information table corresponding to each data node according to the multiple node attributes corresponding to each data node and the attribute identifier corresponding to each node attribute, obtains the attribute identifier set corresponding to each sample under different associated nodes according to the associated node attributes corresponding to each sample in the target database and each node information table, and constructs the sample associated information table according to the attribute identifier set corresponding to each sample under different associated nodes and the sample identifier of each sample. This technical means can reduce the storage space of the data table and improve the reading efficiency of the associated data.
[0056] Figure 2 This is a flowchart of a method for storing associated data provided by the second embodiment of the present invention. This embodiment is a further refinement of the above embodiment. Figure 2 As shown, the method includes:
[0057] Step 201: Obtain each data node and multiple node attributes corresponding to each data node in a target database.
[0058] Step 202: According to the integer data value range corresponding to the target database, determine multiple integer powers of 2 that meet the value range.
[0059] In a specific embodiment, assuming that the integer data value range of the target database is -2^31-2^30, 31 positive integer powers of 2 can be taken in the range, such as 2^0, 2^1, 2^2...2^30 (1073741824).
[0060] Step 203: Arrange the multiple integer powers of 2, and use the integer powers of 2 as attribute identifiers corresponding to the attributes of each node in each data node according to the arrangement results.
[0061] In this step, optionally, multiple integer powers of 2 may be arranged in ascending order, and each integer power of 2 may be used as an attribute identifier corresponding to each node attribute in each data node according to the arrangement result.
[0062] Step 204: Construct a node information table corresponding to each of the data nodes according to the multiple node attributes corresponding to each of the data nodes and the attribute identifier corresponding to each of the node attributes.
[0063] In a specific embodiment, taking the data node "hobbies" as an example, the node information table corresponding to the data node may be as shown in Table 3:
[0064] Table 3
[0065]
[0066]
[0067] As shown in Table 3, the attribute identifier of each node attribute may be a corresponding integer power of 2.
[0068] Step 205: According to the associated node attributes corresponding to each sample in the target database and the attribute identifiers of each associated node attribute in the node information table, obtain the sum of the integer powers of 2 corresponding to each sample under different associated nodes, and use the sum of the integer powers of 2 as the attribute identifier set.
[0069] In this embodiment, taking a sample as an example, after obtaining the associated node attributes corresponding to the sample, the attribute identifiers corresponding to each associated node attribute can be obtained from the aforementioned node information table. The multiple associated node attribute identifiers corresponding to the sample under a specific associated node are then summed to obtain the integer power of 2 sum corresponding to the sample under that associated node. The sum of the integer powers of 2 is then used as the attribute identifier set. Using the same method, the attribute identifier sets corresponding to different associated nodes of the sample can be obtained.
[0070] In a specific embodiment, assuming that the sample is a person, the associated node attributes corresponding to the person are "watching movies", "reading", "academic awards" and "photography awards", assuming that the attribute identification corresponding to "watching movies" is "4" and the attribute identification corresponding to "reading" is "8", then it can be determined that the attribute identification set of the person under the associated node "hobbies" is "12"; assuming that the attribute identification corresponding to "academic awards" is "16" and the attribute identification corresponding to "photography awards" is "64", then it can be determined that the attribute identification set of the person under the associated node "awards" is "80".
[0071] Therefore, the attribute identification set corresponding to each sample under different associated nodes can be obtained through the above method.
[0072] Step 206: Construct a sample association information table based on the attribute identification sets corresponding to each sample under different association nodes and the sample identification of each sample.
[0073] In a specific embodiment, taking the association nodes "Hobbies" and "Awards" as an example, assuming that the attribute identification set of person 1 under the association node "Hobbies" is "12" and the attribute identification set under the association node "Awards" is "80", and the attribute identification set of person 2 under the association node "Hobbies" is "30" and the attribute identification set under the association node "Awards" is "20", the constructed sample association information table can be shown in Table 4:
[0074] Table 4
[0075] Sample ID Hobbies Awards 1 12 80 2 30 20 …… …… ……
[0076] As shown in Table 4, the attribute identification set corresponding to each sample under different associated nodes may be the sum of integer powers of 2.
[0077] Step 207: After receiving the associated data query request, obtain the target sample identifier and the target associated node included in the associated data query request.
[0078] In this step, after receiving the associated data query request input by the user, the target sample identifier and target associated node can be extracted from the request based on the preset identifier. The target sample identifier can be the identifier corresponding to the sample that the user wants to query, and the target associated node can be the sample attribute that the user wants to query for the sample.
[0079] Step 208: Obtain a target attribute identifier set from the sample association information table according to the target sample identifier and the target association node.
[0080] In this step, the attribute identification set (ie, the target attribute identification set) corresponding to the target association node under the target sample identification can be obtained according to the sample association information table.
[0081] In a specific embodiment, assuming that the target sample identifier is 1 and the target associated node is “hobbies”, the target attribute identifier set can be determined to be 12 in Table 4.
[0082] Step 209: Split the target attribute identifier set into integer powers of 2.
[0083] In this step, when splitting the target attribute identifier set according to integer powers of 2, you can first calculate the maximum integer power of 2 corresponding to the target attribute identifier set, and then calculate the difference between the target attribute identifier set and the maximum integer power of 2. If the difference is greater than 0, continue to calculate the maximum integer power of 2 corresponding to the difference, and calculate the difference between the difference and the maximum integer power of 2 until the difference is equal to 0.
[0084] Step 210: Obtain a node information table corresponding to the target associated node, and obtain associated data corresponding to the query request in the node information table corresponding to the target associated node according to the splitting result of the target attribute identifier set.
[0085] In this step, after splitting the target attribute identifier set, multiple node attribute identifiers can be obtained, and then the node attribute information corresponding to each node attribute identifier is obtained according to the node information table, and this node attribute information is used as the associated data corresponding to the query request.
[0086] In a specific embodiment, assuming that the target sample identifier is 2 and the target associated node is "hobbies", the target attribute identifier set can be determined to be 30 in Table 4, and then the target attribute identifier set can be split into 16, 8, 4 and 2, and the corresponding node attributes obtained in Table 3 are "painting", "watching movies", "reading" and "singing" respectively.
[0087] In this embodiment, by using integer powers of 2 as attribute identifiers and the sum of integer powers of 2 as an attribute identifier set, the problem of too long character strings in the attribute identifier set, which leads to time-consuming data reading, can be avoided; secondly, due to the characteristic that any positive integer greater than zero can be split into a unique set containing the maximum power exponent of 2, by splitting the attribute identifier set according to integer powers of 2, the efficiency of character string splitting and the accuracy of the splitting results can be improved.
[0088] The technical solution provided by an embodiment of the present invention obtains each data node and multiple node attributes corresponding to each data node in a target database, determines multiple integer powers of 2 that fit within the value range of integer data corresponding to the target database, arranges the multiple integer powers of 2 and uses the integer powers of 2 as attribute identifiers corresponding to each node attribute according to the arrangement results, constructs a node information table based on the multiple node attributes corresponding to each data node and the attribute identifiers corresponding to each node attribute, obtains the sum of the integer powers of 2 corresponding to each sample at different associated nodes as an attribute identifier set based on the associated node attributes and attribute identifiers corresponding to each sample in the target database, constructs a sample association information table based on the attribute identifier sets corresponding to each sample at different associated nodes and the sample identifiers of each sample, obtains a target attribute identifier set from the sample association information table based on the target sample identifier and the target associated node after receiving an associated data query request, splits the target attribute identifier set according to the integer powers of 2, and obtains associated data from the node information table corresponding to the target associated node based on the split results of the target attribute identifier set. This technical solution can reduce the storage space of the data table and improve the reading efficiency of the associated data.
[0089] Figure 3This is a flowchart of a method for storing associated data provided by the third embodiment of the present invention. This embodiment is a further refinement of the above embodiment. Figure 3 As shown, the method includes:
[0090] Step 301: Obtain each data node and multiple node attributes corresponding to each data node in the target database.
[0091] Step 302: According to the integer data value range corresponding to the target database, determine multiple integer powers of 2 that meet the value range.
[0092] Step 303: Arrange the multiple integer powers of 2.
[0093] Step 304 : Determine whether the total number of node attributes in each of the data nodes is greater than or equal to the target number of the multiple integer powers of 2; if so, execute steps 305 - 307 ; otherwise, execute step 308 .
[0094] In this embodiment, the target number may be the total number of integer powers of 2. Assuming that the integer data value range of the target database is -2^31-2^30, 31 positive integer powers of 2 can be taken in the range, such as 2^0, 2^1, 2^2, ..., 2^30 (1073741824), that is, the target number is 31.
[0095] Step 305: Obtain a target number of node attributes from the multiple node attributes of the data node, and use integer powers of 2 as attribute identifiers corresponding to the node attributes according to the arrangement results.
[0096] In this embodiment, if the total number of node attributes in a data node exceeds the target number, a portion of the node attributes can be first extracted from the total number of node attributes. Specifically, the target number of node attributes can be sequentially obtained based on the number of times the node attributes are arranged, and each integer power of 2 is used as the attribute identifier corresponding to each node attribute.
[0097] Step 306: Count the number of remaining node attributes in the data node and determine whether the number is less than or equal to the target number. If so, execute step 307; if not, return to execute step 305 until the number of remaining node attributes in the data node is less than or equal to the target number.
[0098] Step 307: Obtain integer powers of 2 equal to the number in sequence according to the arrangement result, and use each integer power of 2 as an attribute identifier corresponding to each remaining node attribute.
[0099] Step 308: According to the arrangement result, the integer powers of 2 are used as attribute identifiers corresponding to the attributes of each node in each data node.
[0100] In this embodiment, if the total number of node attributes in a certain data node is greater than the target number, after extracting some node attributes from all node attributes, the number of remaining node attributes can be counted. If the number is less than or equal to the target number, integer powers of 2 equal to the number can be extracted again from all integer powers of 2, and each integer power of 2 can be used as the attribute identifier corresponding to each remaining node attribute; if the number is greater than the target number, part of the node attributes can be extracted again according to the target number from the remaining node attributes until the number of remaining node attributes is less than or equal to the target number.
[0101] Step 309: Determine the data item identifier corresponding to each node attribute according to the arrangement order of each attribute identifier in each data node and the number of occurrences of each attribute identifier.
[0102] In this step, if the same attribute identifier appears multiple times in the data node, the data item identifiers may be determined for each node attribute corresponding to the attribute identifier according to the order of appearance of the attribute identifier (ie, the arrangement order).
[0103] In a specific embodiment, assuming that in a certain data node, the attribute identifier "8" appears a total of 3 times, the corresponding node attribute for the first time is "attribute D", the corresponding node attribute for the second time is "attribute P", and the corresponding node attribute for the third time is "attribute Z", then according to the arrangement order of the attribute identifier "8", it can be determined that the data item identifier corresponding to "attribute D" is "1", the data item identifier corresponding to "attribute P" is "2", and the data item identifier corresponding to "attribute Z" is "3".
[0104] Step 310: Construct a node information table corresponding to each data node according to the plurality of node attributes corresponding to each data node, the attribute identifier corresponding to each node attribute, and the data item identifier.
[0105] In a specific embodiment, taking the data node "hobbies" as an example, the node information table corresponding to the data node may be as shown in Table 5:
[0106] Table 5
[0107] Property ID Data item ID Node properties 1 1 swim 2 1 painting 4 1 See a movie 8 1 read 16 1 Sing …… …… …… 1 2 travel 2 2 Playing ball 4 2 shop …… …… …… 1 3 Listen to music
[0108] As shown in Table 5, since the total number of node attributes in a data node is greater than the total number of integer powers of 2, the same attribute identifier can be assigned to multiple node attributes. When multiple node attributes correspond to the same attribute identifier, the data item identifier can be determined for each node attribute in sequence according to the order of the attribute identifiers.
[0109] Step 311: According to the associated node attributes corresponding to each sample in the target database and each node information table, obtain the attribute identifier set corresponding to different data item identifiers under different associated nodes of each sample.
[0110] In this step, taking an association node as an example, the attribute identification set corresponding to the sample under different data item IDs can be obtained based on the node information table corresponding to the association node. Taking Table 5 as an example, assuming that the association node attributes corresponding to the sample are "painting," "movie watching," "travel," "playing ball," and "listening to music," it can be determined that the attribute identification set corresponding to the sample when the data item ID is 1 is 6, the attribute identification set corresponding to the data item ID is 2, and the attribute identification set corresponding to the data item ID is 1.
[0111] Thus, the attribute identifier sets corresponding to different data item identifiers under different associated nodes of each sample can be obtained through the above method.
[0112] Step 312: Construct a sample association information table corresponding to each association node according to the attribute identifier set corresponding to different data item identifiers under different association nodes of each sample and the sample identifier of each sample.
[0113] In this step, optionally, taking the association node "hobbies" as an example, the sample association information table corresponding to the association node may be as shown in Table 6:
[0114] Table 6
[0115]
[0116] As shown in Table 6, the sample association information table stores the attribute identifier sets corresponding to different data item identifiers of each sample under a specific association node.
[0117] In this embodiment, the same method as above may be used to construct a sample association information table corresponding to each association node.
[0118] In a specific embodiment, after the associated data is stored in the above manner, if a user's associated data query request for a certain sample is received, the target sample identifier and the target associated node included in the associated data query request can be obtained. Assuming that the target sample identifier is 2 and the target associated node is "hobbies", the attribute identifier set corresponding to each data item ID corresponding to the sample can be obtained in the sample association information table (such as Table 6), such as 123, 118, 328...28, etc.
[0119] After obtaining the attribute identifier sets corresponding to the sample, each attribute identifier set can be split according to integer powers of 2 to obtain multiple attribute identifiers. Specifically: 123 = 64 + 32 + 16 + 8 + 2 + 1, 118 = 64 + 32 + 16 + 4 + 2, 328 = 256 + 64 + 8, ..., 28 = 16 + 8 + 4. Then, in the node information table (such as Table 5), the node attribute information corresponding to each attribute identifier under each data item ID is obtained as the associated data corresponding to the query request.
[0120] Specifically, taking the attribute identification set 123 of sample 2 when the data item ID is 1 as an example, the attribute identification set can be split into the following attribute identifications: 64, 32, 16, 8, 2 and 1. Then, the node attribute information corresponding to these attribute identifications when the data item ID is 1 can be obtained in Table 5, namely: swimming, painting, reading, singing...etc.
[0121] The technical solution provided by the embodiment of the present invention obtains each data node and multiple node attributes corresponding to each data node in the target database, determines multiple integer powers of 2 that meet the value range according to the integer data value range corresponding to the target database, arranges the multiple integer powers of 2, judges whether the total number of node attributes in each data node is greater than or equal to the target number, and if so, obtains the node attributes of the target number, and uses each integer power of 2 as the attribute identifier corresponding to each node attribute according to the arrangement result, counts the number of remaining node attributes to judge whether the number is less than or equal to the target number, and if so, obtains the integer power of 2 equal to the number according to the arrangement result, and uses each integer power of 2 as the attribute identifier corresponding to each node attribute. Power is used as the attribute identifier corresponding to each remaining node attribute respectively. According to the arrangement order of each attribute identifier in each data node and the number of occurrences of each attribute identifier, the data item identifier corresponding to each node attribute is determined, and a node information table corresponding to each data node is constructed. According to the associated node attributes corresponding to each sample in the target database and each node information table, the attribute identifier set corresponding to different data item identifiers of each sample under different associated nodes is obtained. According to the attribute identifier set corresponding to different data item identifiers of each sample under different associated nodes and the sample identifier of each sample, a technical means is used to construct a sample associated information table corresponding to each associated node respectively. This can reduce the storage space of the data table and improve the reading efficiency of the associated data.
[0122] Figure 4 A schematic diagram of a storage device for associated data provided in the fourth embodiment of the present invention is shown in FIG. Figure 4 As shown, the device includes: an attribute identifier determination module 410 , a node information table construction module 420 , an identifier set acquisition module 430 and an association information table construction module 440 .
[0123] The attribute identifier determination module 410 is used to obtain each data node and multiple node attributes corresponding to each data node in the target database, and determine the attribute identifier corresponding to each node attribute for each data node according to a preset numerical range;
[0124] The node information table construction module 420 is used to construct a node information table corresponding to each data node according to multiple node attributes corresponding to each data node and attribute identifiers corresponding to each node attribute;
[0125] The identification set acquisition module 430 is used to acquire the attribute identification set corresponding to each sample under different associated nodes based on the associated node attributes corresponding to each sample in the target database and each node information table;
[0126] The association information table construction module 440 is used to construct a sample association information table according to the attribute identification set corresponding to each sample under different association nodes and the sample identification of each sample.
[0127] The technical solution provided by the embodiment of the present invention obtains each data node and multiple node attributes corresponding to each data node in the target database, determines the attribute identifier corresponding to each node attribute for each data node according to a preset numerical range, constructs a node information table corresponding to each data node according to the multiple node attributes corresponding to each data node and the attribute identifier corresponding to each node attribute, obtains the attribute identifier set corresponding to each sample under different associated nodes according to the associated node attributes corresponding to each sample in the target database and each node information table, and constructs the sample associated information table according to the attribute identifier set corresponding to each sample under different associated nodes and the sample identifier of each sample. This technical means can reduce the storage space of the data table and improve the reading efficiency of the associated data.
[0128] Based on the above embodiment, the attribute identification determination module 410 includes:
[0129] an integer power determining unit, configured to determine, based on a value range of integer data corresponding to the target database, a plurality of integer powers of 2 that conform to the value range;
[0130] an integer power arrangement unit, configured to arrange the plurality of integer powers of 2, and use the integer powers of 2 as attribute identifiers corresponding to the attributes of each node in each data node according to the arrangement results;
[0131] an attribute quantity determination unit, configured to determine whether the total number of node attributes in each of the data nodes is greater than or equal to the target number of the plurality of integer powers of 2; if so, obtaining the target number of node attributes from the plurality of node attributes of the data nodes, and sequentially using the integer powers of 2 as attribute identifiers corresponding to the respective node attributes according to the arrangement result;
[0132] The remaining attribute quantity statistics unit is used to count the number of remaining node attributes in the data node and determine whether the number is less than or equal to the target number; if so, the integer powers of 2 equal to the number are obtained in sequence according to the arrangement result, and each integer power of 2 is used as the attribute identifier corresponding to each remaining node attribute.
[0133] The node information table construction module 420 includes:
[0134] a data item identifier determining unit, configured to determine the data item identifier corresponding to each of the node attributes according to the arrangement order of each of the attribute identifiers in each of the data nodes and the number of occurrences of each of the attribute identifiers;
[0135] The information table construction unit is used to construct a node information table corresponding to each data node according to multiple node attributes corresponding to each data node, attribute identifiers corresponding to each node attribute, and data item identifiers.
[0136] The identification set acquisition module 430 includes:
[0137] a summation result obtaining unit, configured to obtain, based on the associated node attributes corresponding to each sample in the target database and the attribute identifiers of each associated node attribute in the node information table, a summation result of integer powers of 2 corresponding to each sample at different associated nodes, and use the summation result of integer powers of 2 as an attribute identifier set;
[0138] The attribute identification set acquisition unit is used to acquire the attribute identification sets corresponding to different data item identifications of each sample under different associated nodes according to the associated node attributes corresponding to each sample in the target database and each node information table.
[0139] The association information table construction module 440 includes:
[0140] A query request receiving unit, configured to, after receiving a related data query request, obtain a target sample identifier and a target related node included in the related data query request;
[0141] a target identification set acquisition unit, configured to acquire a target attribute identification set in the sample association information table according to the target sample identification and the target association node;
[0142] An integer power splitting unit, configured to split the target attribute identifier set according to integer powers of 2;
[0143] an associated data acquisition unit, configured to acquire a node information table corresponding to the target associated node, and acquire associated data corresponding to the query request in the node information table corresponding to the target associated node according to the splitting result of the target attribute identifier set;
[0144] The sample association information table construction unit is used to construct a sample association information table corresponding to each association node according to the attribute identification set corresponding to different data item identifications of each sample under different association nodes and the sample identification of each sample.
[0145] The above device can execute the methods provided by all the above embodiments of the present invention, and has the corresponding functional modules and beneficial effects of executing the above methods. For technical details not fully described in the embodiments of the present invention, please refer to the methods provided by all the above embodiments of the present invention.
[0146] Figure 5A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0147] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0148] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0149] The processor 11 may be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors that run machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the storage method of the associated data.
[0150] In some embodiments, the method for storing associated data may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the method for storing associated data described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the method for storing associated data in any other appropriate manner (e.g., by means of firmware).
[0151] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0152] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0153] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0154] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0155] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, 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: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0156] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0157] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0158] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A method for storing associated data, characterized in that: include: Obtaining each data node and multiple node attributes corresponding to each data node in a target database, and determining multiple integer powers of 2 that fit within a value range of integer data corresponding to the target database; Arrange the multiple integer powers of 2, and determine whether the total number of node attributes in each of the data nodes is greater than or equal to the target number of the multiple integer powers of 2; if so, obtain the target number of node attributes from the multiple node attributes of the data nodes, and use the integer powers of 2 as attribute identifiers corresponding to the node attributes according to the arrangement results; Counting the number of remaining node attributes in the data node, and determining whether the number is less than or equal to the target number; If so, then obtain integer powers of 2 equal to the number in sequence according to the arrangement result, and use each integer power of 2 as the attribute identifier corresponding to each remaining node attribute; Determine the data item identifier corresponding to each node attribute based on the arrangement order of each attribute identifier in each data node and the number of occurrences of each attribute identifier; construct a node information table corresponding to each data node based on the multiple node attributes corresponding to each data node, the attribute identifier corresponding to each node attribute, and the data item identifier; According to the associated node attributes corresponding to each sample in the target database and the attribute identifiers of each associated node attribute in the node information table, obtain the sum of integer powers of 2 corresponding to each sample under different associated nodes, and use the sum of integer powers of 2 as the attribute identifier set; A sample association information table is constructed based on the attribute identification set corresponding to each sample under different association nodes and the sample identification of each sample.
2. The method according to claim 1, characterized in that After constructing the sample association information table based on the attribute identifier sets corresponding to each sample under different association nodes and the sample identifiers of each sample, the following steps are also included: After receiving the associated data query request, obtaining the target sample identifier and the target associated node included in the associated data query request; According to the target sample identifier and the target associated node, a target attribute identifier set is obtained in the sample associated information table; Splitting the target attribute identifier set according to integer powers of 2; A node information table corresponding to the target associated node is obtained, and associated data corresponding to the query request is obtained from the node information table corresponding to the target associated node according to the splitting result of the target attribute identifier set.
3. The method according to claim 1, characterized in that According to the associated node attributes corresponding to each sample in the target database and each node information table, the attribute identification set corresponding to each sample under different associated nodes is obtained, including: According to the associated node attributes corresponding to each sample in the target database and each node information table, the attribute identifier set corresponding to different data item identifiers under different associated nodes of each sample is obtained; Based on the attribute identifier sets corresponding to each sample under different association nodes and the sample identifiers of each sample, a sample association information table is constructed, including: According to the attribute identifier sets corresponding to different data item identifiers of each sample under different association nodes and the sample identifiers of each sample, a sample association information table corresponding to each association node is constructed.
4. A storage device for associated data, characterized in that: include: An attribute identifier determination module is used to obtain each data node and multiple node attributes corresponding to each data node in a target database, and determine multiple integer powers of 2 that meet the value range based on the integer data value range corresponding to the target database; arrange the multiple integer powers of 2 to determine whether the total number of node attributes in each of the data nodes is greater than or equal to the target number of the multiple integer powers of 2; if so, obtain the target number of node attributes from the multiple node attributes of the data nodes, and use the integer powers of 2 as the attribute identifier corresponding to each node attribute according to the arrangement result; count the number of remaining node attributes in the data nodes, and determine whether the number is less than or equal to the target number; If so, then obtain integer powers of 2 equal to the number in sequence according to the arrangement result, and use each integer power of 2 as the attribute identifier corresponding to each remaining node attribute; A node information table construction module is used to determine the data item identifier corresponding to each node attribute based on the arrangement order of each attribute identifier in each data node and the number of occurrences of each attribute identifier; and to construct a node information table corresponding to each data node based on multiple node attributes corresponding to each data node, the attribute identifier corresponding to each node attribute, and the data item identifier; An identification set acquisition module is used to obtain the sum of integer powers of 2 corresponding to each sample under different associated nodes based on the associated node attributes corresponding to each sample in the target database and the attribute identifiers of each associated node attribute in the node information table, and use the sum of integer powers of 2 as the attribute identification set; The association information table construction module is used to construct a sample association information table according to the attribute identification set corresponding to each sample under different association nodes and the sample identification of each sample.
5. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to perform the method for storing associated data according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for storing associated data according to any one of claims 1 to 3 when executed.
Citation Information
Patent Citations
Data acquisition method and device
CN106959960A
Text management method and device, electronic equipment and computer readable storage medium
CN110245329A