Data relationship construction methods, data statistical methods, devices and electronic equipment

By constructing a mapping relationship between redundant fields in the data tables, the problem of inaccurate data statistics caused by non-corresponding relationships in the database is solved, and the accurate construction and statistics of data relationships are realized.

CN116186023BActive Publication Date: 2026-03-06QINGDAO HAIER TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-29
Publication Date
2026-03-06

AI Technical Summary

Technical Problem

In the early stages of the project, the non-corresponding relationships between fields in the database made it impossible to query fields accurately. In the later stages of the project, as the amount of data increased, the non-corresponding relationships led to inaccurate data statistics results and even the loss of data relationships.

Method used

By identifying redundant fields between two data tables and constructing a mapping relationship for primary key fields based on these redundant fields, a correspondence between the data tables is established, and data statistics are optimized using preset query conditions.

Benefits of technology

It reduces the loss of data relationships, especially transaction data, and improves the accuracy and precision of data statistics.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116186023B_ABST
    Figure CN116186023B_ABST
Patent Text Reader

Abstract

This invention provides a data relationship construction method, data statistics method, apparatus, and electronic device, comprising: determining redundant fields between a first data table and a second data table; mapping a first primary key field in the first data table to the second data table based on the redundant fields to construct a correspondence between the first primary key field and a second primary key field in the second data table; the redundant fields are used to construct a non-correspondence relationship between the first and second data tables; both the correspondence and non-correspondence relationships are used for data statistics on the first and second data tables. The data relationship construction method, data statistics method, apparatus, and electronic device provided by this invention construct a correspondence between two data tables by adding a primary key field from one data table to another. As project functions iterate, primary key substitution reduces the error in data statistics and decreases the loss of data relationships, especially reducing the loss of some transactional data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of big data technology, and in particular to a data relationship construction method, data statistics method, apparatus, and electronic device. Background Technology

[0002] When undertaking a project, it is necessary to establish a database. Since the project is improved step by step through iteration, in the early stages of the project, there may be situations where the functions are not complete or some relationships in the project database are not fully established.

[0003] However, since the project has already been put into use in the early stages, the existing fields in the project database have non-corresponding relationships, which causes fields to be unable to be queried or the query range to be inaccurate.

[0004] As project features iterate, this lack of correspondence can lead to the loss of untraceable relationships between newly added fields in the database tables and existing fields in the later stages of the project. Summary of the Invention

[0005] To address the problems existing in the prior art, embodiments of the present invention provide a data relationship construction method, a data statistics method, an apparatus, and an electronic device.

[0006] Firstly, this invention provides a method for constructing data relationships, comprising: determining redundant fields between a first data table and a second data table;

[0007] Based on the redundant fields, the first primary key field in the first data table is mapped to the second data table to establish a correspondence between the first primary key field and the second primary key field in the second data table;

[0008] The redundant fields are used to construct a non-correspondence relationship between the first data table and the second data table;

[0009] Both the correspondence and the non-correspondence relationships are used for data statistics in the first data table and the second data table.

[0010] According to a data relationship construction method provided by the present invention, the step of mapping a first primary key field in the first data table to a second data table based on the redundant field includes:

[0011] Based on the redundant fields in the first data table and the redundant fields in the second data table, and the preset query conditions, the first primary key field in the first data table is mapped to the second data table; the redundant fields are fields common to both data tables in the database; the primary key field is the field that is the primary key field of the data table;

[0012] The preset query conditions are determined based on the relationships between the fields in the first data table and the fields in the second data table.

[0013] According to a data relationship construction method provided by the present invention, determining redundant fields between a first data table and a second data table includes:

[0014] Retrieve the first data table and the second data table from the database respectively;

[0015] If it is determined that there is a common field between the first data table and the second data table, the common field is obtained and used as a redundant field between the first data table and the second data table;

[0016] The first data table and the second data table are determined based on redundant fields.

[0017] Secondly, the present invention provides a data statistics method, including: determining a target field;

[0018] Based on the correspondence between the first primary key field in the first data table and the second primary key field in the second data table, statistics are performed on the target fields in the first data table and the second data table;

[0019] The correspondence between the first primary key field in the first data table and the second primary key field in the second data table is determined based on any of the data relationship construction methods described above.

