A method and device for extracting table objects

By judging and updating the source table to be processed, table object extraction is performed on source tables where no foreign keys exist, and whether there is a foreign key table in the processed source table, it solves the problem that the foreign key table cannot be extracted when the primary key table corresponding to the foreign key does not exist, and achieves the smooth extraction of table objects.

CN114595229BActive Publication Date: 2025-03-25SUNINFO INFORMATION TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210247699.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-14
Publication Date
2025-03-25
Estimated Expiration
2042-03-14

AI Technical Summary

Technical Problem

In the prior art, when the primary key table corresponding to a foreign key does not exist, the foreign key table cannot be extracted using the normal table object extraction method.

Method used

By determining whether there are foreign keys in the source table to be processed, the source table to be processed is updated according to the judgment results, the table object extraction process is performed on the source table where there is no foreign key, and whether there is a foreign key table in the processed source table. If so, the table object extraction process is performed on the foreign key table.

Benefits of technology

It realizes that during the database object extraction process, the table object can still be extracted smoothly when the primary key table corresponding to the foreign key does not exist, solving the problem that traditional methods cannot extract foreign key tables normally.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114595229B_ABST
    Figure CN114595229B_ABST
Patent Text Reader

Abstract

The purpose of this application is to provide a method and device for extracting table objects. This application determines whether a source table to be processed has a foreign key based on the calling mode of the source table to be processed, and obtains a determination result; updates the source table to be processed according to the determination result; performs table object extraction processing on the source table without a foreign key to obtain a processed source table; determines whether the processed source table has a foreign key table, and if so, performs table object extraction processing on the foreign key table. Thus, when the primary key table corresponding to the foreign key does not exist during the database object extraction process, the table object can still be extracted smoothly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a method and device for extracting table objects. Background Art

[0002] At present, with the widespread use of database technology, databases are also used by more and more users. Database extraction functions are also widely used. How to realize the extraction of database objects has become an important part of the extraction function. The extraction of table objects in object extraction is the basic premise of object extraction. How to correctly and effectively extract table objects has become an important foundation for database object extraction. The traditional database table object extraction directly obtains the SQL of the database table object and then creates the table. When the table object has a primary and foreign key relationship, it cannot extract the foreign key table normally. Summary of the invention

[0003] One purpose of the present application is to provide a method and device for extracting table objects, so as to solve the problem in the prior art that when the primary key table corresponding to the foreign key does not exist, the foreign key table cannot be extracted using the ordinary table object extraction method.

[0004] According to one aspect of the present application, a method for extracting a table object is provided, the method comprising:

[0005] Based on the calling mode of the source table to be processed, it is determined whether the source table to be processed has a foreign key, and a determination result is obtained;

[0006] Performing update processing on the source table to be processed according to the judgment result;

[0007] Perform table object extraction processing on the source table without foreign keys to obtain the processed source table;

[0008] It is determined whether the processed source table has a foreign key table. If so, table object extraction is performed on the foreign key table.

[0009] Optionally, updating the to-be-processed source table according to the judgment result includes:

[0010] Determine a source table without foreign keys and a source table with foreign keys according to the judgment result;

[0011] The primary key table corresponding to the foreign key in the source table with the foreign key is used as the source table to be processed to update the source table to be processed.

[0012] Optionally, taking the primary key table corresponding to the foreign key in the source table having the foreign key as the source table to be processed to update the source table to be processed includes:

[0013] Adding a first tag to the primary key table;

[0014] The primary key table marked by the first mark is used as a source table to be processed, so as to update the source table to be processed.

[0015] Optionally, performing table object extraction processing on a source table without a foreign key includes:

[0016] Extract table objects from source tables where foreign keys do not exist into the target database.

[0017] Optionally, extract table objects from the source table that do not have foreign keys to the target database, including:

[0018] Determine the SQL statement for the source table where the foreign key does not exist;

[0019] The SQL statement is executed in the target database to create a table object in the target database.

[0020] Optionally, determining whether the processed source table has a foreign key table includes any of the following methods:

[0021] By obtaining the foreign key table through the application program interface, it is determined whether the processed source table has a foreign key table;

