Wide table generation method and device based on service scene
By splitting the wide table into narrow tables and establishing correlation relationships, a wide table for business scenarios is generated, which solves the data redundancy and complex cross-reference problems in the existing technology, realizes clear control and flexible expansion of indicator data, and improves query efficiency. efficiency.
Patent Information
- Application Number
- CN202410713673.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-09-27
AI Technical Summary
In the existing technology, the generation of indicator wide tables under business scenarios has data redundancy and complex cross-reference relationships, which makes maintenance and expansion difficult, and cannot flexibly adapt to the needs of rapidly changing financial business scenarios.
By splitting the wide table to be generated into narrow tables, establishing the relationship between primary keys and foreign keys, and generating SQL temporary views for aggregation, a wide table for business scenarios is generated to avoid data redundancy and complex cross-references.
It achieves clear management and control of indicator data, simplifies maintenance and expansion, improves query and display efficiency, and adapts to the needs of different business scenarios.
Smart Images

Figure CN118709665A
Abstract
Description
Technical Field
[0001] The present application belongs to the field of information data processing technology, and specifically relates to a method and device for generating a wide table based on a business scenario. Background Art
[0002] A business scenario refers to a specific business application scenario formed by integrating business processes, data and technology in a specific business environment according to the needs and goals of the enterprise. It is a specific scenario in the operation process of an enterprise, which can be a business process, a business module or a business function. The application scope of business scenarios is very wide. In enterprise management, business scenarios can be applied to various departments and fields, including sales, procurement, production, logistics, human resources, etc. The application of business scenarios is also different in different industries. For example, in the retail industry, business scenarios can include product listing, inventory management, order processing, etc.; in the financial industry, business scenarios can include loan approval, risk assessment, payment settlement, etc. By applying business scenarios, enterprises can optimize and automate business processes, improve work efficiency and quality, and reduce costs and risks. At the same time, business scenarios can also help enterprises conduct data analysis and decision support, providing better business insights and competitive advantages.
[0003] The indicators in the existing business scenarios are processed independently to produce a wide indicator table for each business scenario. In this case, multiple business scenarios require multiple wide tables, but many indicators between wide tables overlap, resulting in many repeatedly processed indicators and causing a lot of data redundancy.
[0004] In the context of digital operations, there are many scenarios for financial services, and they change very quickly. Moreover, the indicator elements that need to be displayed in each scenario are also different. In order to adapt to the needs of new businesses and new scenarios, there is an urgent need in the existing technology for a wide table generation method that is adaptable to business scenarios and can be flexibly configured. Summary of the invention
[0005] The present invention can be used in the technical field of the application of information data processing technology in finance, and can also be used in any field other than the financial field.
[0006] One object of the present invention is to provide a wide table generation method based on business scenarios, which has clearer control over indicator data and does not have complex cross-reference relationships, making maintenance simpler and facilitating the expansion and use of indicator data.
[0007] Another object of the present invention is to provide a device for generating a wide table based on a business scenario. Another object of the present invention is to provide an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the steps of the above-mentioned method for generating a wide table based on a business scenario when executing the computer program. Still another object of the present invention is to provide a readable medium, on which a computer program is stored, and when the computer program is executed by the processor, the steps of the above-mentioned method for generating a wide table based on a business scenario are implemented.
[0008] In order to solve the technical problems in the background technology of this application, the present invention provides the following technical solutions:
[0009] In a first aspect, the present invention provides a method for generating a wide table based on a business scenario, comprising:
[0010] Selecting a narrow table according to an indicator of a scenario corresponding to the wide table to be generated; wherein the indicator is the minimum granularity unit for splitting the scenario;
[0011] Establishing association relationships between a plurality of the narrow tables and the wide table to be generated according to the attributes of the narrow table, the business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationships include: an association relationship between a primary key of the wide table and a foreign key of the narrow table, and an association relationship between a foreign key of the wide table and a primary key of the narrow table;
[0012] Generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship;
[0013] All SQL temporary views are aggregated to generate the wide table to be generated; wherein the multiple wide tables correspond to the multiple scenarios one by one.
[0014] In some embodiments of the present invention, aggregating all SQL temporary views includes:
[0015] Selecting at least one narrow table according to the association relationship, and determining an aggregation order of the corresponding narrow table;
[0016] The SQL temporary view corresponding to the selected at least one narrow table is aggregated according to the aggregation order to generate the wide table to be generated.
[0017] In some embodiments of the present invention, when the wide table to be generated includes a parent index, the step of generating a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship further includes:
[0018] At least two narrow tables are selected according to the association relationship; wherein the parent index is generated by at least two indexes;
[0019] generating at least one parent indicator according to the indicators corresponding to the at least two selected narrow tables;
[0020] Cross-connecting multiple narrow tables corresponding to the parent index to generate a parent narrow table;
[0021] The SQL temporary view is generated according to the parent narrow table, the association relationship and / or multiple narrow tables.
[0022] In some embodiments of the present invention, establishing associations between the plurality of narrow tables and the wide table to be generated according to the attributes of the narrow table, the service parameters, the attributes of the wide table to be generated, and the service parameters includes:
[0023] Selecting a narrow table as a central narrow table according to the service parameters of the wide table to be generated and the service parameters of the narrow table;
[0024] Determining at least one other narrow table associated with the central narrow table according to the service parameters of the central narrow table;
[0025] The association relationship is established according to the central narrow table, the at least one other narrow table, attributes of the narrow table, and attributes of the wide table.
[0026] In some embodiments of the present invention, establishing the association relationship according to the central narrow table, the at least one other narrow table, the attributes of the narrow table, and the attributes of the wide table includes:
[0027] determining at least one sub-association relationship between the central narrow table and the at least one other narrow table;
[0028] Selecting the at least one sub-association relationship according to the business parameter of the wide table;
[0029] The association relationship is generated according to the attribute of the narrow table, the attribute of the wide table and the selected at least one sub-association relationship.
[0030] In some embodiments of the present invention, a plurality of indicators correspond one-to-one to a plurality of narrow tables, and the indicators are table contents stored in the narrow tables.
[0031] In a second aspect, the present invention provides a wide table generation device based on a business scenario, the device comprising:
[0032] A narrow table selection module, used to select a narrow table according to an indicator of a scenario corresponding to the wide table to be generated; wherein the indicator is the minimum granularity unit for splitting the scenario;
[0033] An association relationship establishment module, used to establish association relationships between the plurality of narrow tables and the wide table to be generated according to the attributes of the narrow table, the business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationships include: an association relationship between the primary key of the wide table and the foreign key of the narrow table, and an association relationship between the foreign key of the wide table and the primary key of the narrow table;
[0034] A SQL view generation module, used to generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship;
[0035] The wide table generation module is used to aggregate all SQL temporary views to generate the wide table to be generated; wherein the multiple wide tables correspond to the multiple scenarios one by one.
[0036] In some embodiments of the present invention, the wide table generation module includes:
[0037] An aggregation order determination unit, configured to select at least one narrow table according to the association relationship, and determine an aggregation order of the corresponding narrow table;
[0038] The first wide table generation unit is used to aggregate the SQL temporary view corresponding to the selected at least one narrow table according to the aggregation order to generate the wide table to be generated.
[0039] In some embodiments of the present invention, when the wide table to be generated includes a parent index, the wide table generation module further includes:
[0040] A narrow table selection unit, configured to select at least two narrow tables according to the association relationship; wherein the parent index is generated by at least two indexes;
[0041] A parent index generating unit, configured to generate at least one parent index according to the indexes corresponding to the at least two selected narrow tables;
[0042] A parent narrow table generating unit, configured to cross-connect multiple narrow tables corresponding to the parent index to generate a parent narrow table;
[0043] The wide table generates a second unit, which is used to generate the SQL temporary view according to the parent narrow table, the association relationship and / or multiple narrow tables.
[0044] In some embodiments of the present invention, the association relationship establishment module includes:
[0045] A central narrow table setting unit, configured to select a narrow table as a central narrow table according to the service parameters of the wide table to be generated and the service parameters of the narrow table;
[0046] Another narrow table determination unit, configured to determine at least one other narrow table associated with the central narrow table according to the service parameter of the central narrow table;
[0047] The association relationship establishing unit is configured to establish the association relationship according to the central narrow table, the at least one other narrow table, the attributes of the narrow table, and the attributes of the wide table.
[0048] In some embodiments of the present invention, the association relationship establishing unit includes:
[0049] a sub-association determination unit, configured to determine at least one sub-association between the central narrow table and the at least one other narrow table;
[0050] A sub-association selection unit, configured to select the at least one sub-association according to the service parameters of the wide table;
[0051] The association relationship generating unit is used to generate the association relationship according to the attribute of the narrow table, the attribute of the wide table and the selected at least one sub-association relationship.
[0052] In some embodiments of the present invention, a plurality of indicators correspond one-to-one to a plurality of narrow tables, and the indicators are table contents stored in the narrow tables.
[0053] In a third aspect, the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of a method for generating a wide table based on a business scenario.
[0054] In a fourth aspect, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, steps of a method for generating a wide table based on a business scenario are implemented.
[0055] In a fifth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of a method for generating a wide table based on a business scenario.
[0056] From the above description, it can be seen that an embodiment of the present invention provides a method and device for generating a wide table based on a business scenario, and the corresponding method includes: first, selecting a narrow table according to an indicator of a scenario corresponding to the wide table to be generated; wherein the indicator is the minimum granularity unit under the split scenario; then, establishing an association relationship between multiple narrow tables and the wide table to be generated according to the attributes of the narrow table, business parameters, attributes of the wide table to be generated, and business parameters; wherein the association relationship includes: an association relationship between the primary key of the wide table and the foreign key of the narrow table, and an association relationship between the foreign key of the wide table and the primary key of the narrow table; generating a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship; finally, aggregating all SQL temporary views to generate the wide table to be generated; wherein multiple wide tables correspond one-to-one to multiple scenarios.
[0057] The corresponding device includes: a narrow table selection module, which is used to select a narrow table according to the indicators of the scenario corresponding to the wide table to be generated; wherein the indicators are the minimum granularity units under the splitting scenario; an association relationship establishment module, which is used to establish association relationships between multiple narrow tables and the wide table to be generated according to the attributes of the narrow table, business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationships include: the association relationship between the primary key of the wide table and the foreign key of the narrow table, and the association relationship between the foreign key of the wide table and the primary key of the narrow table; an SQL view generation module, which is used to generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship; a wide table generation module, which is used to aggregate all SQL temporary views to generate the wide table to be generated; wherein the multiple wide tables correspond one-to-one to the multiple scenarios.
[0058] An embodiment of the present invention provides a method and device for generating a wide table based on business scenarios. First, the indicator elements of all business scenarios are decomposed into single elements. Then, the single elements are processed according to the minimum granularity and numbered for dictionary management. In this case, all sets of single indicator elements can cover all business scenarios to avoid repeated processing of data and improve the efficiency of query and display. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0060] Figure 1 A schematic diagram of a process of generating a wide table based on a business scenario in an embodiment of the present invention;
[0061] Figure 2FIG. 4 is a flow chart of step 400 of a method for generating a wide table based on a business scenario in an embodiment of the present invention. Figure 1 ;
[0062] Figure 3 FIG. 4 is a flow chart of step 400 of a method for generating a wide table based on a business scenario in an embodiment of the present invention. Figure 2 ;
[0063] Figure 4 This is a flow chart of step 200 of a method for generating a wide table based on a business scenario in an embodiment of the present invention;
[0064] Figure 5 This is a flow chart of step 203 of the method for generating a wide table based on a business scenario in an embodiment of the present invention;
[0065] Figure 6 A flowchart of a method for generating a wide table based on a business scenario in a specific implementation manner of the present invention;
[0066] Figure 7 is a block diagram of a wide table generating device based on a business scenario in an embodiment of the present invention;
[0067] Figure 8 The block of the wide table generation module 40 in the embodiment of the present invention is Figure 1 ;
[0068] Fig. 9 The block of the wide table generation module 40 in the embodiment of the present invention is Figure 2 ;
[0069] Fig.10 A block diagram of an association relationship establishing module 20 in an embodiment of the present invention;
[0070] Fig.11 A block diagram of an association relationship establishing unit 20c in an embodiment of the present invention;
[0071] Fig.12 It is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0072] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0073] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0074] It should be noted that the terms "including" and "having" in the specification and claims of the present application and the above-mentioned drawings and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices. In the absence of conflict, the embodiments in the present application and the features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the drawings and in combination with the embodiments.
[0075] The acquisition, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of laws and regulations.
[0076] The embodiment of the present invention provides a specific implementation of a wide table generation method based on a business scenario, see Figure 1 , the method specifically includes the following contents:
[0077] Step 100: Select a narrow table according to an index of a scenario corresponding to the wide table to be generated; wherein the index is the minimum granularity unit for splitting the scenario;
[0078] Step 200: establishing association relationships between a plurality of the narrow tables and the wide table to be generated according to the attributes of the narrow table, the business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationships include: an association relationship between the primary key of the wide table and the foreign key of the narrow table and an association relationship between the foreign key of the wide table and the primary key of the narrow table;
[0079] Step 300: Generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship;
[0080] Step 400: Aggregate all SQL temporary views to generate the wide table to be generated; wherein the multiple wide tables correspond to the multiple scenarios one by one.
[0081] From the above description, it can be seen that an embodiment of the present invention provides a method for generating a wide table based on a business scenario, including: first, selecting a narrow table according to an indicator of a scenario corresponding to the wide table to be generated; wherein the indicator is the minimum granularity unit under the split scenario; then, establishing an association relationship between multiple narrow tables and the wide table to be generated according to the attributes of the narrow table, business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationship includes: an association relationship between the primary key of the wide table and the foreign key of the narrow table, and an association relationship between the foreign key of the wide table and the primary key of the narrow table; generating a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship; finally, aggregating all SQL temporary views to generate the wide table to be generated; wherein the multiple wide tables correspond one-to-one to the multiple scenarios.
[0082] A method for generating a wide table based on business scenarios is provided in an embodiment of the present invention. According to specific business scenarios, required indicator elements are extracted from a single element indicator library to form a business query wide table. The business query wide table only stores results without the need for processing. The present invention can avoid repeated processing of data and improve the efficiency of query and display.
[0083] For step 100 , the indicator is the table content stored in the narrow table.
[0084] Preferably, the attributes of the table in step 200 include: column name, data type, width, format, required items, default value, uniqueness constraint, foreign key constraint, sorting, and hidden columns, specifically:
[0085] Column name: The name of each column in the table, used to describe the data content contained in the column.
[0086] Data Type: Specify the type of data in each column, such as text, number, date, etc., which helps with data accuracy and calculations.
[0087] Width: Specify the width of each column to fit the displayed content and ensure that the data is fully displayed.
[0088] Format: Specify the display format of data, such as currency format, percentage format, etc., to improve data readability.
[0089] Required: Identifies which columns are required to help ensure data integrity.
[0090] Default Values: Assign default values to certain columns to simplify the data entry process.
[0091] Unique constraint: ensures that the values in certain columns are unique throughout the table.
[0092] Foreign key constraint: specifies the relationship between certain columns and other tables to ensure data consistency.
[0093] Sorting: Specify the default sorting method for table data to facilitate users to view and analyze data.
[0094] Hide columns: You can hide some infrequently used columns to simplify the user interface and improve user experience.
[0095] On the other hand, the business parameters in step 200 refer to adjustable values, settings or conditions used to affect business processes, calculation results or decisions in the business field. Preferably, the business parameters include quantitative parameters, quality parameters, time parameters, environmental parameters, constraints, algorithm parameters, cost parameters and risk parameters, specifically:
[0096] Quantitative parameters: Numerical parameters such as price, quantity, percentage, etc. These parameters can affect business calculations, forecasts, and decisions.
[0097] Quality parameters: Descriptive parameters such as product category, customer type, product status, etc. These parameters can be used to distinguish business processing methods in different situations.
[0098] Time parameters: parameters related to time, such as date, time period, season, etc. Time parameters can affect business planning, sales seasonality adjustment, etc.
[0099] Environmental parameters: Parameters that describe the business operating environment, such as market conditions, competitor conditions, etc. These parameters can help the business make targeted adjustments.
[0100] Restrictions: Conditions that limit business operations, such as minimum order quantity, maximum inventory, maximum discount ratio, etc. These conditions can ensure that business operations are within a controllable range.
[0101] Algorithm parameters: Parameters used in fields such as data analysis and machine learning, such as learning rate, number of iterations, model selection, etc. These parameters directly affect the performance and results of the algorithm.
[0102] Cost parameters: Parameters that describe the cost of business, such as transportation cost, production cost, labor cost, etc. These parameters are crucial for cost control and profit analysis.
[0103] Risk Parameters: Parameters that describe business risks, such as market risk, credit risk, operational risk, etc. These parameters help in assessing the risk level and developing risk management strategies.
[0104] For step 200, the association relationship between the multiple narrow tables and the wide table to be generated (in database design and management, the association relationship between two tables refers to how to associate data in different tables so as to obtain relevant information in a query) can be described from the following aspects:
[0105] Primary Key-Foreign Key Association: In this relationship, the primary key of one table is associated with a foreign key in another table. A foreign key is a field whose value matches the primary key value in another table, thus establishing the association between the tables. This relationship is often used to establish a one-to-many relationship between tables, where each record in one table can be associated with multiple records in another table.
[0106] One-to-one association: In this relationship, each record in one table is associated with one record in the other table. The records in each table are related by sharing the same key, such as a primary key or a unique key. One-to-one associations are often used to break up large tables into smaller, related sub-tables.
[0107] Many-to-many association: In this relationship, multiple records in one table are associated with multiple records in another table. To implement a many-to-many association, you usually need to create a third "junction" table that contains the foreign keys between the two tables. Many-to-many associations are often used to represent complex business relationships.
[0108] Self-association: In a self-association, records in a table are associated with other records in the same table. This relationship is often used to represent a hierarchy, such as a superior-subordinate relationship in an organizational structure or a parent-child relationship in a product classification.
[0109] For step 300, two methods are provided here for implementation: using a merge operation to merge rows or columns in multiple narrow tables according to a specified key field, which can be implemented using a database query language or a data processing tool.
[0110] Alternatively, you can use a pivot table operation to convert certain columns in a narrow table into rows or columns of a wide table. Pivot table operations are used to convert long-format data into wide formats, such as using dates as row indexes and product categories as column indexes.
[0111] In some embodiments of the present invention, see Figure 2 , step 400 comprises:
[0112] Step 401: selecting at least one narrow table according to the association relationship, and determining an aggregation order of the corresponding narrow table;
[0113] It should be pointed out that before clustering, it is necessary to ensure that the data in all narrow tables are logically consistent to prevent errors caused by data mismatch. Specifically: Before performing the join operation, ensure that each narrow table is preprocessed and cleaned. This includes checking data types, removing duplicate values, handling missing values, etc. Ensure that the data format and content are consistent. Next, before performing the join operation, ensure that each narrow table is preprocessed and cleaned. This includes checking data types, removing duplicate values, handling missing values, etc. Ensure that the data format and content are consistent. In addition, before the join operation, perform a data matching check to ensure data consistency. Compare key fields or indicators to ensure that they are consistent in all tables. Using mechanisms such as foreign key constraints in the database can help ensure data consistency during join operations. This prevents the insertion of mismatched data or the destruction of data relationships.
[0114] Step 401: Aggregate the SQL temporary view corresponding to the selected at least one narrow table according to the aggregation order to generate the wide table to be generated.
[0115] For example, the three narrow tables Customers, Orders, and OrderDetails will be concatenated to generate a wide table containing customer details, order information, and product details in the order:
[0116] Assume that the three tables have the following structure: Customers table: CustomerID (INT, primary key); CustomerName (VARCHAR); CustomerEmail (VARCHAR);
[0117] Orders table: OrderID (INT, primary key); CustomerID (INT, foreign key); OrderDate (DATE);
[0118] OrderDetails table: DetailID (INT, primary key); OrderID (INT, foreign key); ProductID (INT); Quantity (INT); Price (DECIMAL).
[0119] Use the SQL JOIN statement to combine these tables. Here is an example SQL query that combines data from all three tables:
[0120] Query results: This query will generate a wide table in which each row contains the following information: CustomerID: customer ID; CustomerName: customer name; CustomerEmail: customer email address; OrderID: order ID; OrderDate: order date; ProductID: product ID; Quantity: product quantity; Price: product price.
[0121] In some embodiments of the present invention, when the wide table to be generated includes a parent index, see Figure 3 , step 400 further includes:
[0122] Step 403: selecting at least two narrow tables according to the association relationship; wherein the parent index is generated by at least two indexes;
[0123] Step 404: Generate at least one parent index according to the indexes corresponding to the at least two selected narrow tables;
[0124] Specifically, first, determine the two indicators that need to be merged, and record them as A and B. Next, determine the characteristics and relationship between the two indicators A and B, and determine the principles and methods of merging. For example: calculate the arithmetic mean or geometric mean of A and B as the parent indicator. Set the weight coefficient to obtain the weighted average as the parent indicator. If A and B have a clear dependency relationship, they can be combined into a parent indicator using a certain functional relationship. Calculate the value of the parent indicator based on the determined merging method. Name the parent indicator and explain its meaning and calculation method.
[0125] For example, suppose there are two indicators: sales growth rate (A) and profit margin (B). A comprehensive performance indicator can be generated by calculating the weighted average of A and B. The weight can be set according to the actual situation. The calculation formula of the parent indicator can be:
[0126] Parent index = w1*A+w2*B
[0127] Among them, w1 and w2 are weight coefficients, w1+w2=1. By adjusting the values of w1 and w2, the relative importance of different factors in the comprehensive index can be reflected. Specifically, the grid search method can be used to find the optimal learning rate and other parameters that affect weight adjustment. Specifically: First, it is necessary to define the parameter grid to be searched, including the learning rate and other parameters that affect weight adjustment (the parameter grid is a set of parameter spaces, and the model will search for the best parameter combination in this space). Next, it is necessary to select a machine learning model and define other hyperparameters of the model (parameters other than the learning rate). In order to evaluate the performance of each set of parameters, a scoring function also needs to be defined.
[0128] Next, using the defined parameter grid, model, and scoring function, a grid search algorithm is executed, which searches for the best parameter combination on the parameter grid and evaluates the performance of each parameter combination using the scoring function. After the grid search is completed, the parameter combination with the best performance is selected as the optimal parameter. Preferably, the optimal parameters are obtained by cross-validation to ensure the generalization performance of the model.
[0129] Step 405: cross-connect multiple narrow tables corresponding to the parent index to generate a parent narrow table;
[0130] Specifically, a Cartesian product operation is performed on the data in multiple narrow tables to generate a new table containing all possible combinations;
[0131] Step 406: Generate the SQL temporary view according to the parent narrow table, the association relationship and / or multiple narrow tables.
[0132] In some embodiments of the present invention, see Figure 4 , step 200 comprises:
[0133] Step 201: selecting a narrow table as a central narrow table according to the service parameters of the wide table to be generated and the service parameters of the narrow table;
[0134] Step 202: determining at least one other narrow table associated with the central narrow table according to the service parameters of the central narrow table;
[0135] Step 203: Establishing the association relationship according to the central narrow table, the at least one other narrow table, the attributes of the narrow table, and the attributes of the wide table.
[0136] In some embodiments of the present invention, see Figure 5 , step 203 comprises:
[0137] Step 2031: determining at least one sub-association relationship between the central narrow table and the at least one other narrow table;
[0138] Step 2032: selecting the at least one sub-association relationship according to the business parameters of the wide table;
[0139] Step 2033: Generate the association relationship according to the attribute of the narrow table, the attribute of the wide table and the selected at least one sub-association relationship.
[0140] In some embodiments of the present invention, a plurality of indicators correspond one-to-one to a plurality of narrow tables, and the indicators are table contents stored in the narrow tables.
[0141] A method for generating a wide table based on business scenarios is provided in an embodiment of the present invention. According to specific business scenarios, required indicator elements are extracted from a single element indicator library to form a business query wide table. The business query wide table only stores results without the need for processing. The present invention can avoid repeated processing of data and improve the efficiency of query and display.
[0142] Specifically, the method provided by the present invention first saves each indicator into a narrow table according to the minimum granularity, and the front-end scene takes the indicator as needed, and generates an indicator upper-level logical wide table for all indicators required by this scene through a customized method, which is easy to read and display. Since the data sources required by the upper-level logical wide table are all narrow tables, there is no need to reprocess the data.
[0143] In a specific implementation, the present invention also provides a specific implementation of a wide table generation method based on a business scenario, which specifically includes the following contents.
[0144] See also Figure 6 The specific implementation of a wide table generation method based on a business scenario provided by the present invention includes the following steps:
[0145] S1: Save each indicator into a narrow table according to the minimum granularity.
[0146] S2: Extract indicators on demand based on the front-end scenario.
[0147] Specifically, we must first clarify the business goals and requirements in the front-end scenario, such as improving user experience, optimizing page loading speed, increasing user interaction, etc. According to the business goals, select the key indicators related to them. For example, in the case of optimizing page loading speed, the key indicators may include page loading time, first screen rendering time, number of resource requests, etc. Next, determine the data source that can be used to extract indicators, and according to the selected key indicators, write the corresponding query or script to extract the required data from the data source, and perform necessary processing and conversion.
[0148] S3: Generate an upper-level logical wide table of indicators through customization for all indicators required for this scenario.
[0149] Determine all the required indicators based on the business goals and requirements of the front-end scenario. Based on the determined indicators, design an appropriate wide table structure, including fields such as indicator name, data type, description, etc. Extract the required indicator data from the data source based on the designed wide table structure. You can use SQL queries, Python scripts, or other data extraction tools to obtain data. Fill the extracted data into the wide table to ensure that each indicator has a corresponding value or information. Preferably, data cleaning, conversion, and integration are required to ensure the accuracy and completeness of the data.
[0150] Based on the populated data, generate an upper-level logical wide table containing all indicators. Here is a method to generate the above upper-level logical wide table with a pivot table: select one or more fields as the row index of the pivot table, and the unique values of these fields will become the row labels of the pivot table. Select one or more fields as the column index of the pivot table, and the unique values of these fields will become the column labels of the pivot table. Select one or more fields as the numeric fields of the pivot table, and the values of these fields will fill the data cells in the pivot table. Pivot the data according to the row index and column index to generate a new pivot table, that is, the upper-level logical wide table. The combination of the row index and the column index determines the location of the data, and the value of the value field fills the data cell.
[0151] In a specific implementation of a wide table generation method based on a business scenario provided by the present invention, the minimum granularity narrow table saved by indicators is the smallest unit of the indicator scenario, and only one copy of each data needs to be saved, thereby avoiding redundancy of indicator data.
[0152] The prior art creates a wide table for each scenario. Many indicator fields in the wide tables of multiple scenarios are duplicated, which is equivalent to multiple copies of one indicator. This makes it difficult to maintain the uniform accuracy of the indicators. The present invention perfectly avoids this problem. Each indicator has only one copy of data, which is read from here when used in each scenario, thus ensuring the accuracy of the indicator data.
[0153] When the scene changes, the wide table structure corresponding to the scene must be changed accordingly, which will increase the cost of transformation. The present invention can exist in the smallest unit and can be increased or decreased at will as the scene changes, and can achieve plug-and-play.
[0154] In existing scenarios, when adding new indicators, there will be multiple indicator data sources obtained, and there will be a problem of not knowing which data source is more accurate. The single indicator data source provided by the present invention perfectly avoids this problem.
[0155] The indicator data management and control method of the present invention is clearer and does not have a complex cross-reference relationship, making maintenance simpler and very convenient for expansion and use of indicator data.
[0156] Based on the same inventive concept, the embodiments of the present application also provide a wide table generation device based on a business scenario, which can be used to implement the method described in the above embodiments, such as the following embodiments. Since the principle of solving the problem by the wide table generation device based on a business scenario is similar to that of the wide table generation method based on a business scenario, the implementation of the wide table generation device based on a business scenario can refer to the implementation of the wide table generation method based on a business scenario, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the system described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0157] The embodiment of the present invention provides a specific implementation of a wide table generation device based on a business scenario that can implement a wide table generation method based on a business scenario, see Figure 7 , a wide table generation device based on a business scenario specifically includes the following contents:
[0158] The narrow table selection module 10 is used to select a narrow table according to an indicator of a scenario corresponding to the wide table to be generated; wherein the indicator is the minimum granularity unit for splitting the scenario;
[0159] The association relationship establishment module 20 is used to establish association relationships between the plurality of narrow tables and the wide table to be generated according to the attributes of the narrow table, the business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationships include: the association relationship between the primary key of the wide table and the foreign key of the narrow table and the association relationship between the foreign key of the wide table and the primary key of the narrow table;
[0160] A SQL view generation module 30, used to generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship;
[0161] The wide table generation module 40 is used to aggregate all SQL temporary views to generate the wide table to be generated; wherein the multiple wide tables correspond to the multiple scenarios one by one.
[0162] In some embodiments of the present invention, see Figure 8 , the wide table generation module 40 includes:
[0163] An aggregation order determining unit 40a, configured to select at least one narrow table according to the association relationship, and determine an aggregation order of the corresponding narrow table;
[0164] The first wide table generating unit 40b is used to aggregate the SQL temporary view corresponding to the selected at least one narrow table according to the aggregation order to generate the wide table to be generated.
[0165] In some embodiments of the present invention, see Fig. 9 When the wide table to be generated includes a parent index, the wide table generating module 40 further includes:
[0166] A narrow table selection unit 40c is used to select at least two narrow tables according to the association relationship; wherein the parent index is generated by at least two indexes;
[0167] A parent index generating unit 40d, configured to generate at least one parent index according to the indexes corresponding to the at least two selected narrow tables;
[0168] A parent narrow table generating unit 40e, configured to cross-connect multiple narrow tables corresponding to the parent index to generate a parent narrow table;
[0169] The second wide table generating unit 40f is used to generate the SQL temporary view according to the parent narrow table, the association relationship and / or multiple narrow tables.
[0170] In some embodiments of the present invention, see Fig.10 , the association relationship establishing module 20 includes:
[0171] A central narrow table setting unit 20a, configured to select a narrow table as a central narrow table according to the service parameters of the wide table to be generated and the service parameters of the narrow table;
[0172] Another narrow table determination unit 20b is used to determine at least one other narrow table associated with the central narrow table according to the service parameters of the central narrow table;
[0173] The association relationship establishing unit 20c is configured to establish the association relationship according to the central narrow table, the at least one other narrow table, the attributes of the narrow table, and the attributes of the wide table.
[0174] In some embodiments of the present invention, see Fig.11 , the association relationship establishing unit 20c includes:
[0175] A sub-association relationship determining unit 20c1, configured to determine at least one sub-association relationship between the central narrow table and the at least one other narrow table;
[0176] A sub-association selection unit 20c2, configured to select the at least one sub-association according to the service parameters of the wide table;
[0177] The association relationship generating unit 20c3 is configured to generate the association relationship according to the attribute of the narrow table, the attribute of the wide table and the selected at least one sub-association relationship.
[0178] In some embodiments of the present invention, a plurality of indicators correspond one-to-one to a plurality of narrow tables, and the indicators are table contents stored in the narrow tables.
[0179] From the above description, it can be seen that an embodiment of the present invention provides a wide table generation device based on a business scenario, including: a narrow table selection module, used to select a narrow table according to an indicator of a scenario corresponding to the wide table to be generated; wherein the indicator is the minimum granularity unit under the split scenario; an association relationship establishment module, used to establish an association relationship between multiple narrow tables and the wide table to be generated according to the attributes of the narrow table, business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationship includes: the association relationship between the primary key of the wide table and the foreign key of the narrow table and the association relationship between the foreign key of the wide table and the primary key of the narrow table; a SQL view generation module, used to generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship; a wide table generation module, used to aggregate all SQL temporary views to generate the wide table to be generated; wherein the multiple wide tables correspond one-to-one to the multiple scenarios.
[0180] A business scenario-based wide table generation device provided in an embodiment of the present invention first decomposes the indicator elements of all business scenarios into single elements; then, the single elements are processed according to the minimum granularity and numbered for dictionary management; in this case, all sets of single indicator elements can cover all business scenarios to avoid repeated processing of data and improve the efficiency of query and display.
[0181] The embodiments of the present application also provide a specific implementation of an electronic device that can implement all steps in the method for generating a wide table based on a business scenario in the above embodiments, see Fig.12 , electronic equipment specifically includes the following:
[0182] Processor (processor) 1201, memory (memory) 1202, communication interface (CommunicationsInterface) 1203 and bus 1204;
[0183] The processor 1201, the memory 1202, and the communication interface 1203 communicate with each other through the bus 1204; the communication interface 1203 is used to realize information transmission between the server device and the client device and other related devices;
[0184] The processor 1201 is used to call the computer program in the memory 1202. When the processor executes the computer program, all steps in the method for generating a wide table based on a business scenario in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0185] Step 100: Select a narrow table according to an index of a scenario corresponding to the wide table to be generated; wherein the index is the minimum granularity unit for splitting the scenario;
[0186] Step 200: establishing association relationships between a plurality of the narrow tables and the wide table to be generated according to the attributes of the narrow table, the business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationships include: an association relationship between the primary key of the wide table and the foreign key of the narrow table and an association relationship between the foreign key of the wide table and the primary key of the narrow table;
[0187] Step 300: Generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship;
[0188] Step 400: Aggregate all SQL temporary views to generate the wide table to be generated; wherein the multiple wide tables correspond to the multiple scenarios one by one.
[0189] The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps in the method for generating a wide table based on a business scenario in the above embodiments. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all the steps in the method for generating a wide table based on a business scenario in the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0190] Step 100: Select a narrow table according to an index of a scenario corresponding to the wide table to be generated; wherein the index is the minimum granularity unit for splitting the scenario;
[0191] Step 200: establishing association relationships between a plurality of the narrow tables and the wide table to be generated according to the attributes of the narrow table, the business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationships include: an association relationship between the primary key of the wide table and the foreign key of the narrow table and an association relationship between the foreign key of the wide table and the primary key of the narrow table;
[0192] Step 300: Generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship;
[0193] Step 400: Aggregate all SQL temporary views to generate the wide table to be generated; wherein the multiple wide tables correspond to the multiple scenarios one by one.
[0194] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the hardware + program embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0195] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0196] Although the present application provides method operation steps such as embodiments or flow charts, more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the actual device or client product is executed, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel (for example, in a parallel processor or multi-threaded processing environment).
[0197] For the convenience of description, the above devices are described in various modules according to their functions. Of course, when implementing the embodiments of this specification, the functions of each module can be implemented in the same or more software and / or hardware, or the module implementing the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0198] Those skilled in the art also know that, in addition to implementing the controller in a purely computer-readable program code, the controller can be made to implement the same function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered as a hardware component, and the devices for implementing various functions included therein can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules for implementing the method and structures within the hardware component.
[0199] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0200] 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.
[0201] Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. In the description of this specification, the description of the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of this specification. In this specification, the schematic representation of the above terms does not necessarily target the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, in the absence of contradiction, a person skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0202] The above is only an example of the embodiment of the present specification and is not intended to limit the embodiment of the present specification. For those skilled in the art, the embodiment of the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the embodiment of the present specification shall be included in the scope of the claims of the embodiment of the present specification.
Claims
1. A method for generating a wide table based on a business scenario, characterized in that: include: Selecting a narrow table according to an indicator of a scenario corresponding to the wide table to be generated; wherein the indicator is the minimum granularity unit for splitting the scenario; Establishing association relationships between a plurality of the narrow tables and the wide table to be generated according to the attributes of the narrow table, the business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationships include: an association relationship between a primary key of the wide table and a foreign key of the narrow table, and an association relationship between a foreign key of the wide table and a primary key of the narrow table; Generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship; All SQL temporary views are aggregated to generate the wide table to be generated; wherein the multiple wide tables correspond to the multiple scenarios one by one.
2. The method for generating a wide table according to claim 1, characterized in that: The above will aggregate all SQL temporary views, including: Selecting at least one narrow table according to the association relationship, and determining an aggregation order of the corresponding narrow table; The SQL temporary view corresponding to the selected at least one narrow table is aggregated according to the aggregation order to generate the wide table to be generated.
3. The method for generating a wide table according to claim 1, characterized in that: When the wide table to be generated includes a parent index, the step of generating a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship further includes: At least two narrow tables are selected according to the association relationship; wherein the parent index is generated by at least two indexes; generating at least one parent indicator according to the indicators corresponding to the at least two selected narrow tables; Cross-connecting multiple narrow tables corresponding to the parent index to generate a parent narrow table; The SQL temporary view is generated according to the parent narrow table, the association relationship and / or multiple narrow tables.
4. The method for generating a wide table according to claim 1, characterized in that: Establishing association relationships between the plurality of narrow tables and the wide table to be generated according to the attributes of the narrow table, the service parameters, the attributes of the wide table to be generated, and the service parameters, including: Selecting a narrow table as a central narrow table according to the service parameters of the wide table to be generated and the service parameters of the narrow table; Determining at least one other narrow table associated with the central narrow table according to the service parameters of the central narrow table; The association relationship is established according to the central narrow table, the at least one other narrow table, attributes of the narrow table, and attributes of the wide table.
5. The method for generating a wide table according to claim 4, characterized in that: Establishing the association relationship according to the central narrow table, the at least one other narrow table, the attribute of the narrow table, and the attribute of the wide table includes: determining at least one sub-association relationship between the central narrow table and the at least one other narrow table; Selecting the at least one sub-association relationship according to the business parameter of the wide table; The association relationship is generated according to the attribute of the narrow table, the attribute of the wide table and the selected at least one sub-association relationship.
6. The method for generating a wide table according to any one of claims 1 to 5, characterized in that: The multiple indicators correspond one-to-one to the multiple narrow tables and are table contents stored in the narrow tables.
7. A wide table generation device based on business scenarios, characterized in that: include: A narrow table selection module, used to select a narrow table according to an indicator of a scenario corresponding to the wide table to be generated; wherein the indicator is the minimum granularity unit for splitting the scenario; An association relationship establishment module, used to establish association relationships between the plurality of narrow tables and the wide table to be generated according to the attributes of the narrow table, the business parameters, the attributes of the wide table to be generated, and the business parameters; wherein the association relationships include: an association relationship between the primary key of the wide table and the foreign key of the narrow table, and an association relationship between the foreign key of the wide table and the primary key of the narrow table; A SQL view generation module, used to generate a SQL temporary view corresponding to each narrow table according to each narrow table and the association relationship; The wide table generation module is used to aggregate all SQL temporary views to generate the wide table to be generated; wherein the multiple wide tables correspond to the multiple scenarios one by one.
8. The wide table generating device according to claim 7, characterized in that: The wide table generation module comprises: An aggregation order determination unit, configured to select at least one narrow table according to the association relationship, and determine an aggregation order of the corresponding narrow table; The first wide table generation unit is used to aggregate the SQL temporary view corresponding to the selected at least one narrow table according to the aggregation order to generate the wide table to be generated.
9. The wide table generating device according to claim 7, characterized in that: When the wide table to be generated includes a parent indicator, the wide table generation module further includes: A narrow table selection unit, configured to select at least two narrow tables according to the association relationship; wherein the parent index is generated by at least two indexes; A parent index generating unit, configured to generate at least one parent index according to the indexes corresponding to the at least two selected narrow tables; A parent narrow table generating unit, configured to cross-connect multiple narrow tables corresponding to the parent index to generate a parent narrow table; The wide table generates a second unit, which is used to generate the SQL temporary view according to the parent narrow table, the association relationship and / or multiple narrow tables.
10. The wide table generating device according to claim 7, characterized in that: The association relationship establishment module includes: A central narrow table setting unit, configured to select a narrow table as a central narrow table according to the service parameters of the wide table to be generated and the service parameters of the narrow table; Another narrow table determination unit, configured to determine at least one other narrow table associated with the central narrow table according to the service parameter of the central narrow table; The association relationship establishing unit is configured to establish the association relationship according to the central narrow table, the at least one other narrow table, the attributes of the narrow table, and the attributes of the wide table.
11. The wide table generating device according to claim 10, characterized in that: The association relationship establishing unit includes: a sub-association determination unit, configured to determine at least one sub-association between the central narrow table and the at least one other narrow table; A sub-association selection unit, configured to select the at least one sub-association according to the service parameters of the wide table; The association relationship generating unit is used to generate the association relationship according to the attribute of the narrow table, the attribute of the wide table and the selected at least one sub-association relationship.
12. The wide table generating device according to any one of claims 7 to 11, characterized in that: The multiple indicators correspond one-to-one to the multiple narrow tables and are table contents stored in the narrow tables.
13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the method for generating a wide table based on a business scenario according to any one of claims 1 to 6 are implemented.
14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method for generating a wide table based on a business scenario according to any one of claims 1 to 6 are implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for generating a wide table based on a business scenario according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Method and system for dynamically generating wide table according to data assets
CN112395291A
Feature wide table generation and business processing model training method and device
CN113535817A
Synchronization method and device of wide table data, electronic device and storage medium
CN115525722A
Data management method and system based on dimension modeling
CN117573646A
Method and device for converting narrow user feature table into wide feature table
CN117632500A