[0020] According to a data statistics method provided by the present invention, if the correlation of the target field is a non-corresponding relationship, then after determining the target field, the method further includes:

[0021] Based on the non-correspondence between redundant fields in the first data table and redundant fields in the second data table, and based on preset query conditions, statistics are performed on the target fields in the first data table and the second data table.

[0022] The non-correspondence relationship is constructed based on the redundant fields between the first data table and the second data table.

[0023] According to a data statistics method provided by the present invention, the preset query conditions include any one of the following query conditions: time, user ID number, or enterprise ID number.

[0024] Thirdly, the present invention also provides a data relationship construction apparatus, comprising: a first determining module, configured to determine redundant fields between a first data table and a second data table;

[0025] A construction module is used to map the first primary key field in the first data table to the second data table based on the redundant fields, so as to construct a correspondence between the first primary key field and the second primary key field in the second data table;

[0026] The redundant fields are used to construct a non-correspondence relationship between the first data table and the second data table;

[0027] Both the correspondence and the non-correspondence relationships are used for data statistics in the first data table and the second data table.

[0028] Fourthly, the present invention also provides a data statistics device, comprising:

[0029] The second determination module is used to determine the target field;

[0030] The statistics module is used to perform statistics on the target field in the first data table and the second data table based on the correspondence between the first primary key field in the first data table and the second primary key field in the second data table;

[0031] The correspondence between the first primary key field in the first data table and the second primary key field in the second data table is determined based on the aforementioned data relationship construction method.

[0032] Fifthly, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of any of the data relationship construction methods or data statistics methods described above.

[0033] In a sixth aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the data relationship construction method or data statistics method as described above.

[0034] The data relationship construction method, data statistics method, apparatus, and electronic device provided by this invention construct a correspondence between two data tables by adding a primary key field from one data table to another. As project functions iterate, the primary key substitution reduces the error in data statistics and the loss of data relationships, especially the loss of some transaction data. Attached Figure Description

[0035] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0036] Figure 1 This is a flowchart illustrating the data relationship construction method provided by the present invention;

[0037] Figure 2 This is a schematic diagram illustrating the relationship between the database and the data management library provided by this invention;

[0038] Figure 3 This is a flowchart illustrating the data statistics method provided by the present invention;

[0039] Figure 4 This is a schematic diagram of the data relationship construction device provided by the present invention;

[0040] Figure 5 This is a schematic diagram of the data statistics device provided by the present invention;

[0041] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0043] It should be noted that in the description of the embodiments of the present invention, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. The terms "upper," "lower," etc., indicating orientation or positional relationships are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention. Unless otherwise expressly specified and limited, the terms "installed," "connected," and "linked" should be interpreted broadly, for example, as a fixed connection, a detachable connection, or an integral connection; a mechanical connection or an electrical connection; a direct connection or an indirect connection through an intermediate medium; or a connection within two elements. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0044] A database is a file system used to store data. Data is stored in a specific format, and users can add, modify, delete, and query data in the database.

[0045] According to the data type specified by the table fields, you can fill in a data table with one row of data as a field.

[0046] The following is combined with Figures 1 to 6 This invention describes the data relationship construction method, data statistics method, apparatus, and electronic device provided in the embodiments of the present invention.

[0047] Figure 1 This is a flowchart illustrating the data relationship construction method provided by the present invention, as shown below. Figure 1 As shown, including but not limited to the following steps:

[0048] First, in step S11, redundant fields between the first data table and the second data table are determined.

[0049] Further, in step S12, based on the redundant field, the first primary key field in the first data table is mapped to the second data table to establish a correspondence between the first primary key field and the second primary key field in the second data table; the redundant field is used to establish a non-correspondence relationship between the first data table and the second data table; both the correspondence relationship and the non-correspondence relationship are used for data statistics in the first data table and the second data table.

[0050] In this database, both the first and second data tables belong to the same project. When both tables contain identical fields, these are called redundant fields, indicating a non-corresponding relationship. This non-corresponding relationship creates a large statistical range between the two tables. Later in the project, due to the large volume of data, relying solely on this non-corresponding relationship for statistical analysis can lead to an excessively large statistical range, or the non-corresponding relationship may not be included in the statistics, ultimately resulting in inaccurate data analysis results.

[0051] For example, both of the following data tables have a redundant field M, so there is no corresponding relationship between the first data table and the second data table.