[0022] By querying SQL statements, it is determined whether the processed source table has a foreign key table.

[0023] Optionally, the method further comprises:

[0024] It is determined whether the processed source table has a foreign key table. If not, the processed source table is not processed.

[0025] Optionally, after extracting the table object from the foreign key table, the method further includes:

[0026] Adding a second mark to the foreign key table after the table object extraction process;

[0027] The foreign key table marked by the second mark is used as a processed source table, and the update process of the processed source table is completed.

[0028] According to another aspect of the present application, a device for extracting a table object is also provided, the device comprising:

[0029] A data analysis module is used to determine whether a foreign key exists in the source table to be processed based on the calling mode of the source table to be processed, and obtain a determination result;

[0030] A logic module, used for updating the source table to be processed according to the judgment result;

[0031] A first table object extraction module is used to perform table object extraction processing on a source table without a foreign key to obtain a processed source table;

[0032] The second table object extraction module is used to determine whether the processed source table has a foreign key table, and if so, perform table object extraction processing on the foreign key table.

[0033] According to yet another aspect of the present application, a computer-readable medium is provided, on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement any of the methods described above.

[0034] According to another aspect of the present application, a device for extracting a table object is also provided, the device comprising:

[0035] one or more processors; and

[0036] A memory storing computer readable instructions, which, when executed, cause the processor to perform the operations of any of the methods described above.

[0037] Compared with the prior art, the present application obtains a judgment result by determining whether the source table to be processed has a foreign key; updates the source table to be processed according to the judgment result; performs table object extraction on the source table without a foreign key to obtain a processed source table; determines whether the processed source table has a foreign key table, and if so, performs table object extraction on the foreign key table. Thus, when the primary key table corresponding to the foreign key does not exist during the database object extraction process, the table object can still be extracted smoothly. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0039] Figure 1 A schematic flow chart of a method for extracting table objects according to one aspect of the present application is shown;

[0040] Figure 2 A schematic flow chart of a method for extracting table objects in an optional embodiment of the present application is shown;

[0041] Figure 3 A schematic diagram of a device framework structure for extracting table objects provided according to another aspect of the present application is shown.

[0042] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION

[0043] The present application is described in further detail below in conjunction with the accompanying drawings.

[0044] In a typical configuration of the present application, the terminal, the device of the service network and the trusted party all include one or more processors (CPU), input / output interfaces, network interfaces and memories.

[0045] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0046] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory media such as modulated data signals and carrier waves.

[0047] Figure 1 A schematic flow chart of a method for extracting table objects according to one aspect of the present application is shown, the method comprising: S100 to S400, wherein in S100, judging whether the source table to be processed has a foreign key based on the calling mode of the source table to be processed, and obtaining a judgment result; in S200, updating the source table to be processed according to the judgment result; in S300, performing table object extraction processing on the source table without a foreign key to obtain a processed source table; in S400, judging whether the processed source table has a foreign key table, and if so, performing table object extraction processing on the foreign key table. Thus, when the primary key table corresponding to the foreign key does not exist during the database object extraction process, the table object can still be extracted smoothly.

[0048] Continuing with the above embodiment, in S100, it is determined whether the source table to be processed has a foreign key based on the way the source table to be processed is called, and a judgment result is obtained. Here, the primary-foreign key relationship in the source table to be processed is determined based on the way the source table to be processed is called by the database to determine whether a foreign key exists, and a judgment result is obtained. In an optional embodiment of the present application, the called method includes but is not limited to an API call method through a database JDBC connection, that is, it is determined whether the source table to be processed has a foreign key through an API call method through a database JDBC connection.

[0049] In S200, the source table to be processed is updated according to the judgment result. Here, the judgment result can determine the source table with foreign keys and the source table without foreign keys, and then the source table to be processed is updated according to different source tables to ensure that the primary key tables corresponding to all foreign keys are subjected to foreign key judgment processing, and ensure that all table objects can be extracted successfully.

[0050] In S300, table object extraction is performed on the source table without foreign keys to obtain a processed source table. Here, when the source table to be processed does not have foreign keys, SQL statements of table objects in the source table without foreign keys can be extracted to obtain a source table after table object extraction.

