Method, device and equipment for generating wide table and storage medium
By parsing database statement information to determine the relationships between tables and generating wide tables, the problem of wasted database storage resources caused by the repeated creation of wide tables in existing technologies is solved, and database query efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE GROUP ANHUI
- Filing Date
- 2021-04-22
- Publication Date
- 2026-04-28
AI Technical Summary
Existing wide table generation methods result in duplicate wide tables, leading to a waste of database storage resources.
By parsing the database statement information, the target database cache table for the inter-table relationships is determined, and the inter-table relationship records are updated according to the target database cache table to generate a wide table.
This avoids the repeated creation of wide tables, reduces the waste of database storage resources, and improves database query efficiency.
Smart Images

Figure CN115237903B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of data processing, and in particular relates to a method, apparatus, device and storage medium for generating wide tables. Background Technology
[0002] With the rapid development of the internet, enterprises are increasingly valuing data and conducting extensive data analysis and mining to identify target customers and understand their business development. Wide tables can integrate data from different levels, reduce multi-table queries, and improve data analysis efficiency. However, wide tables generated using existing methods often contain duplicates, leading to a waste of database storage resources. Summary of the Invention
[0003] This application provides a method, apparatus, device, and storage medium for generating wide tables, which can solve the problem that existing wide table generation methods generate duplicate wide tables, resulting in wasted database storage resources.
[0004] In a first aspect, embodiments of this application provide a method for generating a wide table, the method comprising:
[0005] Retrieves the database access record table and database cache table for database objects with the same database object; the database access record table includes information about executed database statements; the database cache table includes records of inter-table relationships.
[0006] Parse the executed database statement information to obtain the statement segments included in the executed database statement information, as well as the information type of the statement segments;
[0007] When the information type is the first preset type, the target database cache table with inter-table relationships is determined from the database cache table according to the statement segment;
[0008] The wide table is obtained by updating the inter-table relationship records based on the target database cache table.
[0009] Furthermore, in one embodiment, the method further includes:
[0010] When the information type is the second preset type, the database cache table is updated according to the statement segment to obtain a wide table.
[0011] Further, in one embodiment, determining the target database cache table with inter-table relationships from the database cache table based on the statement segment includes:
[0012] Parse the statement segment to obtain a multi-level nested statement segment that conforms to the first preset type;
[0013] Based on the preset naming conventions, the table name and its corresponding table alias, field name and its corresponding field alias are identified from multi-level nested statement segments;
[0014] The target database cache table is determined from the database cache tables based on the table name, table alias, field name, and field alias.
[0015] Furthermore, in one embodiment, a wide table is obtained by updating the inter-table relationship records according to the target database cache table, including:
[0016] Add the target database cache table that is not recorded in the inter-table relationship record to the inter-table relationship record to obtain a wide table.
[0017] Furthermore, in one embodiment, the method further includes:
[0018] Count the number of times the target database cache table is traversed within a preset time period;
[0019] The target database cache table is deleted when the number of times it is traversed is less than a preset threshold.
[0020] Furthermore, in one embodiment, the method further includes:
[0021] Replace the table alias and field alias of the target database cache table records with the table name corresponding to the table alias and the field name corresponding to the field alias, respectively.
[0022] Secondly, embodiments of this application provide a wide table generation apparatus, the apparatus comprising:
[0023] The acquisition module is used to retrieve the database access record table and the database cache table for database objects with the same database object; the database access record table includes information about the executed database statements; the database cache table includes records of inter-table relationships.
[0024] The parsing module is used to parse the executed database statement information to obtain the statement segments included in the executed database statement information, as well as the information type of the statement segments;
[0025] The determination module is used to determine the target database cache table with inter-table relationships from the database cache table based on the statement segment when the information type is the first preset type.
[0026] The update module is used to update the inter-table relationship records based on the target database cache table to obtain a wide table.
[0027] Furthermore, in one embodiment, the update module is also used to:
[0028] When the information type is the second preset type, the database cache table is updated according to the statement segment to obtain a wide table.
[0029] Furthermore, in one embodiment, the determining module is specifically used for:
[0030] Parse the statement segment to obtain a multi-level nested statement segment that conforms to the first preset type;
[0031] Based on the preset naming conventions, the table name and its corresponding table alias, field name and its corresponding field alias are identified from multi-level nested statement segments;
[0032] The target database cache table is determined from the database cache tables based on the table name, table alias, field name, and field alias.
[0033] Furthermore, in one embodiment, the update module is specifically used for:
[0034] Add the target database cache table that is not recorded in the inter-table relationship record to the inter-table relationship record to obtain a wide table.
[0035] Thirdly, embodiments of this application provide a wide table generation apparatus, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the wide table generation method described above.
[0036] Fourthly, embodiments of this application provide a computer-readable storage medium storing an information transmission implementation program, which, when executed by a processor, implements the aforementioned wide table generation method.
[0037] The wide table generation method, apparatus, device, and storage medium of this application embodiment can determine the target database cache table with inter-table relationships based on the database access record table, and then update the inter-table relationship records based on the target database cache table to obtain the wide table. Since the target database cache table is updated based on the inter-table relationship records, the wide table will not be duplicated. Attached Figure Description
[0038] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 This is a schematic diagram of the architecture of a wide table generation system provided in an embodiment of this application;
[0040] Figure 2 This is a flowchart illustrating a method for generating a wide table according to an embodiment of this application;
[0041] Figure 3 This is a schematic diagram of the structure of a wide table generation device provided in an embodiment of this application;
[0042] Figure 4 This is a schematic diagram of the structure of a wide table generation device provided in an embodiment of this application. Detailed Implementation
[0043] The features and exemplary embodiments of various aspects of this application will now be described in detail. To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain this application and are not configured to limit this application. For those skilled in the art, this application can be implemented without some of these specific details. The following description of the embodiments is merely to provide a better understanding of this application by illustrating examples of this application.
[0044] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0045] Currently, wide tables are typically generated manually or by creating them according to a theme. Existing methods generally have the following drawbacks: 1. They do not perform query joins on existing wide tables, easily leading to the creation of similar or duplicate wide tables, resulting in wasted database storage resources; 2. They do not consider the actual usage of wide tables, resulting in low effective utilization but high database resource consumption; 3. There is no deletion mechanism after wide tables are created; only new wide tables are created without deleting unused ones, leading to a gradual decline in the effective utilization of database resources.
[0046] To address the problems of existing technologies, embodiments of this application provide a method, apparatus, device, and storage medium for generating wide tables. Embodiments of this application can determine a target database cache table with inter-table relationships based on a database access record table, and then update the inter-table relationship records based on the target database cache table to obtain a wide table. Since the target database cache table is updated based on the inter-table relationship records, the wide table is not repeatedly created, thus avoiding additional performance overhead for the database. The wide table generation system provided in this application embodiment is described below.
[0047] Figure 1 A schematic diagram of the architecture of a wide table generation system provided in one embodiment of this application is shown.
[0048] like Figure 1 As shown, the system may include:
[0049] Client, server, and database server;
[0050] The client includes a connection unit. The server includes a distribution unit, a logging unit, a parsing unit, a basic dictionary unit, an association strategy unit, a wide table creation unit, a post-evaluation unit, a wide table deletion unit, and a database scheduling unit.
[0051] The connection unit connects to the server and is used to obtain database requests from users or applications, transmit them to the server, and provide feedback to users or applications on the database processing results returned by the server.
[0052] The distribution unit, connected to the connection unit, log unit, and database scheduling unit respectively, is used to distribute and parse database requests. On the one hand, it receives database requests transmitted by the connection unit and transmits the requests to the corresponding databases according to the IP and port; on the other hand, it parses the database requests and records the relevant content to the log unit.
[0053] The log unit, connected to the distribution unit, parsing unit, and post-evaluation unit respectively, is used to store database access records.
[0054] The basic dictionary unit, connected to the parsing unit, wide table deletion unit, wide table creation unit, post-evaluation unit, and database scheduling unit, is used to store information related to tables and fields within the database. The information comes from two sources: first, the dictionary is updated during the creation and deletion of wide tables in the self-processing system; second, the backend maintenance personnel can manually trigger the database scheduling unit to retrieve the original table information from the database to handle initialization situations.
[0055] The association strategy unit is connected to both the parsing unit and the wide table creation unit, and is used to store the association relationship between the two tables parsed by the parsing unit.
[0056] The wide table creation unit is connected to the basic dictionary unit, the association strategy unit, and the database scheduling unit, respectively.
[0057] The post-evaluation unit is connected to the log unit, the basic dictionary unit, and the wide table deletion unit.
[0058] The wide table deletion unit is connected to the post-evaluation unit, the basic dictionary unit, and the database scheduling unit, respectively.
[0059] The parsing unit automatically retrieves successfully executed SQL statements from the log unit within a preset statistical period, analyzes and determines the relationships between tables, and records them in the association strategy unit. Statistical parsing can also be manually triggered, with the required statistical period set.
[0060] The above describes the wide table generation system provided in the embodiments of this application. The wide table generation method provided in the embodiments of this application will be described below.
[0061] Figure 2 A flowchart illustrating a method for generating a wide table according to an embodiment of this application is shown.
[0062] like Figure 2 As shown, the method may include the following steps:
[0063] S210: Retrieve the database access record table and database cache table that are identical to the database object.
[0064] The database access record table includes information about executed database statements; the database cache table includes records of relationships between tables.
[0065] The database access record table stores database access records. Its storage format can be shown in Table 1. In the table, the timestamp field is the timestamp, the source_ip field is the IP of the client that initiated the operation, the user field is the username, the DB_ip_port field is the database IP and port, the DB_object field is the database object being operated on, the DB_sql field is the database statement being executed, and the state field is the result of the database execution, with 'T' indicating successful execution and 'F' indicating failed execution.
[0066]
[0067] Table 1
[0068] The database cache table stores information about tables and fields within the database. This information comes from two sources: firstly, the dictionary is updated during the creation and deletion of wide tables in the self-processing system; secondly, backend maintenance personnel can manually trigger the process by retrieving the original table information from the database through the database scheduling unit to handle initialization situations.
[0069] The storage format of the database cache table can be as shown in Table 2. The fields DB_object, DB_table, and DB_owner are the database name, table name, and table owner (i.e., the database username that created the table). R_no is the association code, representing the association strategy used for wide table creation; this field is empty if the table is not wide. DB_field contains the table's fields and their sources. The field source records the fields renamed during wide table creation, along with their original names, stored as strings in the format "<field1, original name1>; <field1, original name1>…". The field R_no is the association code, which is auto-incrementing and uniquely identifies the table association; DB_o is the database name of the operation; the field DB_t1 is the table name of table 1; the field DB_t2 is the table name of table 2; the field Field1 is the field name involved in the association query of table 1; the field Field2 is the field name involved in the association query of table 2; the field Relation is the association between the two tables; and the field Frequency is the frequency of the association between the two tables within the statistical period.
[0070]
[0071] Table 2
[0072] S220, parse the executed database statement information to obtain the statement segments included in the executed database statement information, as well as the information type of the statement segments.
[0073] The executed database statement information can be Structured Query Language (SQL); the executed database statement information is the database access record whose execution result (state) is successful (T) within the preset statistical period.
[0074] When determining the information type of a statement segment, the statement type can be determined based on the first word of the statement segment.
[0075] S230, when the information type is the first preset type, determine the target database cache table with inter-table relationships from the database cache table according to the statement segment.
[0076] The first preset type can include: "create", "update", "insert", or "select" statements.
[0077] In one embodiment, S230 may include:
[0078] Parse the statement segment to obtain a multi-level nested statement segment that conforms to the first preset type.
[0079] Multi-level nested statement segments can be determined through the following steps: Starting with the first SELECT statement in the segment, traverse the segment character by character. When the number of right parentheses equals the number of left parentheses plus one, extract the content from the first SELECT statement to the last right parenthesis as the SELECT statement. If there is no case where the number of right parentheses equals the number of left parentheses plus one until the end of the statement, then extract the content from the first SELECT statement to the end of the statement as a single SELECT statement. Assign the original statement to the O_sql field of the original statement, and assign the extracted SELECT statement to the N_sql field of the nested statement. Use the N_sql field after assignment as the judgment content, and determine whether the N_sql field contains the second SELECT field according to the above judgment process, until the N_sql field does not contain the SELECT field, thus obtaining the multi-level nested statement segment.
[0080] Based on preset naming conventions, the table name and its corresponding table alias, field name and its corresponding field alias are identified from multi-level nested statement segments.
[0081] The default naming convention can be SQL92. During recognition, it first checks whether there is a comma or a join field after the from field in a multi-level nested statement segment. If so, it uses the alias as the key and the original name as the value to identify the table name and its corresponding table alias, as well as the field name and its corresponding field alias. If not, it only identifies the table name and field name.
[0082] The target database cache table is determined from the database cache tables based on the table name, table alias, field name, and field alias.
[0083] When determining the target database cache table, fields and field aliases fall into two categories. One category involves fields or aliases that directly indicate their parent table; in this case, the parent table is directly identified as the target database cache table. The other category involves fields or aliases that do not directly indicate their parent table; in this case, the field or alias needs to be compared against information in the database cache table, and the table in the database cache table that records the field or alias is identified as the target database cache table.
[0084] S240: Update the inter-table relationship records based on the target database cache table to obtain a wide table.
[0085] In one embodiment, S240 may include:
[0086] Add the target database cache table that is not recorded in the inter-table relationship record to the inter-table relationship record to obtain a wide table.
[0087] When the records of the inter-table relationships are updated, if the table records R_no in the basic dictionary unit corresponding to the two related tables are not empty, then the parsed related records of the wide table are replaced with the related records of its original table by combining the table field and original field name DB_field in the basic dictionary unit, and the related records of the wide table in the relationship strategy unit (using R_no matching).
[0088] Record the two related tables in one join strategy. Separate the table query fields and the join relationship between the two tables into long strings, each separated by a semicolon. Update the corresponding join record in the join strategy unit. Sort the two related tables in ascending order by table name. In the join strategy unit, check if a join record exists for these two tables based on the DB_o, DB_t1, and DB_t2 fields. If it doesn't exist, store the database object name in DB_o, the table name and query fields of table 1 in DB_t1 and the Field1 field, the table name and query fields of table 2 in DB_t2 and the Field2 field, and the join relationship between the two tables in the Relation field, setting Frequency to 1. If it already exists, take the intersection of the Relation fields of the two records. If the intersection is empty, still treat it as adding a new join record. If the intersection is not empty, update the existing record, take the union of the Field1 and Field2 records, take the intersection of the Relation fields of the two records, and increment Frequency by 1. Associate the parsed table name with the corresponding DB_table field in the basic dictionary unit, update the corresponding R_no field of the table with semicolons, and store the relationship between the field and the field alias.
[0089] In one embodiment, the method may further include:
[0090] S250, when the information type is the second preset type, update the database cache table according to the statement segment to obtain a wide table.
[0091] The second preset type includes statement types other than "create", "update", "insert", or "select" statements. When updating the database cache table, the SQL92 standard is referenced, and the SQL format is matched to determine whether the statement segment conforms to the table or table field change pattern, including field addition, deletion, modification, table name modification, table deletion, etc. The corresponding table and updated fields are parsed according to the SQL format. For example, the SQL format for adding a field is ALTER table_name ADD field_name_attribute; the SQL format for deleting a field is ALTER table_name DROP field; and the SQL format for deleting a table is DROP table_name.
[0092] In one embodiment, the method may further include:
[0093] S260, count the number of times the target database cache table is traversed within a preset time period.
[0094] S270, when the number of times the target database cache table is traversed is less than a preset threshold, delete the target database cache table.
[0095] You can perform searches and statistics using table names as keywords to determine the number of accesses to the target database cache table within a preset time period. During deletion, a DROP statement is generated according to the SQL92 standard. Upon successful deletion, the corresponding table information in the basic dictionary unit is also removed.
[0096] In one embodiment, the method further includes:
[0097] S280, replace the table alias and field alias of the target database cache table record with the table name corresponding to the table alias and the field name corresponding to the field alias, respectively.
[0098] This application's embodiments are independent of existing databases, and their operation will not cause additional performance overhead to the database; they do not rely on database proprietary interfaces, and can support a wide range of databases; they fully consider the actual usage of wide tables, taking user needs as the foundation, and creating wide tables based on the frequency of user-related queries; they take the union of query fields and the intersection of related fields for the relationships, maximizing the number of fields in the wide table to meet the needs of different query scenarios; they remove relationships from already created wide tables, effectively preventing the creation of similar or identical wide tables; and they distinguish whether a table is a formal system table or a query table temporarily created by an individual user but not deleted, based on the database management account, i.e., the table owner, to prevent over-filtering.
[0099] This application embodiment analyzes and parses the multi-table join queries that users use frequently, creates a wide table based on this, and flexibly deletes it based on post-event backtesting evaluation. This can effectively reduce multi-table joins, improve database query efficiency, reduce the SQL writing requirements for users, and avoid duplicate creation of wide tables.
[0100] Figure 2 The method for generating wide tables is described below, in conjunction with the appendix. Figure 3 and attached Figure 4 This application describes the apparatus provided in the embodiments.
[0101] Figure 3 This illustration shows a schematic diagram of the structure of a wide table generation apparatus according to an embodiment of this application. Figure 3 Each module in the device shown has the ability to implement Figure 2 The functions of each step in the process are defined, and their corresponding technical effects are achieved. For example... Figure 3 As shown, the device may include:
[0102] Module 310 is used to retrieve database access record tables and database cache tables that are identical to database objects.
[0103] The database access record table includes information about executed database statements; the database cache table includes records of inter-table relationships.
[0104] The parsing module 320 is used to parse the executed database statement information to obtain the statement segments included in the executed database statement information, as well as the information type of the statement segments.
[0105] The determination module 330 is used to determine the target database cache table with inter-table relationships from the database cache table based on the statement segment when the information type is the first preset type.
[0106] Update module 340 is used to update the inter-table relationship records based on the target database cache table to obtain a wide table.
[0107] This application embodiment analyzes and parses the multi-table join queries that users use frequently, creates a wide table based on this, and flexibly deletes it based on post-event backtesting evaluation. This can effectively reduce multi-table joins, improve database query efficiency, reduce the SQL writing requirements for users, and avoid duplicate creation of wide tables.
[0108] In one embodiment, the update module 340 is further configured to:
[0109] When the information type is the second preset type, the database cache table is updated according to the statement segment to obtain a wide table.
[0110] In one embodiment, the determining module 330 is specifically used for:
[0111] Parse the statement segment to obtain a multi-level nested statement segment that conforms to the first preset type;
[0112] Based on the preset naming conventions, the table name and its corresponding table alias, field name and its corresponding field alias are identified from multi-level nested statement segments;
[0113] The target database cache table is determined from the database cache tables based on the table name, table alias, field name, and field alias.
[0114] In one embodiment, the update module 340 is specifically used for:
[0115] Add the target database cache table that is not recorded in the inter-table relationship record to the inter-table relationship record to obtain a wide table.
[0116] In one embodiment, the device further includes:
[0117] The statistics module is used to count the number of times the target database cache table is traversed within a preset time period.
[0118] The deletion module is used to delete the target database cache table when the number of times the target database cache table is traversed is less than a preset threshold.
[0119] In one embodiment, the device further includes:
[0120] The replacement module is used to replace the table alias and field alias of the target database cache table records with the table name corresponding to the table alias and the field name corresponding to the field alias, respectively.
[0121] This application's embodiments are independent of existing databases, and their operation will not cause additional performance overhead to the database; they do not rely on database proprietary interfaces, and can support a wide range of databases; they fully consider the actual usage of wide tables, taking user needs as the foundation, and creating wide tables based on the frequency of user-related queries; they take the union of query fields and the intersection of related fields for the relationships, maximizing the number of fields in the wide table to meet the needs of different query scenarios; they remove relationships from already created wide tables, effectively preventing the creation of similar or identical wide tables; and they distinguish whether a table is a formal system table or a query table temporarily created by an individual user but not deleted, based on the database management account, i.e., the table owner, to prevent over-filtering.
[0122] Figure 4 A schematic diagram of the structure of a wide table generation device according to an embodiment of this application is shown. Figure 4 As shown, the device may include a processor 401 and a memory 402 storing computer program instructions.
[0123] Specifically, the processor 401 may include a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.
[0124] Memory 402 may include mass storage for data or instructions. For example, and not limitingly, memory 402 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. In one instance, memory 402 may include removable or non-removable (or fixed) media, or memory 402 may be non-volatile solid-state memory. Memory 402 may be internal or external to the integrated gateway disaster recovery device.
[0125] In one instance, memory 402 may be read-only memory (ROM). In one instance, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.
[0126] The processor 401 reads and executes computer program instructions stored in the memory 402 to achieve... Figure 2 The method in the illustrated embodiment achieves... Figure 2 The technical effects achieved by executing the methods in the examples shown are not elaborated here for the sake of brevity.
[0127] In one example, the device for generating the wide table may also include a communication interface 403 and a bus 410. Wherein, as Figure 4 As shown, the processor 401, memory 402, and communication interface 403 are connected through bus 410 and complete communication with each other.
[0128] The communication interface 403 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.
[0129] Bus 410 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 410 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, this application contemplates any suitable bus or interconnect.
[0130] The device for generating the wide table can execute the method for generating the wide table in the embodiments of this application, thereby achieving... Figure 2 The technical effects of the described method for generating wide tables.
[0131] Furthermore, in conjunction with the wide table generation methods in the above embodiments, this application embodiment can provide a computer storage medium for implementation. This computer storage medium stores computer program instructions; when these computer program instructions are executed by a processor, they implement any of the wide table generation methods in the above embodiments.
[0132] It should be clarified that this application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.
[0133] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.
[0134] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.
[0135] The aspects of this application have been described above with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block in the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that these instructions, executable via the processor of the computer or other programmable data processing apparatus, enable the implementation of the functions / actions specified in one or more blocks of the flowchart illustrations and / or block diagrams. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field-programmable logic circuit. It is also understood that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can also be implemented by dedicated hardware performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0136] The above description is merely a specific implementation of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.
Claims
1. A method for generating a wide table, characterized in that, include: Retrieve the database access record table and database cache table that contain the same database objects; the database access record table includes information about the executed database statements; The database cache table includes records of inter-table relationships. The information in the database cache table comes from historical wide tables that have been created or deleted, as well as the original database tables. The database cache table sets a relationship code for the historical wide tables to represent the relationship strategy on which the historical wide tables were created. When the relationship code is empty, the historical wide tables exist. Parse the executed database statement information to obtain the statement segments included in the executed database statement information, and the information type of the statement segments; When the information type is a first preset type, the target database cache table with inter-table relationships is determined from the database cache table according to the statement segment; The wide table is obtained by updating the inter-table relationship records according to the target database cache table. Specifically, when updating the inter-table relationship record based on the target database cache table, if the relationship code exists in the target database cache table, the relationship record of the historical wide table is replaced with the relationship record of the original database table in the target database cache table, taking into account the table fields and original field names of the historical wide table.
2. The method for generating a wide table as described in claim 1, characterized in that, The method further includes: When the information type is the second preset type, the database cache table is updated according to the statement segment to obtain the wide table.
3. The method for generating a wide table as described in claim 1, characterized in that, The step of determining the target database cache table with inter-table relationships from the database cache table based on the statement segment includes: Parse the statement segment to obtain a multi-level nested statement segment that conforms to the first preset type; According to the preset naming convention, the table name and the corresponding table alias, field name and the corresponding field alias are identified from the multi-level nested statement segment; The target database cache table is determined from the database cache table based on the table name, the table alias, the field name, and the field alias.
4. The method for generating a wide table as described in claim 1, characterized in that, The step of updating the inter-table relationship records according to the target database cache table to obtain the wide table includes: The target database cache table that is not recorded in the inter-table relationship record is added to the inter-table relationship record to obtain the wide table.
5. The method for generating a wide table as described in claim 3, characterized in that, The method further includes: The number of times the target database cache table is traversed within a preset time period is counted; When the target database cache table is traversed less than a preset threshold, the target database cache table is deleted.
6. The method for generating a wide table as described in claim 3, characterized in that, The method further includes: Replace the table alias and field alias of the target database cache table record with the table name corresponding to the table alias and the field name corresponding to the field alias, respectively.
7. A wide table generation apparatus, characterized in that, include: The acquisition module is used to acquire the database access record table and the database cache table that contain the same database objects; the database access record table includes information about the executed database statements; The database cache table includes records of inter-table relationships. The information in the database cache table comes from historical wide tables that have been created or deleted, as well as the original database tables. The database cache table sets a relationship code for the historical wide tables to represent the relationship strategy on which the historical wide tables were created. When the relationship code is empty, the historical wide tables exist. The parsing module is used to parse the executed database statement information to obtain the statement segments included in the executed database statement information and the information type of the statement segments; The determination module is used to determine, when the information type is a first preset type, a target database cache table with inter-table relationships from the database cache table according to the statement segment; The update module is used to update the inter-table relationship records according to the target database cache table to obtain the wide table. Specifically, when updating the inter-table relationship record based on the target database cache table, if the relationship code exists in the target database cache table, the relationship record of the historical wide table is replaced with the relationship record of the original database table in the target database cache table, taking into account the table fields and original field names of the historical wide table.
8. The wide table generation apparatus as described in claim 7, characterized in that, The update module is also used for: When the information type is the second preset type, the database cache table is updated according to the statement segment to obtain the wide table.
9. The wide table generation apparatus as described in claim 7, characterized in that, The determining module is specifically used for: Parse the statement segment to obtain a multi-level nested statement segment that conforms to the first preset type; According to the preset naming convention, the table name and the corresponding table alias, field name and the corresponding field alias are identified from the multi-level nested statement segment; The target database cache table is determined from the database cache table based on the table name, the table alias, the field name, and the field alias.
10. The wide table generation apparatus as claimed in claim 7, characterized in that, The update module is specifically used for: The target database cache table that is not recorded in the inter-table relationship record is added to the inter-table relationship record to obtain the wide table.
11. A wide table generation device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the method for generating a wide table as described in any one of claims 1 to 6.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an implementation program for information transmission, which, when executed by a processor, implements the method for generating a wide table as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Generation method of wide table in structured query language database and device thereof
CN108228628A
Method for maintaining association relationship of data tables, computing device and storage medium
CN110955662A