[0052] Let the fields in the first data table include: primary key field A, field B, field C and redundant field M; let the fields in the second data table include: primary key field D, field E, field F and redundant field M.

[0053] The first data table has a total of four fields: the first primary key field A is the primary key field of the first data table; the second data table has a total of four fields: the second primary key field D is the primary key field of the second data table; and the redundant field M is a redundant field between the first data table and the second data table.

[0054] Furthermore, based on the redundant field M, the first primary key field A in the first data table can be mapped to the second data table to establish a correspondence between the first primary key field A and the second primary key field D in the second data table.

[0055] After establishing the correspondence between the first primary key field A and the second primary key field D in the second data table, a small-scale association is established between the first and second data tables. If data statistics are performed according to the correspondence, the statistical range can be accurately determined.

[0056] The first primary key field A in the second data table can be added through a user interface provided by the database management system (DBMS), such as the Structured Query Language (SQL) interface, through which the data stored in the DBMS system can be modified.

[0057] Figure 2 This is a schematic diagram illustrating the relationship between the database and the data management library provided by this invention, as shown below. Figure 2 As shown, a project's database includes a first data table to a Nth data table, totaling N data tables. When a user needs to establish a correspondence between the data tables, they send a statistical command to the database server through the client. The DBMS provides a user interface to locate the first and second data tables in the database and add the first primary key field A from the first data table to the second data table.

[0058] A Database Management System (DBMS) is a large software application used to operate and manage databases. It is used to create, use, and maintain databases, providing unified management and control to ensure database security and integrity. Users access data within tables in the database through the DBMS. DBMSs can store data in various ways and present this data to users in a specific manner. Generally, DBMSs store data using different dimensions, such as using different columns to represent different attributes of the same object, or using different rows to represent information about different objects.

[0059] After establishing the correspondence, the corresponding second data table is obtained. At this point, the fields in the first data table include: the first primary key field A, field B, field C, and field M; while the fields in the corresponding second data table include: the second primary key field D, field E, field F, field M, and the first primary key field A.

[0060] In this context, the first primary key field A in the corresponding second data table is the same as the primary key field in the first data table. At this point, since the first data table and the corresponding second data table have just established a correspondence, the first primary key field A in the corresponding second data table does not yet store any data. The primary key in a data table is used to identify the field of the current record. Since a data table can only have one primary key, when the second data table includes both the first primary key field A and the second primary key field D, the first primary key field A can be considered a foreign key, that is, a pointer to the primary key of another table.

[0061] Later in the project, if a new field G is added to the corresponding second data table, a new second data table is formed. The fields in the new second data table include: second primary key field D, field E, field F, redundant field M, first primary key field A, and field G.

[0062] In the second data table, since the newly added field G is built upon the first primary key field A, and after adding the new field G to the second data table, the data in the first primary key field A in the second data table will be supplemented. Since the first primary key field A is the primary key in the first data table, a correspondence is established between the new field G in the second data table and the first data table. Therefore, any subsequent additions of field G to the second data table will also have a corresponding relationship with the first data table.

[0063] In the corresponding second data table, the original fields, such as field E and field F, still do not correspond to the first data table.

[0064] The data relationship construction method provided by this invention establishes a correspondence between two data tables by adding a primary key field from one data table to another. As project functions iterate, the primary key substitution reduces the error in data statistics and the loss of data relationships, especially reducing the loss of some transaction data.

[0065] Optionally, mapping the first primary key field in the first data table to the second data table based on the redundant field includes:

[0066] Based on the redundant fields in the first data table and the redundant fields in the second data table, and the preset query conditions, the first primary key field in the first data table is mapped to the second data table; the redundant fields are fields common to both data tables in the database; the primary key field is the field that is the primary key field of the data table;

[0067] The preset query conditions are determined based on the relationships between the fields in the first data table and the fields in the second data table.

[0068] A primary key is one or more fields in a table whose values ​​are used to uniquely identify a record in the table.

[0069] Before constructing the mapping relationship, the first data table contains the following fields: primary key fields A, B, and C, and a redundant field M; the second data table contains the following fields: primary key fields D, E, and F, and a redundant field M. Both the first and second data tables contain a redundant field M.