[0051] In S400, it is determined whether the processed source table has a foreign key table. If so, table object extraction is performed on the foreign key table. Here, it is determined whether the source table after the table object extraction is a foreign key table. If so, table object extraction is performed on the foreign key table, so that all foreign key tables are created. In this way, when the primary key table corresponding to the foreign key does not exist during the database object extraction process, the table object can still be extracted smoothly.

[0052] In an optional embodiment of the present application, in S200, source tables without foreign keys and source tables with foreign keys are determined according to the judgment result; the primary key table corresponding to the foreign keys in the source table with foreign keys is used as the source table to be processed to update the source table to be processed. Here, when the source table to be processed has foreign keys, the primary key table corresponding to the foreign keys in the source table to be processed can be used as a new source table to be processed, and it is re-determined whether there are foreign keys inside the primary key table, and recursively determined whether there are foreign keys in the primary key table corresponding to each foreign key. If there are no foreign keys, the table object is extracted from the primary key table, thereby ensuring that all table objects can be extracted successfully.

[0053] In an optional embodiment of the present application, in S200, a first mark is added to the primary key table; the primary key table marked by the first mark is used as a source table to be processed to update the source table to be processed. Here, the first mark is used to identify the primary key table so as to accurately and efficiently update the source table to be processed, and so on to determine whether there are foreign keys in all primary key tables.

[0054] In an optional embodiment of the present application, in S300, a table object in a source table without a foreign key is extracted into a target database. Here, a table object in a source table without a foreign key is extracted into a target database, so that an SQL statement of the table object is executed in the target database, and a table object is created in the target database.

[0055] In an optional embodiment of the present application, in S300, an SQL statement of a source table without a foreign key is determined; the SQL statement is executed in the target database to create a table object in the target database. Here, an SQL statement of a source table without a foreign key is determined, and the SQL statement is executed in the target database to create a table object in the target database. Thus, the integrity of the table structure is ensured, so that data operations and data extraction of the table object can be implemented subsequently.

[0056] In an optional embodiment of the present application, in S400, determining whether the processed source table has a foreign key table can be any of the following methods: determining whether the processed source table has a foreign key table by obtaining the foreign key table through an application program interface; or determining whether the processed source table has a foreign key table by querying an SQL statement. Here, the foreign key table can be obtained through an application program interface (API) to determine whether the processed source table has a foreign key table; or the foreign key table can be determined by querying an SQL statement.

[0057] In an optional embodiment of the present application, after the table object extraction process is performed on the foreign key table, it is determined whether the processed source table has a foreign key table. If not, the processed source table is not processed. Here, the data analysis module 100 can be used to determine whether the processed source table has a foreign key table. If not, the processed source table is not processed, and all table objects in the processed source table have been extracted.

[0058] In an optional embodiment of the present application, a second tag is added to the foreign key table after the table object extraction process; the foreign key table marked by the second tag is used as the processed source table, and the update process of the processed source table is completed. Here, the second table object extraction module 400 can be used to add a second tag to the foreign key table after the table object extraction process, so as to use the second tag to identify all the foreign key tables after the table object extraction process, and then the foreign key table marked by the second tag is used as the processed source table, and the processed source table is updated to further determine whether the foreign key table marked by the second tag exists as a foreign key table, and so on to create all foreign key tables.

[0059] In an optional embodiment of the present application, in an actual application scenario, the foreign key a of table A is associated with table B, and the foreign key b of table B is associated with table C. The creation process is as follows: first obtain the primary and foreign key relationship and SQL statement of table A, then the primary key table corresponding to the foreign key a of table A is table B, use the first identifier to mark table B, then obtain the primary and foreign key relationship and SQL statement of table B under the first identifier, then the primary key table corresponding to the foreign key b of table B is table C, then use the first identifier to mark table C, obtain the association relationship and SQL statement of table C under the first identifier, because there is no table associated with the foreign key in table C, then execute the SQL statement of table C to the target library, after the object of table C is extracted, use the second identifier to mark table B, execute the SQL statement corresponding to table B marked by the second identifier to the target library, after the object of table B is extracted, use the second identifier to mark its foreign key table A, and then execute the SQL statement corresponding to table A marked by the second identifier to the target library, after table A is executed, since table A has no foreign key table, the table object extraction is completed. Thereby, when the primary key table corresponding to the foreign key does not exist during the database object extraction process, the table object can still be extracted smoothly.

