Primary key extraction method, device and storage medium
By performing row number reduction processing and information entropy analysis in the data table, combined with a clustering algorithm to extract qualified row data and combine fields, the problem of low efficiency in primary key determination in the existing technology is solved, and the primary key of the table is quickly extracted. , improve work efficiency.
Patent Information
- Application Number
- CN202110012338.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-06
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-01-06
AI Technical Summary
The existing technology is inefficient when determining the primary key of a data table, especially when the data developer does not understand the fields in the table, requiring multiple guesses and verifications, resulting in low efficiency.
By receiving the client's primary key extraction request, the target table is obtained, the number of rows is reduced to obtain the first sub-table, the row data that meets the preset conditions is extracted using information entropy and clustering algorithms, the primary key is determined using the field combination method, and the primary key is obtained from the client. Send the primary key.
It greatly reduces the amount of data calculation in the primary key extraction process, improves the efficiency of primary key determination, and improves the work efficiency of data developers.
Smart Images

Figure CN113761185B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of big data, and in particular to a primary key extraction method, device and storage medium. Background Art
[0002] Usually, when creating a table in a data warehouse, a primary key is not set. However, in the application process of the table, for example, when you want to understand the content contained in a single table (such as business analysis), or find the relationship between multiple tables, data developers need to analyze the content of a single table or multiple tables based on the primary key. Therefore, how to determine the primary key display of the table is particularly important.
[0003] In the process of implementing this application, the inventor found that there are at least the following problems in the prior art: when determining whether certain fields in a table are primary keys, the prior art requires manual deduplication and verification of whether the fields are primary keys. If data developers do not understand the fields, they cannot determine based on experience and need to make multiple guesses and verifications, resulting in low efficiency in determining the primary key. Summary of the invention
[0004] The embodiments of the present application provide a primary key extraction method, device and storage medium for quickly extracting the primary key of a table.
[0005] In a first aspect, an embodiment of the present application provides a primary key extraction method, comprising: in response to receiving a primary key extraction request from a client, obtaining a target table, the primary key extraction request including identification information of the target table; performing row reduction processing on the target table to obtain a first sub-table of the target table; combining fields in the first sub-table, and if the amount of data after deduplication of the first sub-table based on the field combination is equal to the amount of data after deduplication of the target table, determining the field combination as the primary key of the target table; and sending the primary key to the client.
[0006] In one possible implementation, performing row reduction processing on a target table to obtain a first sub-table of the target table may include: determining the information entropy of each row of data in the target table; performing row clustering on each row of data in the target table using a first clustering algorithm; and extracting row data in each row cluster whose corresponding information entropy meets a preset condition to obtain a first sub-table.
[0007] In one possible implementation, extracting row data in each row cluster whose corresponding information entropy meets a preset condition to obtain a first sub-table may include: extracting row data in each row cluster whose corresponding information entropy is greater than a preset information entropy to obtain the first sub-table; or, in descending order of the corresponding information entropies in each row cluster, extracting row data corresponding to a preset number of information entropies ranked in front to obtain the first sub-table, where the preset number is determined based on the amount of data in the target table and the number of categories in the row cluster.
[0008] In a possible implementation manner, the greater the difference between the amount of data in the target table and the number of categories of row clustering, the greater the preset number.
[0009] In a possible implementation, combining fields in the first subtable may include: clustering columns of data in the first subtable using a second clustering algorithm; and combining fields between categories in each column cluster.
[0010] In one possible implementation, performing row reduction processing on a target table to obtain a first sub-table of the target table may include: determining dimension fields included in the target table based on field information of each field in the target table; extracting data stored corresponding to the dimension fields in the target table to obtain a second sub-table; performing row reduction processing on the second sub-table to obtain the first sub-table of the target table.
[0011] In one possible implementation, determining the dimension fields included in the target table based on the field information of each field in the target table may include: traversing each field in the target table, obtaining a classification result of whether the field is a dimension field based on the field information and a classification model of the field, the classification model being used to identify whether the field is a dimension field; extracting the fields whose classification results are dimension fields, and obtaining the dimension fields included in the target table.
[0012] In one possible implementation, obtaining a classification result of whether a field is a dimension field based on the field information and a classification model of the field may include: using a preset mapping algorithm to map the field information of the field into a word vector; inputting the word vector into the classification model to obtain a classification result of whether the field is a dimension field.
[0013] In a possible implementation, a preset mapping algorithm is used to map field information of a field into a word vector, which may include at least one of the following:
[0014] If the field information contains a field name, the word frequency-inverse text frequency index algorithm is used to map the field name to the first vector;
[0015] If the field information contains the field type, the word frequency-inverse text frequency index algorithm is used to map the field type into a second vector;
[0016] If the field information includes a field description, the word2vec algorithm is used to map the field description into a third vector.
[0017] The word vector is obtained by concatenating at least one of the first vector, the second vector and the third vector. The preset mapping algorithm may include a word frequency-inverse text frequency index algorithm and / or a word2vec algorithm.
[0018] In a second aspect, an embodiment of the present application provides a primary key extraction device, comprising:
[0019] An acquisition module, configured to acquire a target table in response to receiving a primary key extraction request from a client, wherein the primary key extraction request includes identification information of the target table;
[0020] A processing module, used for performing a row reduction process on the target table to obtain a first sub-table of the target table;
[0021] A verification module, used for combining fields in the first sub-table, and if the amount of data after deduplication of the first sub-table based on the field combination is equal to the amount of data after deduplication of the target table, then determining the field combination as the primary key of the target table;
[0022] The sending module is used to send the primary key to the client.
[0023] In a possible implementation, the processing module may include:
[0024] The first determination submodule is used to determine the information entropy of each row of data in the target table;
[0025] A clustering submodule, used for clustering each row of data in the target table using a first clustering algorithm;
[0026] The first extraction submodule is used to extract row data whose corresponding information entropy meets a preset condition in each row cluster to obtain a first subtable.
[0027] In one possible implementation, the first extraction submodule can be specifically used to: extract row data in each row cluster whose corresponding information entropy is greater than a preset information entropy to obtain a first sub-table; or, in order from high to low corresponding information entropies in each row cluster, extract row data corresponding to a preset number of information entropies ranked in front to obtain the first sub-table, where the preset number is determined based on the amount of data in the target table and the number of categories in the row cluster.
[0028] In a possible implementation manner, the greater the difference between the amount of data in the target table and the number of categories of row clustering, the greater the preset number.
[0029] In a possible implementation, when the verification module combines the fields in the first subtable, it can be specifically used to: cluster the columns of data in the first subtable using the second clustering algorithm; and combine the fields between categories in each column cluster.
[0030] In a possible implementation, the processing module may include:
[0031] The second determination submodule is used to determine the dimension fields included in the target table according to the field information of each field in the target table;
[0032] The second extraction submodule is used to extract the data stored in the dimension field in the target table to obtain a second subtable;
[0033] The processing submodule is used to perform row number reduction processing on the second subtable to obtain the first subtable of the target table.
[0034] In one possible implementation, the second determination submodule can be specifically used to: traverse each field in the target table, and obtain a classification result of whether the field is a dimension field based on the field information and classification model of the field, and the classification model is used to identify whether the field is a dimension field; extract the field whose classification result is a dimension field, and obtain the dimension field contained in the target table.
[0035] In a possible implementation, when the second determination submodule is used to obtain a classification result of whether a field is a dimension field based on the field information and the classification model of the field, it can be specifically used to: use a preset mapping algorithm to map the field information of the field into a word vector; input the word vector into the classification model to obtain a classification result of whether the field is a dimension field.
[0036] In a possible implementation manner, when the second determination submodule is used to map the field information of the field into a word vector using a preset mapping algorithm, it can be specifically used for at least one of the following:
[0037] If the field information contains a field name, the word frequency-inverse text frequency index algorithm is used to map the field name to the first vector;
[0038] If the field information contains the field type, the word frequency-inverse text frequency index algorithm is used to map the field type into a second vector;
[0039] If the field information includes a field description, the word2vec algorithm is used to map the field description into a third vector.
[0040] The word vector is obtained by concatenating at least one of the first vector, the second vector and the third vector. The preset mapping algorithm may include a word frequency-inverse text frequency index algorithm and / or a word2vec algorithm.
[0041] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements a method as described in any one of the first aspects when executing the computer program.
[0042] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed on an electronic device, the electronic device executes a method as described in any one of the methods in the first aspect.
[0043] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is run on an electronic device, the electronic device executes a method as described in any one of the methods in the first aspect.
[0044] The primary key extraction method, device and storage medium provided in the embodiment of the present application obtain the target table in response to receiving a primary key extraction request from the client, wherein the primary key extraction request includes identification information of the target table; the target table is processed to reduce the number of rows to obtain the first subtable of the target table; the fields in the first subtable are combined, and if the amount of data after deduplication of the first subtable based on the field combination is equal to the amount of data after deduplication of the target table, the field combination is determined to be the primary key of the target table; and the primary key is sent to the client. By reducing the number of rows of the target table, the amount of data calculation in the primary key extraction process can be greatly reduced. Therefore, the primary key of the table can be quickly extracted, so as to achieve the purpose of improving the efficiency of determining the primary key, thereby improving the work efficiency of relevant personnel.
[0045] These and other aspects of the present application will become more apparent from the following description of the embodiment(s). BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0047] Figure 1 A schematic diagram of an application scenario of the primary key extraction method provided in this application;
[0048] Figure 2 A schematic diagram of a process for extracting a primary key according to an embodiment of the present application;
[0049] Figure 3 A schematic diagram of a process flow for reducing the number of rows provided in an embodiment of the present application;
[0050] Figure 4 A schematic diagram of a flow chart of field combination provided in an embodiment of the present application;
[0051] Figure 5 A schematic diagram of a process flow of a primary key extraction method provided in another embodiment of the present application;
[0052] Figure 6 A schematic diagram of the structure of a primary key extraction device provided in one embodiment of the present application;
[0053] Figure 7 A schematic diagram of the structure of a primary key extraction device provided in another embodiment of the present application;
[0054] Figure 8 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application.
[0055] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0056] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0057] First, for ease of understanding, some terms in this application are explained:
[0058] Data warehouse, also known as Data Warehouse in English, can be abbreviated as DW or DWH. It is a structured data environment for decision support systems and online analytical application data sources. Data warehouse studies and solves the problem of obtaining information from databases. In the context of information technology and data intelligence, data warehouses provide many cost-effective computing resources in the fields of software and hardware, Internet and enterprise intranet solutions, and databases. They can store extremely large amounts of data for analysis and allow the use of multiple data access technologies.
[0059] A primary key is one or more fields in a table whose value is used to uniquely identify a record in the table. In a relationship between two tables, a primary key is used to reference a specific record in one table from another table. Primary keys are mainly used for foreign key associations in other tables, as well as for modifying and deleting the record itself.
[0060] Table, such as hive table, hive is a data warehouse tool based on Hadoop, used for data extraction, transformation, loading, which is a mechanism for storing, querying and analyzing large-scale data stored in Hadoop. In the embodiment of the present application, a table can have one or more primary keys. For example, the table mentioned in the embodiment of the present application can be a table in a big data scenario, for example, an order table, an after-sales table, a user table, a merchant table and other business tables.
[0061] Dimension fields are certain characteristics of things or phenomena. Generally, non-numeric fields are selected, such as gender, region, time, etc., which are all dimension fields and are usually used as fields for association between tables.
[0062] Information entropy refers to the average amount of information after excluding redundancy.
[0063] Normally, databases such as MySQL will set a primary key, but most of the time when creating a table in a data warehouse, a primary key is not set. However, during the association process, manual deduplication verification is required to determine whether the field is the primary key, which brings great inconvenience to data developers.
[0064] When manually determining whether certain fields in a table are primary keys, if you do not understand the fields in the table, you cannot determine based on experience, which results in multiple guesses and verifications. For example, if you want to associate multiple tables or analyze a single table during data development, you will waste a lot of time looking for primary keys. For example, if you have no experience with the table and the table contains n dimension fields, then you will need This requires verification of the entire data set, which greatly affects the work efficiency of data developers.
[0065] In response to the above problems, the present application provides a primary key extraction method, device and storage medium, which improves the computational efficiency of primary key extraction by reducing the amount of data contained in the table.
[0066] For example, Figure 1 This is a schematic diagram of the application scenario of the primary key extraction method provided in this application. Figure 1 As shown, the application scenario may include: at least one client ( Figure 1 Three clients are shown, namely client 111, client 112, and client 113, a network 12, and a server 13. Each client and server 13 can communicate with each other through the network 12.
[0067] For example, in actual applications, when users including data developers trigger the extraction of the primary key of a table through the client 111, the client 111 sends a primary key extraction request to the server 13 through the network 12, and the primary key extraction request includes the identification information of the target table; accordingly, the server receives the primary key extraction request, and obtains the target table based on the identification information of the target table carried in the primary key extraction, and then performs row reduction processing on the target table to obtain a first sub-table with a reduced amount of data compared to the target table; finally, the fields in the first sub-table are combined, and if the amount of data after deduplication of the first sub-table based on the field combination is equal to the amount of data after deduplication of the target table, then the field combination is determined to be the primary key of the target table, and the primary key is fed back to the client 111 through the network 12, and the relevant information of the primary key is displayed to the user through the client 111, so that the user can analyze the table based on the primary key or associate between tables.
[0068] It should be noted that the attached Figure 1This is only a schematic diagram of an application scenario provided by the embodiment of the present application. Figure 1 does not limit the equipment included in Figure 1 The positional relationship between the devices in the Figure 1 In the application scenario shown, a data storage device may also be included, and the data storage device may be an external memory relative to the server 13, or an internal memory integrated in the server 13. In addition, the server 13 may be an independent server, or a service cluster.
[0069] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0070] Figure 2 The present invention provides a primary key extraction method, which is applied to a primary key extraction device, and the device can be implemented by software and / or hardware. Figure 1 In the illustrated scenario, the primary key extraction device may be integrated into a server, for example, the primary key extraction device is a chip or circuit in the server; or, the primary key extraction device is a server. Next, an example is given with the server as the execution subject.
[0071] like Figure 2 As shown, the primary key extraction method includes the following steps:
[0072] S201. In response to receiving a primary key extraction request from a client, a target table is acquired, where the primary key extraction request includes identification information of the target table.
[0073] In actual applications, when data developers and other relevant personnel need to obtain the primary key of a table, they perform corresponding operations on the client. The client responds to the operation and sends a primary key extraction request to the server, triggering the server to execute the primary key extraction process.
[0074] Accordingly, the server receives the primary key extraction request and responds to it. Specifically, the server parses the primary key extraction request to obtain the identification information of the target table contained therein; based on the identification information, the server can obtain the target table with the identification information from an internal storage medium or an external data source. The target table is the table whose primary key is to be determined, and is the object of the primary key extraction performed by the server in the embodiment of the present application.
[0075] It can be understood that the target table usually contains multiple fields, each field corresponding to its own field information and corresponding stored data. Generally, the field information can include information such as field name, field type, field length and field description. In the embodiment of the present application, the field information can be at least one of the above information.
[0076] As an example, the embodiment of the present application uses the order table shown in Table 1 as the target table for explanation. Referring to Table 1, the order table contains 9 fields, and the corresponding field names are: sale_ord_id, item_sku_id, dept_id_1, dept_id_2, cate_1, cate_2, gmv and ord_num; different fields correspond to their own stored data. For example, the column with the field name sale_ord_id stores the data 1, 1, 1, 5, 5, 5, 9, 9, 9 and 9 corresponding to the field. It should be clear that Table 1 is only used to illustrate the meaning of each part thereof, and the fields contained in the order table and the corresponding stored data are not limited to Table 1.
[0077] Table 1 Order table
[0078] sale_ord_id item_sku_id dept_id_1 dept_id_2 cate_1 cate_2 gmv 3rd_num 1 1 1 2 2 2 834.5 453 1 1 2 2 2 3 454.3 65 1 1 1 3 2 2 45 876 5 5 6 6 7 7 234 76 5 5 5 6 7 7 3 54 5 6 5 6 7 6 76 4 5 5 5 6 7 7 65 32 9 8 9 9 8 8 87 76 9 9 8 9 9 8 987 87 9 9 8 8 8 8 765 98 9 9 8 9 8 8 5443 98
[0079] The field information of each field in Table 1 may be as shown in Table 2:
[0080] Table 2
[0081] Field Name Segment Type Field Description sale_ord_id string Order Number item_sku_id string Product Number dept_id_1 string First-level department number dept_id_2 string Secondary department number cate_1 string First-level category number cate_2 string Secondary Category Number gmv double Sales ord_num int Order volume
[0082] S202: Perform row reduction processing on the target table to obtain a first sub-table of the target table.
[0083] Since the amount of data contained in the table is very large in the big data scenario, the purpose of this step is to reduce the amount of data contained in the table and obtain a sub-table of the target table. To distinguish it from other sub-tables, it is named "first sub-table" here. The "first" does not indicate the size of the data contained in the sub-table, but the amount of data in the first sub-table is smaller than that of the target table.
[0084] As for the row number reduction process, it can be understood that the effect of reducing the amount of data contained in the target table is achieved by deleting the rows in the target table. For the specific implementation of the row number reduction process, reference can be made to the subsequent embodiments.
[0085] S203: Perform field combination on the fields in the first subtable. If the amount of data after deduplication of the first subtable based on the field combination is equal to the amount of data after deduplication of the target table, determine the field combination as the primary key of the target table.
[0086] By combining the fields in the first subtable, multiple field combinations can be obtained. For example, the first subtable includes field a, field b, field c There are four fields in total, including field d. By combining the fields, we can get the following field combinations:
[0087] (a), (b), (c), (d);
[0088] (a, b), (a, c), (a, d), (b, c), (b, d), (c, d);
[0089] (a, b, c), (a, b, d), (a, c, d), (b, c, d);
[0090] (a, b, c, d).
[0091] Verify whether the above field combinations are primary keys. For example, compare the amount of data after deduplication of field combination (a) with the amount of data after deduplication of the first subtable. If the two are the same, then determine that field combination (a) is the primary key. For another example, compare the amount of data after deduplication of field combination (a, b) with the amount of data after deduplication of the first subtable. If the two are the same, then determine that field combination (a, b) is the primary key, that is, the joint primary key.
[0092] S204: Send the primary key to the client.
[0093] Specifically, the server sends the primary key to the client. The primary key here can be the field name of the field included in the primary key, or the position of the field included in the primary key in the target table, etc., which needs to be set according to actual needs.
[0094] The client displays the primary key for reference by relevant personnel. The embodiment of the present application does not limit the display method used by the client to display the primary key. For example, the client displays the primary key in a color that is different from other fields, and so on.
[0095] The primary key extraction method provided in the embodiment of the present application, in response to receiving a primary key extraction request from a client, obtains a target table, the primary key extraction request includes identification information of the target table; performs row reduction processing on the target table to obtain the first subtable of the target table; performs field combination on each field in the first subtable, and if the amount of data after deduplication of the first subtable based on the field combination is equal to the amount of data after deduplication of the target table, the field combination is determined to be the primary key of the target table; and sends the primary key to the client. By performing row reduction processing on the target table, the amount of data in the primary key extraction process can be greatly reduced. Therefore, the primary key of the table can be quickly extracted, thereby achieving the purpose of improving the extraction efficiency of the primary key, thereby improving the work efficiency of relevant personnel.
[0096] Next, how to perform the row number reduction process is described through the following embodiments.
[0097] like Figure 3 As shown, Figure 2 The step S202, performing a row reduction process on the target table to obtain a first sub-table of the target table, may further include:
[0098] S301. Determine the information entropy of each row of data in the target table.
[0099] In the target table, the data of each instance is stored in the form of rows. Taking Table 1 as an example, the first row stores the data corresponding to each field [1,1,1,2,2,2,834.5,453], representing an instance.
[0100] Traverse each row of data in the target table and calculate the information entropy of the row data.
[0101] S302: Use a first clustering algorithm to perform row clustering on each row of data in the target table.
[0102] The present application does not limit the specific type of the first clustering algorithm. For example, the first clustering algorithm may include but is not limited to a density clustering algorithm and a partition clustering algorithm. The density clustering algorithm is, for example, a density-based clustering method with noise (Density-Based Spatial Clustering of Applications with Noise, referred to as DBSCAN), and the partition clustering algorithm is, for example, a K-means clustering algorithm (K-means Clustering Algorithm, referred to as K-Means). Compared with K-Means, which is only applicable to clustering of convex sample sets, DBSCAN can be applied to both convex sample sets and non-convex sample sets.
[0103] Through the row clustering process, similar row data in the target table can be clustered together, so as to reduce the number of rows by executing S303 .
[0104] It should be noted that the embodiment of the present application does not limit the execution order of S301 and S302. That is, the server can execute these two steps in sequence, for example, first execute S301 and then execute S302, or first execute S302 and then execute S301; or, the server can also execute S301 and S302 in parallel.
[0105] S303: extract row data whose corresponding information entropy meets a preset condition in each row cluster to obtain a first sub-table.
[0106] Since the row data in each row cluster are similar, the amount of data in the target table can be reduced by cutting similar row data. Therefore, in the target table, for each row cluster, the first sub-table is obtained by extracting row data whose information entropy meets the preset conditions. Alternatively, it can be understood that in the target table, for each row cluster, the row data whose information entropy does not meet the preset conditions is deleted to obtain the first sub-table; or, in the target table, for each row cluster, the row data whose information entropy meets the preset conditions is retained to obtain the first sub-table.
[0107] This embodiment obtains a first sub-table with a smaller data volume through stratified sampling.
[0108] Optionally, due to different preset conditions, the implementation methods of obtaining the first sub-table are also different. For example:
[0109] In one implementation, the preset condition is that the information entropy is greater than the preset information entropy. At this time, extracting row data in each row cluster whose corresponding information entropy meets the preset condition to obtain the first subtable may include: extracting row data in each row cluster whose corresponding information entropy is greater than the preset information entropy to obtain the first subtable. The size of the preset information entropy can be set according to actual needs.
[0110] In another implementation, the preset condition is a higher preset number of information entropies. In this case, extracting row data in each row cluster whose corresponding information entropy meets the preset condition to obtain the first subtable may include: extracting row data corresponding to a preset number of information entropies ranked first in the order of the corresponding information entropies in each row cluster from high to low to obtain the first subtable. The preset number is determined according to the amount of data in the target table and the number of categories of the row cluster.
[0111] Optionally, the greater the difference between the amount of data in the target table and the number of categories of the row clustering, the greater the preset number. For example, when the difference is greater than the preset value, the preset number can be set larger; when the difference is less than the preset value, the preset number can be set smaller.
[0112] On the basis of the above embodiment, the number of columns of the table may be further reduced to further reduce the amount of data in the primary key extraction process.
[0113] In some embodiments, such as Figure 4 As shown, the fields in the first sub-table are combined, which may include:
[0114] S401: Use a second clustering algorithm to perform column clustering on each column of data in the first subtable.
[0115] The second clustering algorithm and the first clustering algorithm may be the same clustering algorithm, or they may be different clustering algorithms. For example, the first clustering algorithm and the second clustering algorithm may both be DBSCAN.
[0116] Through the column clustering process, similar column data in the first sub-table can be clustered together, so as to reduce the number of columns in the table by executing S402.
[0117] S402: Combine fields between categories in each column cluster.
[0118] In this step, the columns are combined according to the categories after clustering, wherein the principle of combination is that the fields in the field combination are derived from the combination of individual fields selected from each category, and do not include combinations within the category.
[0119] This embodiment takes into account that the fields within a category should be considered to be relatively similar, and the possibility of the fields becoming a primary key after combination is small, while the differences between categories are large, and the possibility of the fields becoming a primary key after combination is large. In this way, after eliminating the field combination within a category, the amount of calculation is also greatly reduced.
[0120] For example, still taking the first subtable containing four fields, field a, field b, field c and field d, as an example, after clustering the columns of data in the first subtable, two categories are obtained: a category containing field a, field b and field c, and a category containing field d. The fields between the categories are combined to obtain the following field combinations:
[0121] (a), (b), (c), (d);
[0122] (a, d), (b, d), (c, d);
[0123] (a,b,d), (a,c,d), (b,c,d);
[0124] (a,b,c,d).
[0125] It is easy to see that the above field combinations do not include field combinations within the categories (a,b), (b,c), (a,c) and (a,b,c).
[0126] In the process of extracting primary keys, the embodiment of the present application utilizes dimension clustering to combine associated primary keys, eliminates invalid combinations of internal dimensions of the same category, and greatly improves the extraction efficiency of associated primary keys.
[0127] Figure 5 A schematic diagram of a process flow of a primary key extraction method provided in another embodiment of the present application. In this embodiment, the primary key extraction method may include:
[0128] S500: Receive a primary key extraction request from a client.
[0129] The primary key extraction request includes identification information of the target table.
[0130] S501: Obtain a target table.
[0131] The specific implementation of S500 and S501 is similar to that of S201 and will not be described in detail here.
[0132] S502: Determine the dimension fields included in the target table according to the field information of each field in the target table.
[0133] Optionally, this step may include: traversing each field in the target table, and obtaining a classification result of whether the field is a dimension field based on the field information and the classification model of the field, wherein the classification model is used to identify whether the field is a dimension field; extracting the fields whose classification results are dimension fields, and obtaining the dimension fields contained in the target table.
[0134] After obtaining the target table, the fields contained in the target table are known, and the dimension fields contained in the target table are determined according to the field information of the fields. Among them, the classification model is a pre-trained model that meets the convergence conditions. During the training process, whether the field is a dimension field is marked by manual marking. For example, 1 indicates that it is a dimension field, and 0 indicates that it is not a dimension field (non-dimensional field). In this way, if the classification model output is 1, it is determined that the corresponding field is a dimension field; if the classification model output is 0, it is determined that the corresponding field is a non-dimensional field.
[0135] Generally, before using a classification model to classify a field, the field information needs to be parameterized, that is, the field information is converted into a numerical value. Therefore, as a possible implementation method, according to the field information of the field and the classification model, obtaining a classification result of whether the field is a dimension field can include: using a preset mapping algorithm to map the field information of the field into a word vector; inputting the word vector into the classification model to obtain a classification result of whether the field is a dimension field.
[0136] The preset mapping algorithm is used to map the field information of the field into a word vector, which may include at least one of the following:
[0137] 1) If the field information includes a field name, the Term Frequency–Inverse Document Frequency (TF-IDF) algorithm is used to map the field name into the first vector.
[0138] Among them, the TF-IDF algorithm is a commonly used weighting technology used in information retrieval and data mining to evaluate the importance of a word to a document set or one of the documents in a corpus.
[0139] 2) If the field information contains a field type, the word frequency-inverse text frequency index algorithm is used to map the field type into a second vector.
[0140] 3) If the field information includes a field description, the word2vec algorithm is used to map the field description into a third vector.
[0141] Among them, the Word2vec algorithm is a group of related models used to generate word vectors. For example, these models can be neural networks.
[0142] The word vector is obtained by splicing at least one of the first vector, the second vector, and the third vector. For example, when the field information only includes the field name, the field type, or the field description, the word vector finally obtained is the corresponding vector. For example, if the field information only includes the field name, the word vector is the first vector; when the field information includes at least two of the field name, the field type, and the field description, the word vector finally obtained is the splicing of the corresponding vectors. For example, if the field information includes the field name and the field type, the word vector is the splicing of the first vector and the second vector, or, if the field information includes the field name, the field type, and the field description, the word vector is the splicing of the first vector, the second vector, and the third vector. Those skilled in the art can understand that for the acquisition of word vectors, the corresponding acquisition methods in the application stage and the training stage are the same. For example, the word vector in the training stage is obtained by splicing the first vector and the second vector, and the word vector in the application stage is also obtained by splicing the first vector and the second vector of the corresponding field.
[0143] For example, for Table 1 as described above, when the fields in Table 1 are classified, the vectors involved and the classification results may be shown in Table 3:
[0144] Table 3
[0145] Field Name Segment Type Field Description tiidf word2vec embedding label sale_ord_id string Order Number [3,2,1,43,422] [13,32,41,343,422] [3,2,1,43,422,13,32,41,343,422] 1 item_sku_id string Product Number [4,24,22,43,22] [24,324,242,433,242] [4,24,22,43,22,24,324,242,433,242] 1 dept_id_1 string First-level department number [65,3,554.657,43] [32,4,54,33,33] [65,3,554,657,43,32,4,54,33,33] 1 dept_id_2 string Secondary department number [3221,32,45,432] [21,32,45,432] [3221,32,45,432,21,32,45,432] 1 cate_1 string First-level category number [8231,532,15,362] [31,532,15,362] [8231,532,15,362,31,532,15,362] 1 cate_2 string Secondary Category Number [731,332,235,1562] [931,332,235,1562] [731,332,235,1562,931,332,235,1562] 1 gmv double Sales [5431,1232,35,562] [531,123,35,562] [5431,1232,35,562,531,123,35,562] 0 ord_num int Order volume [7331,1232,235,562] [733,12,235,562] [7331,1232,235,562,733,12,235,562] 0
[0146] In Table 3, embedding is used to represent word vectors as the features of the classification model. Label indicates whether the field is a dimension field. 1 indicates that it is a dimension field, and 0 indicates that it is not a dimension field (non-dimensional field).
[0147] S503: Extract the data stored in the dimension field in the target table to obtain a second sub-table.
[0148] Since non-dimensional fields are generally not used to associate with other tables, and non-dimensional fields will not be used as the primary key of the table, such as the field named gmv in Table 3, etc., non-dimensional fields can be excluded when extracting the primary key.
[0149] For example, the data stored in the dimension fields in the target table shown in Table 1 are extracted to obtain the second sub-table shown in Table 4:
[0150] Table 4
[0151] sale_ord_id item_sku_id dept_id_1 dept_id_2 cate_1 cate_2 1 1 1 2 2 2 1 1 2 2 2 3 1 1 1 3 2 2 5 5 6 6 7 7 5 5 5 6 7 7 5 6 5 6 7 6 5 5 5 6 7 7 9 8 9 9 8 8 9 9 8 9 9 8 9 9 8 8 8 8 9 9 8 9 8 8
[0152] S504: Perform row number reduction processing on the second sub-table to obtain the first sub-table of the target table.
[0153] It can be understood that S502 to S504 are Figure 2 The step S202 is further refined.
[0154] For S504, its specific implementation can refer to the implementation of "reducing the number of rows in the target table to obtain the first sub-table of the target table" above, and replace the "target table" with the "second sub-table". For example, the information entropy of each row of data in the first sub-table shown in Table 4 is determined to obtain Table 5:
[0155] Table 5
[0156] sale_ord_id item_sku_id dept_id_1 dept_id_2 cate_1 cate_2 entropy 1 1 1 2 2 2 1 1 1 2 2 2 3 1.459148 1 1 1 3 2 2 1.459148 5 5 6 6 7 7 1.584963 5 5 5 6 7 7 1.459148 5 6 5 6 7 6 1.459148 5 5 5 6 7 7 1.459148 9 8 9 9 8 8 1 9 9 8 9 9 8 0.918296 9 9 8 9 9 8 0.918296 9 9 8 9 8 8 1
[0157] The first clustering algorithm is used to cluster the rows of data in the first subtable, and Table 6 is obtained:
[0158] Table 6
[0159] sale_ord_id item_sku_id dept_id_1 dept_id_2 cate_1 cate_2 entropy cluster 1 1 1 2 2 2 1 1 1 1 2 2 2 3 1.459148 1 1 1 1 3 2 2 1.459148 1 5 5 6 6 7 7 1.584963 2 5 5 5 6 7 7 1.459148 2 5 6 5 6 7 6 1.459148 2 5 5 5 6 7 7 1.459148 2 9 8 9 9 8 8 1 3 9 9 8 9 9 8 0.918296 3 9 9 8 9 9 8 0.918296 3 9 9 8 9 8 8 1 3
[0160] In Table 6, “cluster” is the cluster identifier, and there are three row clusters: 1, 2, and 3.
[0161] After that, extract the row data whose corresponding information entropy meets the preset conditions in each row cluster to obtain the first subtable. For example, extract the n row data with the largest information entropy in each row cluster (as shown in Table 7), corresponding to the 1st, 2nd, 3rd, 7th, and 10th rows respectively, to obtain Table 8:
[0162] Table 7
[0163] sale_ord_id item_sku_id dept_id_1 dept_id_2 cate_1 cate_2 entropy cluster 1 1 1 2 2 2 1 1 1 1 2 2 2 3 1.459148 1 1 1 1 3 2 2 1.459148 1 5 5 6 6 7 7 1.584963 2 5 5 5 6 7 7 1.459148 2 5 6 5 6 7 6 1.459148 2 5 5 5 6 7 7 1.459148 2 9 8 9 9 8 8 1 3 9 9 8 9 9 8 0.918296 3 9 9 8 8 8 8 0.918296 3 9 9 8 9 8 8 1 3
[0164] Table 8
[0165] sale_ord_id item_sku_id dept_id_1 dept_id_2 cate_1 cate2 entropy cluster 1 1 2 2 2 3 1.459148 1 1 1 1 3 2 2 1.459148 1 5 5 6 6 7 7 1.584963 2 9 8 9 9 8 8 1 3 9 9 8 9 8 8 1 3
[0166] S505: Perform field combination on the fields in the first subtable. If the amount of data after deduplication of the first subtable based on the field combination is equal to the amount of data after deduplication of the target table, determine the field combination as the primary key of the target table.
[0167] For example, the second clustering algorithm is used to perform column clustering on the data in each column of the first sub-table shown in Table 8, and Table 9 is obtained:
[0168] Table 9
[0169] sale_ord_id item_sku_id dept_id_1 dept_id_2 cate_1 cate_2 entropy cluster 1 1 2 2 2 3 1.459148 1 1 1 1 3 2 2 1.459148 1 5 5 6 6 7 7 1.584963 2 9 8 9 9 8 8 1 3 9 9 8 9 8 8 1 3
[0170] Referring to Table 9, the categories after column clustering include:
[0171] (sale_ord_id, item_sku_id);
[0172] (dept_id_1, dept_id_2);
[0173] (cate_1, cate_2).
[0174] Then, combine the fields between categories in each column cluster to obtain:
[0175] (sale_ord_id, item_sku_id, dept_id_1, dept_id_2);
[0176] (sale_ord_id, item_sku_id, dept_id_1);
[0177] (sale_ord_id, item_sku_id, dept_id_2);
[0178] (sale_ord_id, dept_id_1, dept_id_2);
[0179] Finally, the primary key is verified. After deduplication of the above field combination, if the data volume is the same as the data volume after deduplication of all fields, the field combination is considered to be a joint primary key.
[0180] After deduplication calculation, it is found that: (sale_ord_id, item_sku_id, dept_id_1, dept_id_2) and (item_sku_id, dept_id_1, dept_id_2) meet the requirements, and these two sets of fields are determined to be the primary key of the target table.
[0181] S506: Send the primary key to the client.
[0182] Optionally, assuming that there is no field combination that meets the requirement at present, the process of row clustering in S504 and column clustering in S505 is repeated until the primary key of the target table is extracted.
[0183] The embodiments of the present application have at least the following beneficial effects:
[0184] (1) Through the classification model, the information entropy of the row data of the calculation table, and clustering methods, the number of rows and columns of the target table is reduced, which greatly reduces the amount of data in the calculation process table and improves the calculation efficiency of primary key extraction.
[0185] (2) In the process of extracting primary keys, clustering is used to combine related primary keys and eliminate invalid combinations of fields in the same category, greatly improving the efficiency of primary key extraction.
[0186] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0187] Figure 6 This is a schematic diagram of the structure of a primary key extraction device provided in an embodiment of the present application. This embodiment of the present application provides a primary key extraction device, which can be integrated in an electronic device such as a server. Figure 6 As shown, the primary key extraction device 60 includes: an acquisition module 61, a processing module 62, a verification module 63 and a sending module 64. Among them:
[0188] An acquisition module 61 is used to acquire a target table in response to receiving a primary key extraction request from a client, wherein the primary key extraction request includes identification information of the target table;
[0189] A processing module 62 is used to perform row number reduction processing on the target table to obtain a first sub-table of the target table;
[0190] A verification module 63 is used to perform field combination on the fields in the first sub-table, and if the amount of data after deduplication of the first sub-table based on the field combination is equal to the amount of data after deduplication of the target table, then determine that the field combination is the primary key of the target table;
[0191] The sending module 64 is used to send the primary key to the client.
[0192] The device provided in the embodiment of the present application can be used to perform Figure 2 The implementation principle and technical effect of the method in the illustrated embodiment are similar and will not be described in detail here.
[0193] refer to Figure 7 ,exist Figure 6 Based on the structure shown, further, the processing module 62 may include:
[0194] The first determination submodule 621 is used to determine the information entropy of each row of data in the target table;
[0195] The clustering submodule 622 is used to perform row clustering on each row of data in the target table using a first clustering algorithm;
[0196] The first extraction submodule 623 is used to extract row data whose corresponding information entropy meets a preset condition in each row cluster to obtain a first subtable.
[0197] In some embodiments, the first extraction submodule 621 can be specifically used to: extract row data in each row cluster whose corresponding information entropy is greater than a preset information entropy to obtain a first sub-table; or, in order from high to low corresponding information entropies in each row cluster, extract row data corresponding to a preset number of information entropies ranked in front to obtain a first sub-table, where the preset number is determined based on the amount of data in the target table and the number of categories in the row cluster.
[0198] Optionally, the greater the difference between the data volume of the target table and the number of categories of row clustering, the greater the preset number.
[0199] In some embodiments, when combining fields in the first subtable, the verification module 63 may be specifically used to: perform column clustering on each column of data in the first subtable using the second clustering algorithm; and perform field combination on fields between categories in each column cluster.
[0200] Furthermore, the processing module 62 may include:
[0201] The second determination submodule 624 is used to determine the dimension fields included in the target table according to the field information of each field in the target table;
[0202] The second extraction submodule 625 is used to extract the data stored in the dimension field in the target table to obtain a second subtable;
[0203] The processing submodule 626 is used to perform row number reduction processing on the second subtable to obtain the first subtable of the target table.
[0204] Optionally, the second determination submodule 624 can be specifically used to: traverse each field in the target table, and obtain a classification result of whether the field is a dimension field based on the field information and the classification model of the field, and the classification model is used to identify whether the field is a dimension field; extract the field whose classification result is a dimension field, and obtain the dimension field contained in the target table.
[0205] In some embodiments, when the second determination submodule 624 is used to obtain a classification result of whether a field is a dimension field based on the field information and the classification model of the field, it can be specifically used to: use a preset mapping algorithm to map the field information of the field into a word vector; input the word vector into the classification model to obtain a classification result of whether the field is a dimension field.
[0206] Furthermore, when the second determining submodule 624 is used to map the field information of the field into a word vector by using a preset mapping algorithm, it can be specifically used for at least one of the following:
[0207] If the field information contains a field name, the word frequency-inverse text frequency index algorithm is used to map the field name to the first vector;
[0208] If the field information contains the field type, the word frequency-inverse text frequency index algorithm is used to map the field type into a second vector;
[0209] If the field information includes a field description, the word2vec algorithm is used to map the field description into a third vector.
[0210] The word vector is obtained by concatenating at least one of the first vector, the second vector and the third vector. The preset mapping algorithm may include a word frequency-inverse text frequency index algorithm and / or a word2vec algorithm.
[0211] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, the processing module can be a separately established processing element, or it can be integrated in a chip of the above device. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The implementation of other modules is similar. In addition, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0212] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more microprocessors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0213] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0214] Figure 8 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Figure 8 As shown, the electronic device may include: a processor 81, a memory 82, a communication interface 83 and a system bus 84. The memory 82 and the communication interface 83 are connected to the processor 81 through the system bus 84 and communicate with each other. The memory 82 is used to store instructions, the communication interface 83 is used to communicate with other devices, and the processor 81 is used to call the instructions in the memory to execute the solution described in the above primary key extraction method embodiment.
[0215] Should Figure 8 The system bus 84 mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus 84 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0216] The communication interface 83 is used to implement the communication between the database access device and other devices (such as clients, read-write libraries and read-only libraries).
[0217] The memory 82 may include a random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory.
[0218] The processor 81 can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0219] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed on an electronic device, the electronic device executes the primary key extraction method as described in any of the above method embodiments.
[0220] An embodiment of the present application also provides a chip for executing instructions, and the chip is used to execute the primary key extraction method described in any of the above method embodiments.
[0221] An embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When the at least one processor executes the computer program, the primary key extraction method described in any of the above method embodiments can be implemented.
[0222] In the present application, "at least one" means one or more, and "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship; in the formula, the character " / " indicates that the previous and next associated objects are in a "division" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple.
[0223] It is to be understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of description and are not intended to limit the scope of the embodiments of the present application. In the embodiments of the present application, the size of the sequence number of each process does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0224] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A primary key extraction method, characterized in that: include: In response to receiving a primary key extraction request from a client, obtaining a target table, wherein the primary key extraction request includes identification information of the target table; Performing a row number reduction process on the target table to obtain a first subtable of the target table; Performing a field combination on the fields in the first sub-table, and if the amount of data after deduplication of the first sub-table based on the field combination is equal to the amount of data after deduplication of the target table, determining the field combination as the primary key of the target table; Sending the primary key to the client; The performing of row reduction processing on the target table to obtain a first sub-table of the target table includes: Determine the information entropy of each row of data in the target table; Using a first clustering algorithm to perform row clustering on each row of data in the target table; Extract row data whose corresponding information entropy meets preset conditions in each row cluster to obtain the first sub-table; The combining of the fields in the first sub-table includes: Using a second clustering algorithm to perform column clustering on each column of data in the first subtable; Combine fields between categories in each column cluster.
2. The primary key extraction method according to claim 1, characterized in that: The step of extracting row data corresponding to each row cluster whose information entropy meets a preset condition to obtain the first sub-table includes: Extract row data whose corresponding information entropy is greater than a preset information entropy in each row cluster to obtain the first sub-table; Alternatively, according to the order of the corresponding information entropy in each row cluster from high to low, extract the row data corresponding to a preset number of information entropies ranked first to obtain the first sub-table, and the preset number is determined according to the data volume of the target table and the number of categories of the row cluster.
3. The primary key extraction method according to claim 2, characterized in that: The greater the difference between the amount of data in the target table and the number of categories of the row clustering, the greater the preset number.
4. The primary key extraction method according to any one of claims 1 to 3, characterized in that: The performing of row reduction processing on the target table to obtain a first sub-table of the target table includes: Determine the dimension fields included in the target table according to the field information of each field in the target table; Extract the data stored in the dimension field in the target table to obtain a second sub-table; The second sub-table is processed to reduce the number of rows to obtain the first sub-table of the target table.
5. The primary key extraction method according to claim 4, characterized in that: The step of determining the dimension fields included in the target table according to the field information of each field in the target table includes: Traversing each field in the target table, and obtaining a classification result of whether the field is a dimension field according to the field information and a classification model of the field, wherein the classification model is used to identify whether the field is a dimension field; The classification result is extracted to be a field of a dimension field, and the dimension field contained in the target table is obtained.
6. The primary key extraction method according to claim 5, characterized in that: The obtaining, according to the field information and the classification model of the field, a classification result of whether the field is a dimension field includes: Using a preset mapping algorithm, mapping the field information of the field into a word vector; The word vector is input into the classification model to obtain a classification result of whether the field is a dimension field.
7. The primary key extraction method according to claim 6, characterized in that: The using of a preset mapping algorithm to map the field information of the field into a word vector includes at least one of the following: If the field information includes a field name, a word frequency-inverse text frequency index algorithm is used to map the field name into a first vector, and the preset mapping algorithm includes the word frequency-inverse text frequency index algorithm; If the field information packet is a field type, a word frequency-inverse text frequency index algorithm is used to map the field type to a second vector, and the preset mapping algorithm includes the word frequency-inverse text frequency index algorithm; If the field information includes a field description, a word2vec algorithm is used to map the field description into a third vector, and the preset mapping algorithm includes the word2vec algorithm; The word vector is obtained by concatenating at least one of the first vector, the second vector and the third vector.
8. A primary key extraction device, characterized in that: include: An acquisition module, configured to acquire a target table in response to receiving a primary key extraction request from a client, wherein the primary key extraction request includes identification information of the target table; A processing module, configured to perform a row reduction process on the target table to obtain a first sub-table of the target table; A verification module, configured to perform field combination on the fields in the first sub-table, and if the amount of data after deduplication of the first sub-table based on the field combination is equal to the amount of data after deduplication of the target table, then determine that the field combination is the primary key of the target table; A sending module, used for sending the primary key to the client; The processing module comprises: A first determination submodule is used to determine the information entropy of each row of data in the target table; A clustering submodule, used for clustering each row of data in the target table by using a first clustering algorithm; A first extraction submodule is used to extract row data whose corresponding information entropy meets a preset condition in each row cluster to obtain the first subtable; The verification module is specifically used to perform column clustering on each column of data in the first sub-table by using a second clustering algorithm; and to perform field combination on fields between categories in each column cluster.
9. An electronic device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data fusion method and device
CN106909689A
Storage method, extraction method, storage platform and extraction platform for equipment data
CN108334549A