[0070] Based on the redundant field M in the first data table and the redundant field M in the second data table, and a preset query condition, the first primary key field A in the first data table is added to the second data table, completing the mapping of the first primary key field A. At this time, the fields in the first data table include: the first primary key field A, field B, field C, and the redundant field M; the corresponding fields in the second data table include: the second primary key field D, field E, field F, the redundant field M, and the first primary key field A.

[0071] The preset query conditions are determined by the relationships between the first primary key fields A, B, and C, and the redundant field M in the first data table, and the second primary key fields D, E, and F, and the redundant field M in the second data table. These relationships are not directly correlated due to the redundant field M.

[0072] The data relationship construction method provided by this invention makes the statistical range of newly added fields more accurate by constructing a correspondence between two data tables, and effectively avoids the loss of data relationships.

[0073] Optionally, determining redundant fields between the first data table and the second data table includes:

[0074] Retrieve the first data table and the second data table from the database respectively;

[0075] If it is determined that there is a common field between the first data table and the second data table, the common field is obtained and used as a redundant field between the first data table and the second data table;

[0076] The first data table and the second data table are determined based on redundant fields.

[0077] This involves using a DBMS to provide a user interface for manipulating data tables in the database, retrieving the first and second data tables respectively. Based on the non-correspondence between the first and second data tables, a redundant field M can be identified. This non-correspondence arises from the shared redundant field M in both the first and second data tables.

[0078] Currently, data statistics are performed directly based on the relationships between fields in the database.

[0079] Figure 3 This is a flowchart illustrating the data statistics method provided by the present invention, as shown below. Figure 3 As shown, it includes:

[0080] First, in step S31, the target field is determined.

[0081] Specifically, the target fields can be multiple fields determined according to statistical instructions. Statistical instructions can include: the query object, the query range, and the query conditions. The query range can be a specified data table in the database.

[0082] For example, the fields in the first data table include: primary key field A, field B, field C and redundant field M; the fields in the second data table include: primary key field D, field E, field F, redundant field M, primary key field A and field G.

[0083] When users need to perform data statistics, they can determine the second data table by querying the scope, and determine the target fields based on the query object.

[0084] The target field can be field G in the second data table. Since the first primary key field A exists in the second data table, there is a corresponding relationship between field G and the first data table in the database.

[0085] Further, in step S32, based on the correspondence between the first primary key field in the first data table and the second primary key field in the second data table, the target fields in the first data table and the second data table are statistically analyzed; the correspondence between the first primary key field in the first data table and the second primary key field in the second data table is determined based on any of the above data relationship construction methods.

[0086] For example, a query can be performed using SQL query commands. By compiling and running the query commands, the corresponding query results can be generated.

[0087] In the process of compiling query commands, the system directory is used to decompose the query commands into relational algebra expressions; then, database statistics are used to optimize the query, execute rules, and generate code.

[0088] During the execution of the query command, the main database is used to execute the query when the code generated during the compilation process is run, and the query results are obtained.

[0089] For example, the first data table contains device information, and the second data table contains all the device's upgrade records. Since the device has undergone multiple upgrades, and each upgrade generates a large number of upgrade records, if all the logs generated during the upgrade process were put into the database, the database would become very large; the original data did not have a corresponding relationship established in the initial stage of table creation, and only a redundant field M with a relatively large range was used to create a non-corresponding relationship.

[0090] The second primary key field D can be used to store the device's unique code, while the redundant field M can be used to store the device's category, such as small household appliances.

[0091] When a project requires equipment upgrades, useful upgrade information can be extracted from a large number of log entries using the primary key field A, which can then be used by the equipment.

[0092] The data statistics method provided by this invention establishes a correspondence between two data tables by adding a primary key field from one data table to another. As project functions iterate, the primary key substitution reduces the error in data statistics and minimizes the loss of data relationships, especially reducing the loss of some transaction data.

[0093] Optionally, if the association relationship of the target field is a non-corresponding relationship, then after determining the target field, the method further includes:

[0094] Based on the non-correspondence between redundant fields in the first data table and redundant fields in the second data table, and based on preset query conditions, statistics are performed on the target fields in the first data table and the second data table.

[0095] The non-correspondence relationship is constructed based on the redundant fields between the first data table and the second data table.

[0096] The preset query conditions can be any of the following: time, user ID (Identity Document), or enterprise ID.