[0060] Figure 2 A schematic flow chart of a method for extracting a table object in an optional embodiment of the present application is shown, in which the primary and foreign key relationship of the source table and the SQL statement of the source table are obtained, and whether the source table object has been extracted is determined by determining whether the source table has a foreign key. If no foreign key exists, the table object is created by extracting the SQL statement of the source table. If a foreign key exists, the primary and foreign key relationship and SQL statement of the primary key table corresponding to the foreign key are obtained, and so on, until there is no primary key table corresponding to the foreign key.

[0061] Specifically, the primary and foreign key relationship of the source table is determined and the SQL statement of the source table is obtained to determine whether the source table has a foreign key. If the source table has a foreign key, the SQL statement of the primary key table corresponding to the foreign key is obtained and the primary key table corresponding to the foreign key is marked as a new source table. Then it is determined whether the new source table has a foreign key relationship. If it exists, the foreign key determination and new marking processing are performed on the new source table, and so on, until no new source table is generated.

[0062] Continuing with the above embodiment, when the source table does not have a foreign key, the table object of the source table is directly extracted to the target database, for example, the SQL statement of the source table object is extracted, and then the SQL statement of the source table object is executed in the target database to create the table object in the target database, thereby ensuring the integrity of the table structure, so as to subsequently implement data operations and data extraction of the table object. Then, it is determined whether the source table has a foreign key table, for example, the foreign key table of the source table can be obtained through the API interface of the database JDBC driver or the table is queried through the SQL statement to see whether the foreign key table exists. If the source table has a foreign key table, the foreign key table is marked as the source table, and the table object of the foreign key table is extracted to the target database, and it is determined whether the foreign key table after the table object is extracted has a corresponding foreign key table, and so on, until all foreign key tables are created. Thus, according to the primary and foreign key relationships, the primary key table is first created, and then the foreign key table is created, and all primary and foreign key relationships are created by analogy, thereby solving the problem that the primary key table corresponding to the foreign key does not exist and the table object cannot be extracted.

[0063] The embodiment of the present application further provides a computer-readable medium on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement the aforementioned method for extracting table objects.

[0064] Corresponding to the method described above, the present application also provides a terminal, which includes a terminal capable of executing the above Figure 1 or Figure 2 The modules or units of the method steps described in each embodiment may be implemented by hardware, software or a combination of hardware and software, which is not limited by the present application. For example, in one embodiment of the present application, a device for extracting a table object is also provided, wherein the device includes:

[0065] one or more processors; and

[0066] A memory storing computer readable instructions, which, when executed, cause the processor to perform the operations of the aforementioned method for extracting table objects.

[0067] For example, the computer readable instructions, when executed, cause the one or more processors to:

[0068] Based on the calling mode of the source table to be processed, it is judged whether the source table to be processed has a foreign key, and a judgment result is obtained; the source table to be processed is updated according to the judgment result; table object extraction is performed on the source table without foreign keys to obtain a processed source table; it is judged whether the processed source table has a foreign key table, and if so, table object extraction is performed on the foreign key table.

[0069] Figure 3A schematic diagram of the framework structure of a device for extracting table objects provided according to another aspect of the present application is shown, and the device includes: a data analysis module 100, which is used to determine whether a source table to be processed has a foreign key based on the calling mode of the source table to be processed, and obtain a determination result; a logic module 200, which is used to update the source table to be processed according to the determination result; a first table object extraction module 300, which is used to perform table object extraction processing on a source table that does not have a foreign key, and obtain a processed source table; a second table object extraction module 400, which is used to determine whether a foreign key table exists in the processed source table, and if so, perform table object extraction processing on the foreign key table. Thus, when the primary key table corresponding to the foreign key does not exist during the database object extraction process, the table object can still be extracted smoothly.