[0097] Even if the relationship between the target field and the target field is not a direct correspondence, adding a preset query condition can further filter the non-corresponding relationships of the target field, thereby narrowing the statistical range and ultimately obtaining more accurate statistical results.

[0098] Figure 4 This is a schematic diagram of the data relationship construction device provided by the present invention, as shown below. Figure 4 As shown, it includes:

[0099] The first determining module 401 is used to determine redundant fields between the first data table and the second data table;

[0100] The construction module 402 is used to map the first primary key field in the first data table to the second data table based on the redundant fields, so as to construct a correspondence between the first primary key field and the second primary key field in the second data table.

[0101] During the operation of the data relationship construction device, the first determining module 401 determines the redundant fields between the first data table and the second data table; based on the redundant fields, the construction module 402 maps the first primary key field in the first data table to the second data table to construct the correspondence between the first primary key field and the second primary key field in the second data table.

[0102] In this database, both the first and second data tables belong to the same project. When both tables contain identical fields, these are called redundant fields, indicating a non-corresponding relationship. This non-corresponding relationship creates a large statistical range between the two tables. Later in the project, due to the large volume of data, relying solely on this non-corresponding relationship for statistical analysis can lead to an excessively large statistical range, or the non-corresponding relationship may not be included in the statistics, ultimately resulting in inaccurate data analysis results.

[0103] For example, both of the following data tables have a redundant field M, so there is no corresponding relationship between the first data table and the second data table.

[0104] Let the fields in the first data table include: primary key field A, field B, field C and redundant field M; let the fields in the second data table include: primary key field D, field E, field F and redundant field M.

[0105] The first data table has a total of four fields: the first primary key field A is the primary key field of the first data table; the second data table has a total of four fields: the second primary key field D is the primary key field of the second data table; and the redundant field M is a redundant field between the first data table and the second data table.

[0106] Furthermore, based on the redundant field M, the first primary key field A in the first data table can be mapped to the second data table to establish a correspondence between the first primary key field A and the second primary key field D in the second data table.

[0107] After establishing the correspondence between the first primary key field A and the second primary key field D in the second data table, a small-scale association is established between the first and second data tables. If data statistics are performed according to the correspondence, the statistical range can be accurately determined.

[0108] The first primary key field A in the second data table can be added through a user interface provided by the DBMS, such as an SQL interface, through which the data stored in the DBMS system can be modified.

[0109] like Figure 2As shown, a project's database includes a first data table to a Nth data table, totaling N data tables. When a user needs to build relationships between the data tables, they send a statistical command to the database server through the client. The DBMS provides a user interface to find the first and second data tables in the database and add the first primary key field A from the first data table to the second data table.

[0110] A Database Management System (DBMS) is a large software application used to operate and manage databases. It is used to create, use, and maintain databases, providing unified management and control to ensure database security and integrity. Users access data within tables in the database through the DBMS. DBMSs can store data in various ways and present this data to users in a specific manner. Generally, DBMSs store data using different dimensions, such as using different columns to represent different attributes of the same object, or using different rows to represent information about different objects.

[0111] After establishing the correspondence, the corresponding second data table is obtained. At this point, the fields in the first data table include: the first primary key field A, field B, field C, and field M; while the fields in the corresponding second data table include: the second primary key field D, field E, field F, field M, and the first primary key field A.

[0112] In this context, the first primary key field A in the corresponding second data table is the same as the primary key field in the first data table. At this point, since the first data table and the corresponding second data table have just established a correspondence, the first primary key field A in the corresponding second data table does not yet store any data. The primary key in a data table is used to identify the field of the current record. Since a data table can only have one primary key, when the second data table includes both the first primary key field A and the second primary key field D, the first primary key field A can be considered a foreign key, that is, a pointer to the primary key of another table.

[0113] Later in the project, if a new field G is added to the corresponding second data table, a new second data table is formed. The fields in the new second data table include: second primary key field D, field E, field F, redundant field M, first primary key field A, and field G.

[0114] In the second data table, since the newly added field G is built upon the first primary key field A, and after adding the new field G to the second data table, the data in the first primary key field A in the second data table will be supplemented. Since the first primary key field A is the primary key in the first data table, a correspondence is established between the new field G in the second data table and the first data table. Therefore, any subsequent additions of field G to the second data table will also have a corresponding relationship with the first data table.

[0115] In the corresponding second data table, the original fields, such as field E and field F, still do not correspond to the first data table.

[0116] The data relationship building device provided by this invention constructs a correspondence between two data tables by adding a primary key field from one data table to another. As project functions iterate, the primary key substitution reduces the error in data statistics and the loss of data relationships, especially the loss of some transaction data.

[0117] It should be noted that the data relationship construction apparatus provided in this embodiment of the invention can be implemented based on the data relationship construction method described in any of the above embodiments during specific execution, and this embodiment will not elaborate on this.

[0118] Figure 5 This is a schematic diagram of the data statistics device provided by the present invention, as shown below. Figure 5 As shown, the second determining module 501 is used to determine the target field;

[0119] The statistics module 502 is used to perform statistics on the target field in the first data table and the second data table based on the correspondence between the first primary key field in the first data table and the second primary key field in the second data table;

[0120] The correspondence between the first primary key field in the first data table and the second primary key field in the second data table is determined based on any of the data relationship construction methods described above.

[0121] During the operation of the data statistics device, the second determining module 501 determines the target field; the statistics module 502 performs statistics on the target field in the first data table and the second data table based on the correspondence between the first primary key field in the first data table and the second primary key field in the second data table; the correspondence between the first primary key field in the first data table and the second primary key field in the second data table is determined based on any of the data relationship construction methods described above.

[0122] First, the second determination module 501 determines the target field.

[0123] Specifically, the target fields can be multiple fields determined according to statistical instructions. Statistical instructions can include: the query object, the query range, and the query conditions. The query range can be a specified data table in the database.

[0124] For example, the fields in the first data table include: primary key field A, field B, field C and redundant field M; the fields in the second data table include: primary key field D, field E, field F, redundant field M, primary key field A and field G.

[0125] When users need to perform data statistics, they can determine the second data table by querying the scope, and determine the target fields based on the query object.

[0126] The target field can be field G in the second data table. Since the first primary key field A exists in the second data table, there is a corresponding relationship between field G and the first data table in the database.

[0127] Furthermore, the statistics module 502 performs statistics on the target field in the first data table and the second data table based on the correspondence between the first primary key field in the first data table and the second primary key field in the second data table; the correspondence between the first primary key field in the first data table and the second primary key field in the second data table is determined based on any of the above data relationship construction methods.

[0128] For example, a query can be performed using SQL query commands. By compiling and running the query commands, the corresponding query results can be generated.

[0129] In the process of compiling query commands, the system directory is used to decompose the query commands into relational algebra expressions; then, database statistics are used to optimize the query, execute rules, and generate code.

[0130] During the execution of the query command, the main database is used to execute the query when the code generated during the compilation process is run, and the query results are obtained.

[0131] For example, the first data table contains device information, and the second data table contains all the device's upgrade records. Since the device has undergone multiple upgrades, and each upgrade generates a large number of upgrade records, if all the logs generated during the upgrade process were put into the database, the database would become very large; the original data did not have a corresponding relationship established in the initial stage of table creation, and only a redundant field M with a relatively large range was used to create a non-corresponding relationship.

[0132] The second primary key field D can be used to store the device's unique code, while the redundant field M can be used to store the device's category, such as small household appliances.

[0133] When a project requires equipment upgrades, useful upgrade information can be extracted from a large number of log entries using the primary key field A, which can then be used by the equipment.

[0134] The data statistics device provided by this invention establishes a correspondence between two data tables by adding a primary key field from one data table to another. As project functions iterate, the primary key substitution reduces the error in data statistics and the loss of data relationships, especially reducing the loss of some transaction data.

[0135] It should be noted that the data statistics device provided in this embodiment of the invention can be implemented based on the data statistics method described in any of the above embodiments, and this embodiment will not elaborate on this.

[0136] Figure 6 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 6 As shown, the electronic device may include a processor 610, a communications interface 620, a memory 630, and a communication bus 640, wherein the processor 610, communications interface 620, and memory 630 communicate with each other via the communication bus 640. The processor 610 can invoke logical instructions in the memory 630 to execute a data relationship construction method, which includes: determining redundant fields between a first data table and a second data table; mapping a first primary key field in the first data table to the second data table based on the redundant fields to construct a correspondence between the first primary key field and a second primary key field in the second data table; using the redundant fields to construct a non-correspondence relationship between the first and second data tables; and using both the correspondence and non-correspondence relationships for data statistics in the first and second data tables.