[0070] It should be noted that the contents executed by the data analysis module 100, the logic module 200, the first table object extraction module 300 and the second table object extraction module 400 are respectively the same or correspondingly the same as the contents in the above steps S100, S200, S300 and S400, and are not repeated here for the sake of brevity.

[0071] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

[0072] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present application can be executed by a processor to implement the steps or functions described above. Similarly, the software program of the present application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.

[0073] In addition, a part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. The program instruction for calling the method of the present application may be stored in a fixed or removable recording medium, and / or transmitted through a data stream in a broadcast or other signal-bearing medium, and / or stored in a working memory of a computer device that runs according to the program instruction. Here, according to an embodiment of the present application, a device is included, the device including a memory for storing computer program instructions and a processor for executing program instructions, wherein, when the computer program instruction is executed by the processor, the device is triggered to run the method and / or technical solution based on the aforementioned multiple embodiments according to the present application.

[0074] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is limited by the attached claims rather than the above description, so it is intended to include all changes that fall within the meaning and scope of the equivalent elements of the claims in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

Claims

1. A method for extracting a table object, wherein: The method comprises: Based on the calling mode of the source table to be processed, it is determined whether the source table to be processed has a foreign key, and a determination result is obtained; Performing update processing on the source table to be processed according to the judgment result; Perform table object extraction processing on the source table without foreign keys to obtain the processed source table; Determine whether the processed source table has a foreign key table, and if so, perform table object extraction on the foreign key table; The updating of the source table to be processed according to the judgment result includes: Determine a source table without foreign keys and a source table with foreign keys according to the judgment result; Taking the primary key table corresponding to the foreign key in the source table where the foreign key exists as the source table to be processed to update the source table to be processed; Wherein, taking the primary key table corresponding to the foreign key in the source table having the foreign key as the source table to be processed to update the source table to be processed includes: Adding a first tag to the primary key table; The primary key table marked by the first mark is used as a source table to be processed, so as to update the source table to be processed.

2. The method according to claim 1, wherein: The performing table object extraction processing on the source table without foreign keys includes: Extract table objects from source tables where foreign keys do not exist into the target database.

3. The method according to claim 2, wherein: Extract table objects from the source table that do not have foreign keys to the target database, including: Determine the SQL statement for the source table where the foreign key does not exist; The SQL statement is executed in the target database to create a table object in the target database.

4. The method according to claim 1, wherein: Determining whether the processed source table has a foreign key table includes any of the following methods: By obtaining the foreign key table through the application program interface, it is determined whether the processed source table has a foreign key table; By querying SQL statements, it is determined whether the processed source table has a foreign key table.

5. The method according to claim 1, wherein: The method further comprises: It is determined whether the processed source table has a foreign key table. If not, the processed source table is not processed.

6. The method according to claim 1, wherein: After the table object extraction process is performed on the foreign key table, the method further includes: Adding a second mark to the foreign key table after the table object extraction process; The foreign key table marked by the second mark is used as a processed source table, and the update process of the processed source table is completed.

7. A device for extracting a table object, wherein: The device comprises: A data analysis module is used to determine whether a foreign key exists in the source table to be processed based on the calling mode of the source table to be processed, and obtain a determination result; A logic module, used for updating the source table to be processed according to the judgment result; A first table object extraction module is used to perform table object extraction processing on a source table without a foreign key to obtain a processed source table; A second table object extraction module is used to determine whether the processed source table has a foreign key table, and if so, perform table object extraction processing on the foreign key table; Wherein, the logic module is used for: Determine a source table without foreign keys and a source table with foreign keys according to the judgment result; Taking the primary key table corresponding to the foreign key in the source table where the foreign key exists as the source table to be processed to update the source table to be processed; Wherein, the logic module is used for: Adding a first tag to the primary key table; The primary key table marked by the first mark is used as a source table to be processed, so as to update the source table to be processed.

8. A computer-readable medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the method according to any one of claims 1 to 6.

9. A device for extracting a table object, wherein: The device comprises: one or more processors; and A memory storing computer readable instructions which, when executed, cause the processor to perform the operations of the method as claimed in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Data synchronization method and device

    CN106933823A