[0137] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0138] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, wherein when the program instructions are executed by a computer, the computer is able to execute the data relationship construction method provided by the above methods, the method comprising: determining redundant fields between a first data table and a second data table; based on the redundant fields, mapping a first primary key field in the first data table to the second data table to construct a correspondence between the first primary key field and a second primary key field in the second data table; the redundant fields are used to construct a non-correspondence relationship between the first data table and the second data table; both the correspondence relationship and the non-correspondence relationship are used for data statistics of the first data table and the second data table.

[0139] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements the data relationship construction method provided in the above embodiments. The method includes: determining redundant fields between a first data table and a second data table; mapping a first primary key field in the first data table to the second data table based on the redundant fields to construct a correspondence between the first primary key field and a second primary key field in the second data table; the redundant fields are used to construct a non-correspondence relationship between the first data table and the second data table; both the correspondence relationship and the non-correspondence relationship are used for data statistics on the first data table and the second data table.

[0140] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0141] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0142] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data relationship construction method characterized by, The method comprises: determining a redundant field between a first data table and a second data table; mapping a first primary key field in the first data table to the second data table based on the redundant field to build a correspondence between the first primary key field and a second primary key field in the second data table; the redundant field is used to build a non-correspondence between the first data table and the second data table; the correspondence and the non-correspondence are both used for data statistics of the first data table and the second data table; the mapping of the first primary key field in the first data table to the second data table based on the redundant field comprises: mapping the first primary key field in the first data table to the second data table based on the redundant field in the first data table and the redundant field in the second data table and a preset query condition; the redundant field is a field common to two data tables in a database; the primary key field is a field of the primary key of the data table; the preset query condition is determined based on the association relationship between each field in the first data table and each field in the second data table.

2. The data relationship construction method of claim 1, wherein, The determination of the redundant field between the first data table and the second data table comprises: respectively calling the first data table and the second data table from the database; in the case that there is a common field between the first data table and the second data table, obtaining the common field and taking the common field as the redundant field between the first data table and the second data table; the first data table and the second data table are determined based on the redundant field.

3. A data statistics method, characterized by, The method comprises: determining a target field; based on the correspondence between the first primary key field in the first data table and the second primary key field in the second data table, performing statistics on the target field in the first data table and the second data table; the correspondence between the first primary key field in the first data table and the second primary key field in the second data table is determined based on the data relationship building method of claim 1 or 2.

4. The data statistical method according to claim 3, wherein, If the association relationship of the target field is a non-correspondence, after the determination of the target field, it further comprises: based on the non-correspondence between the redundant field in the first data table and the redundant field in the second data table and a preset query condition, performing statistics on the target field in the first data table and the second data table; the non-correspondence is built based on the redundant field between the first data table and the second data table.

5. The data statistical method according to claim 4, characterized in that, The preset query condition comprises any one of the following query conditions: time, user identification number or enterprise identification number.

6. A data relationship construction apparatus applied to the data relationship construction method according to claim 1 or 2, characterized by The method comprises: a first determination module for determining a redundant field between a first data table and a second data table; a building module for mapping a first primary key field in the first data table to the second data table based on the redundant field to build a correspondence between the first primary key field and a second primary key field in the second data table; the redundant field is used to build a non-correspondence between the first data table and the second data table; The correspondence relationship and the non-correspondence relationship are both used for data statistics of the first data table and the second data table.

7. A data statistics apparatus characterized by comprising: Comprise: A second determining module, configured to determine a target field; A statistics module, configured to perform statistics on the target field in the first data table and the second data table based on a correspondence relationship between a first primary key field in the first data table and a second primary key field in the second data table; The correspondence relationship between the first primary key field in the first data table and the second primary key field in the second data table is determined based on the data relationship construction method in claim 1 or 2.

8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the steps of the data relationship construction method in claim 1 or 2, or the data statistics method in claims 3 to 5. 9.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the data relationship construction method in claim 1 or 2, or the data statistics method in claims 3 to 5.

Citation Information

Patent Citations

  • Method and system for automatically generating table data

    CN111309734A

  • Data query method, device and equipment and auxiliary data query method, device and equipment

    CN111538747A