A multi-level data linkage method, device and storage medium in complex business scenarios
By configuring and managing data entry items and linkage rules, using regular check rules to generate and execute SQL statements, and combining triggers to achieve multi-table data linkage and matching, it solves the problem of multi-table linkage and matching in complex business scenarios, and improves development efficiency. and system stability.
Patent Information
- Application Number
- CN202410903515.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-08
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-07-08
AI Technical Summary
In complex business scenarios, existing technology is difficult to achieve multi-table data linkage and matching, resulting in low development efficiency, frequent errors, and difficult maintenance. Manually written SQL statements are inefficient, have poor flexibility, and lack unified management and configuration.
Manage data entry items and linkage rules in a configured manner, use regular check rules in the entry data table to generate SQL statements, store and execute them in dynamic SQL data tables, and combine triggers to achieve data synchronization and matching, reducing development and Maintenance costs are reduced and system flexibility and stability are improved.
It achieves automatic synchronization and matching of data, reduces manual intervention, improves data consistency and accuracy, reduces communication costs, improves development efficiency and system flexibility and adaptability, and simplifies maintenance work.
Smart Images

Figure CN118445293B
Abstract
Description
Technical Field
[0001] The present application relates to the field of database technology, and in particular to a multi-level data linkage method, device and storage medium in a complex business scenario. Background Art
[0002] In modern enterprise information management systems, data is usually stored in multiple relational database tables, and there are complex associations and linkage operations between different tables. For example, in a sales management system, the basic information and extended information of a sales order may be stored in different database tables, and the data between these tables needs to be frequently synchronized and matched. As business scenarios become more complex, developers face the following challenges when designing and implementing these systems:
[0003] Frequent data linkage: There are frequent data entry and update operations between different tables, which requires the system to be able to synchronize data in real time and accurately. For example, when a user enters data in one table, the data in other related tables needs to be updated at the same time.
[0004] Complex data matching: Business logic often requires complex calculations and matching based on data in different tables to ensure data consistency and integrity.
[0005] High development and communication costs: When implementing complex business logic, developers need to communicate frequently to confirm data linkage and matching methods, which can easily lead to low development efficiency and frequent errors.
[0006] Difficult to maintain: As business needs change, the system needs to be constantly adjusted and optimized, and the maintenance workload is huge.
[0007] In order to solve the above problems, some systems currently use the method of manually writing SQL statements and triggers to perform data linkage and matching, but this method has the following disadvantages:
[0008] Manually writing SQL statements is inefficient: Developers need to manually write a large number of SQL statements, which is labor-intensive and error-prone.
[0009] Poor flexibility: Manually written SQL statements and triggers are difficult to adapt to changing business needs, and the cost of modification and expansion is high.
[0010] Lack of unified management and configuration: SQL statements and triggers written by different developers are not in a unified style, making centralized management and maintenance difficult.
[0011] Based on the above background, the present invention proposes a new technical solution, which manages data entry items and linkage rules in a configurable manner to achieve multi-table data linkage and matching, thereby effectively reducing development and maintenance costs and improving system flexibility and stability. Summary of the invention
[0012] In order to solve the above technical problems, the present application provides a multi-level data linkage method, device and storage medium in a complex business scenario.
[0013] The first aspect of the present application provides a multi-level data linkage method in a complex business scenario, the method comprising:
[0014] Reading an entry data table, wherein the entry data table is configured with regularity check rules, the entry data table is used to record field information, and the entry data table stores entity tables and / or extended information tables mapped by the field information;
[0015] When the field information in the entry item data table changes, an SQL statement is generated according to the change, and the SQL statement is stored in a pre-configured dynamic SQL data table, and the execution status of each SQL statement is marked in the dynamic SQL data table;
[0016] Calling the backend API interface to execute the SQL statement stored in the dynamic SQL data table and marked as unexecuted, so that the field information in the mapped target extended information table synchronizes the change;
[0017] A trigger is configured in the target extended information table, and a trigger rule and an execution rule are pre-configured in the trigger. When the field information in the target extended information table changes to meet the trigger rule, based on the execution rule, the corresponding field information in the mapped entity table or the extended information table or other extended information tables is changed through the trigger.
[0018] Optionally, based on the execution rule, changing corresponding field information in the mapped entity table or the extended information table or other extended information tables through the trigger includes:
[0019] The same field information is changed in the entity table or other extended information table through the trigger.
[0020] Optionally, based on the execution rule, changing corresponding field information in the mapped entity table or the extended information table or other extended information tables through the trigger includes:
[0021] A pre-configured field information matching table is queried through the trigger, wherein the field information matching table records association functions between fields;
[0022] Extracting the changed field information through the trigger and passing it as a parameter to the associated function;
[0023] The output of the associated target field information is calculated by the associated function, and the corresponding field information in the entity table or the extended information table or other extended information tables is changed by the trigger.
[0024] Optionally, when the field information in the entry data table is changed, a regular check is performed on the input content; the regular check rule is used to verify whether the format of the input content complies with predefined specifications;
[0025] If the input content meets the regularity check rule, the subsequent processing flow continues;
[0026] If the input content does not satisfy the regular check rule, the input is rejected.
[0027] Optionally, the entry data table defines the following fields:
[0028] id: primary key that uniquely identifies each data entry item;
[0029] column_name: the field name of the data entry item;
[0030] column_type: data type of the field;
[0031] table_name: the name of the table to which the field belongs;
[0032] dictionary_key: dictionary key, used to associate data in the dictionary table;
[0033] display_width: interface display width;
[0034] validation_regex: validation regular expression.
[0035] Optionally, the field information matching table defines the following fields:
[0036] source_table: source table name;
[0037] source_column: source table field name;
[0038] target_table: target table name;
[0039] target_column: target table field name;
[0040] calculation_formula: The correlation function.
[0041] Optionally, when a new business data table needs to be inserted, the method further includes:
[0042] Create a business data table and configure each field information in the business data table;
[0043] Configuring the association relationship between each field information in the newly added business data table, and the association relationship between each field information in the business data table and the field information in the existing entity table and / or extended information table;
[0044] Configure a trigger in the business data table, and detect the business data table through the trigger;
[0045] When the field information in the business data table is changed, the associated entity table or extended information table is changed based on the association relationship through the trigger.
[0046] A second aspect of the present application provides a multi-level data linkage device in a complex business scenario, the device comprising:
[0047] A reading unit, used for reading an entry item data table, wherein the entry item data table is configured with regularity checking rules, wherein the entry item data table is used for recording field information, wherein the entry item data table stores an entity table and / or an extended information table mapped by the field information;
[0048] An SQL statement generating unit, configured to generate SQL statements according to changes in field information in the entry item data table when the changes occur, store the SQL statements in a pre-configured dynamic SQL data table, and mark the execution status of each SQL statement in the dynamic SQL data table;
[0049] An SQL statement execution unit, configured to call a backend API interface to execute the SQL statement stored in the dynamic SQL data table and marked as unexecuted, so that the field information in the mapped target extended information table is synchronized with the change;
[0050] A trigger unit, wherein a trigger is configured in the target extended information table, wherein the trigger is pre-configured with trigger rules and execution rules, and wherein the trigger unit is used to change the corresponding field information in the mapped entity table or the extended information table or other extended information tables through the trigger based on the execution rules when the field information in the target extended information table changes to meet the trigger rules.
[0051] A third aspect of the present application provides another multi-level data linkage device in a complex business scenario, the device comprising:
[0052] Processor, memory, input-output unit, and bus;
[0053] The processor is connected to the memory, the input and output unit, and the bus;
[0054] The memory stores a program, and the processor calls the program to execute the first aspect and any optional method in the first aspect.
[0055] A fourth aspect of the present application provides a computer-readable storage medium, on which a program is stored. When the program is executed on a computer, the program executes the first aspect and any optional method in the first aspect.
[0056] It can be seen from the above technical solutions that this application has the following advantages:
[0057] 1. By configuring regular expression verification rules and SQL generation logic in the entry data table, the system can automatically generate and execute SQL statements to achieve automatic data synchronization. This reduces manual intervention, reduces the probability of errors, and improves data consistency and accuracy.
[0058] 2. Store the generated SQL statements in a dynamic SQL data table and mark the execution status to facilitate the management and monitoring of the execution of SQL statements. This mechanism enables the system to flexibly handle different data changes and provides higher scalability and maintainability.
[0059] 3. By managing data entry items and linkage rules in a configurable manner, developers do not need to frequently communicate to confirm data linkage methods. This reduces communication costs and improves development efficiency, which is particularly important in complex business scenarios.
[0060] 4. Configure triggers and execution rules to enable the system to dynamically adjust data linkage and synchronization strategies according to business needs. Whether adding new data tables or modifying existing data tables, the system can flexibly adapt to business changes, providing higher flexibility and adaptability.
[0061] 5. Through configuration management and automated execution, system changes and expansions are more convenient. New requirements only require modifying the configuration or adding new configuration items, without making a lot of changes to the existing code, which greatly simplifies maintenance work.
[0062] 6. Through the trigger mechanism, when the field information in the target extended information table changes, the system can trigger the corresponding operation in real time to ensure the instant synchronization and linkage of data. This improves the real-time performance and processing efficiency of the system.
[0063] 7. Through strict regular validation rules and automated SQL execution processes, the accuracy and completeness of data entry and changes are ensured. Data consistency and completeness are the key to stable system operation in complex business scenarios.
[0064] 8. Dynamic SQL data tables centrally record and manage all generated SQL statements and their execution status, making it easier for system administrators to monitor and audit. Any problems can be quickly located and resolved to ensure system reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] In order to more clearly illustrate the technical solution in the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0066] Figure 1 A flowchart of an embodiment of a multi-level data linkage method in a complex business scenario provided in this application;
[0067] Figure 2 This is a flowchart of another embodiment of the multi-level data linkage method in a complex business scenario provided in this application;
[0068] Figure 3 A schematic diagram of the structure of an embodiment of a multi-level data linkage device in a complex business scenario provided in this application;
[0069] Figure 4 This is a schematic diagram of the structure of an embodiment of a multi-level data linkage device in another complex business scenario provided in this application. DETAILED DESCRIPTION
[0070] It should be noted that the method provided in this application can be applied to a terminal, a system, or a server. For example, the terminal can be a smart phone or a computer, a tablet computer, a smart TV, a smart watch, a portable computer terminal, or a fixed terminal such as a desktop computer. For the convenience of explanation, this application uses the terminal as an example for explanation.
[0071] See also Figure 1 The present application first provides an embodiment of a multi-level data linkage method in a complex business scenario, and the embodiment includes:
[0072] S101, reading an entry data table, wherein the entry data table is configured with regularity check rules, the entry data table is used to record field information, and the entry data table stores entity tables and / or extended information tables mapped by the field information;
[0073] In this step, the system reads a specific database table, the "entry item data table". This table is used to record various field information, such as data entered by the user. This table is also configured with regular expression validation rules, which are used to verify whether the input data meets specific format requirements. In addition, the entry item data table also saves the mapping relationship between these field information and other database tables (such as entity tables and / or extended information tables).
[0074] You can set specific field names, field types, write table names, validation regular expressions, etc. in the entry data table. When users enter data on the interface, the system will perform data validation based on these configurations.
[0075] For example, when a user enters data in a front-end form, the system generates form fields based on the configuration in the entry data table and performs regular expression verification. For example, the user enters the following data:
[0076] Name: Sample Entity
[0077] Description: This is a sample description.
[0078] Created: 2024-06-17 12:00:00
[0079] Update time: 2024-06-17 12:00:00
[0080] The system will check whether these name fields match the regular expression ^[A-Za-z ]+$.
[0081] In an optional implementation, the entry data table defines the following fields:
[0082] id: primary key that uniquely identifies each data entry item;
[0083] column_name: the field name of the data entry item;
[0084] column_type: data type of the field;
[0085] table_name: the name of the table to which the field belongs;
[0086] dictionary_key: dictionary key, used to associate data in the dictionary table;
[0087] display_width: interface display width;
[0088] validation_regex: validation regular expression.
[0089] The following is a code example of the entry data table structure:
[0090] CREATE TABLE sys_input_columns (
[0091] id INT PRIMARY KEY,
[0092] column_name VARCHAR(50),
[0093] column_type VARCHAR(20),
[0094] table_name VARCHAR(50),
[0095] dictionary_key VARCHAR(50),
[0096] display_width INT,
[0097] validation_regex VARCHAR(255) );
[0099] Sample Data
[0100] INSERT INTO sys_input_columns (id, column_name, column_type, table_name, dictionary_key, display_width, validation_regex) VALUES
[0101] (1, 'name', 'VARCHAR', 'new_entity', NULL, 20, '^[A-Za-z ]+$'),
[0102] (2, 'description', 'VARCHAR', 'new_entity', NULL, 50, NULL),
[0103] (3, 'created_at', 'TIMESTAMP', 'new_entity', NULL, 20, NULL),
[0104] (4, 'updated_at', 'TIMESTAMP', 'new_entity', NULL, 20, NULL);
[0105] S102, when the field information in the entry item data table changes, generate SQL statements according to the changes, store the SQL statements in a pre-configured dynamic SQL data table, and mark the execution status of each SQL statement in the dynamic SQL data table;
[0106] Monitors whether the field information in the entry data table has changed (such as insert, update, delete operations). When the user modifies and saves the fields in the entry data table in the front-end interface, the system will detect these changes. Based on these changes, the system will dynamically generate corresponding SQL statements to update other database tables associated with these fields. These generated SQL statements will be stored in the "Dynamic SQL Data Table", and each SQL statement will be marked with its execution status (such as "Not Executed").
[0107] For example, in an e-commerce system, if the price of a product is modified, the system will generate a SQL statement to update the price field in the "product entity table". This SQL statement is then added to the dynamic SQL data table and marked as "not executed".
[0108] The following is a code example of a dynamic SQL data table structure:
[0109] CREATE TABLE fact_dynamic_sql (
[0110] id INT PRIMARY KEY,
[0111] sql_statement TEXT,
[0112] executed BOOLEAN DEFAULT FALSE );
[0114] Sample Data
[0115] INSERT INTO fact_dynamic_sql (sql_statement, executed) VALUES
[0116] ('INSERT INTO new_entity (id, name, description, created_at, updated_at) VALUES (1, ''Sample Entity'', ''This is a sample description.'', ''2024-06-17 12:00:00'', ''2024-06-17 12:00:00'')', FALSE);
[0117] S103, calling the backend API interface to execute the SQL statement stored in the dynamic SQL data table and marked as unexecuted, so that the field information in the mapped target extended information table synchronizes the change;
[0118] In this step, the system will call the backend API interface to execute the SQL statements marked as "not executed" in the dynamic SQL data table. The purpose of this is to ensure that all extended information tables associated with the entry data table can be updated in a timely manner to maintain data consistency. This step aims to synchronize changes in the entry information table to the extended information table by executing the unexecuted SQL statements in the dynamic SQL data table.
[0119] Continuing with the e-commerce system as an example, the backend API interface will be called to execute the previously generated SQL statement to update the price field in the "Product Entity Table". Once the SQL statement is executed successfully, its execution status in the dynamic SQL data table will be updated to "Executed".
[0120] Here is a code example for this step:
[0121] API call query unexecuted SQL
[0122] SELECT id, sql_statement FROM fact_dynamic_sql WHERE executed =FALSE;
[0123] Execute SQL statements
[0124] For example: Perform an insert operation
[0125] INSERT INTO new_entity (id, name, description, created_at, updated_at)
[0126] VALUES (1, 'Sample Entity', 'This is a sample description.', '2024-06-17 12:00:00', '2024-06-17 12:00:00');
[0127] Update execution status
[0128] UPDATE fact_dynamic_sql SET executed = TRUE WHERE id = 1;
[0129] S104. A trigger is configured in the target extended information table, and a trigger rule and an execution rule are pre-configured in the trigger. When the field information in the target extended information table changes to meet the trigger rule, based on the execution rule, the corresponding field information in the mapped entity table or the extended information table or other extended information tables is changed through the trigger.
[0130] In the target extended information table, the system configures triggers. These triggers contain predefined trigger rules and execution rules. When the field information in the extended information table changes and these changes meet the trigger rules of the trigger, the trigger will automatically update other related database tables according to its execution rules.
[0131] The following is a code example that updates each data table through a trigger:
[0132] -- Create a trigger to synchronize related table information when inserting or updating the new_entity table
[0133] CREATE TRIGGER trg_sync_related_entity
[0134] AFTER INSERT ON new_entity
[0135] FOR EACH ROW
[0136] BEGIN
[0137] INSERT INTO related_entity (entity_id, name, description)
[0138] VALUES (NEW.id, NEW.name, NEW.description);
[0139] END;
[0140] CREATE TRIGGER trg_update_related_entity
[0141] AFTER UPDATE ON new_entity
[0142] FOR EACH ROW
[0143] BEGIN
[0144] UPDATE related_entity
[0145] SET name = NEW.name, description = NEW.description
[0146] WHERE entity_id = NEW.id;
[0147] END.
[0148] In order to better illustrate the method provided by this application, the whole process of this method is illustrated by a specific example below:
[0149] Suppose there is a sales management system that contains the following database tables:
[0150] sales_order table: stores basic information of sales orders, corresponding to the associated entity table described in this application.
[0151] fact_sales_order_ext table: stores extended information of sales orders (such as discounts, taxes, etc.), corresponding to the extended information table in this application.
[0152] sys_input_columns table: configures data entry items, corresponding to the entry item data table in this application.
[0153] sys_rows_column_mapping table: configures the mapping relationship and calculation formula between fields, corresponding to the field matching information table in this application.
[0154] fact_dynamic_sql table: records the generated dynamic SQL statements and their execution status, corresponding to the dynamic SQL statement table in this application.
[0155] In the process of sales order management, the following functions need to be implemented:
[0156] Configure data entry items in the sys_input_columns table and perform data verification.
[0157] When the data is saved, SQL statements are generated and executed to insert the data into the corresponding table.
[0158] When order data changes, related synchronization and calculation operations are automatically executed through triggers.
[0159] Synchronize the changes of extended information to the main order table and record the dynamic SQL statement for subsequent execution.
[0160] First, the structure of each table is as follows:
[0161] 1. sales_order table:
[0162] CREATE TABLE sales_order (
[0163] id INT PRIMARY KEY,
[0164] order_number VARCHAR(50),
[0165] customer_name VARCHAR(50),
[0166] total_amount DECIMAL(10, 2),
[0167] discount DECIMAL(10, 2),
[0168] tax DECIMAL(10, 2),
[0169] net_amount DECIMAL(10, 2) );
[0171] 2. fact_sales_order_ext table:
[0172] CREATE TABLE fact_sales_order_ext (
[0173] id INT PRIMARY KEY,
[0174] order_id INT,
[0175] discount DECIMAL(10, 2),
[0176] tax DECIMAL(10, 2),
[0177] FOREIGN KEY (order_id) REFERENCES sales_order(id) );
[0179] 3. sys_input_columns table:
[0180] CREATE TABLE sys_input_columns (
[0181] id INT PRIMARY KEY,
[0182] column_name VARCHAR(50),
[0183] column_type VARCHAR(20),
[0184] table_name VARCHAR(50),
[0185] dictionary_key VARCHAR(50),
[0186] display_width INT,
[0187] validation_regex VARCHAR(100) );
[0189] INSERT INTO sys_input_columns VALUES
[0190] (1, 'discount', 'DECIMAL', 'fact_sales_order_ext', NULL, 10, '^[0-9]+(\.[0-9]{1,2})?$'),
[0191] (2, 'tax', 'DECIMAL', 'fact_sales_order_ext', NULL, 10, '^[0-9]+(\.[0-9]{1,2})?$');
[0192] 4. sys_rows_column_mapping table:
[0193] CREATE TABLE sys_rows_column_mapping (
[0194] source_table VARCHAR(50),
[0195] source_column VARCHAR(50),
[0196] target_table VARCHAR(50),
[0197] target_column VARCHAR(50),
[0198] calculation_formula VARCHAR(100) );
[0200] INSERT INTO sys_rows_column_mapping VALUES
[0201] ('fact_sales_order_ext', 'discount', 'sales_order', 'discount',NULL),
[0202] ('fact_sales_order_ext', 'tax', 'sales_order', 'tax', NULL),
[0203] ('fact_sales_order_ext', 'id', 'sales_order', 'net_amount', 'total_amount - discount + tax');
[0204] 5. fact_dynamic_sql table:
[0205] CREATE TABLE fact_dynamic_sql (
[0206] id INT PRIMARY KEY AUTO_INCREMENT,
[0207] sql_statement TEXT,
[0208] executed BOOLEAN DEFAULT FALSE );
[0210] Configure data entry items in the sys_input_columns table, set specific field names, field types, write table names, validation regular expressions, etc. When users enter data on the interface, the system will perform data validation based on these configurations.
[0211] For example, when users enter discounts and taxes, the system will check whether these fields meet the requirements of the regular expression. If the data does not meet the requirements, a prompt message will pop up.
[0212] When the user clicks the Save button, the system will generate an SQL statement and insert the data into the corresponding table, while recording the generated SQL statement and related parameters.
[0213] The implementation is as follows:
[0214] Generate and execute insert statements
[0215] INSERT INTO fact_sales_order_ext (id, order_id, discount, tax)
[0216] VALUES (1, 1, 50.00, 5.00);
[0217] Record generated SQL statements
[0218] INSERT INTO fact_dynamic_sql (sql_statement, executed)
[0219] VALUES ('INSERT INTO fact_sales_order_ext (id, order_id, discount,tax) VALUES (1, 1, 50.00, 5.00)', FALSE);
[0220] Data synchronization and calculation through triggers
[0221] Set triggers on the fact_sales_order_ext table to implement data synchronization and calculation operations.
[0222] Trigger 1: Synchronize discounts and taxes to the sales_order table
[0223] CREATE TRIGGER trg_update_sales_order
[0224] AFTER UPDATE ON fact_sales_order_ext
[0225] FOR EACH ROW
[0226] BEGIN
[0227] Function 1: Update values from fact_sales_order_ext table to entity table
[0228] UPDATE sales_order
[0229] SET discount = NEW.discount,
[0230] tax = NEW.tax
[0231] WHERE id = NEW.order_id;
[0232] END;
[0233] Trigger 2: Calculate the net amount and update it to the sales_order table
[0234] CREATE TRIGGER trg_calculate_net_amount
[0235] AFTER UPDATE ON fact_sales_order_ext
[0236] FOR EACH ROW
[0237] BEGIN
[0238] Function 2: Calculate new values according to the calculation formula and save them to the fact_sales_order_ext table
[0239] DECLARE total_amount DECIMAL(10, 2);
[0240] DECLARE discount DECIMAL(10, 2);
[0241] DECLARE tax DECIMAL(10, 2);
[0242] DECLARE net_amount DECIMAL(10, 2);
[0243] SELECT total_amount INTO total_amount FROM sales_order WHERE id =NEW.order_id;
[0244] SET discount = NEW.discount;
[0245] SET tax = NEW.tax;
[0246] SET net_amount = total_amount - discount + tax;
[0247] UPDATE sales_order
[0248] SET net_amount = net_amount
[0249] WHERE id = NEW.order_id;
[0250] END;
[0251] Trigger 3: Record unexecuted target SQL statements
[0252] CREATE TRIGGER trg_record_dynamic_sql
[0253] AFTER INSERT ON fact_sales_order_ext
[0254] FOR EACH ROW
[0255] BEGIN
[0256] Function 3: Record the target SQL statement into the fact_dynamic_sql table
[0257] INSERT INTO fact_dynamic_sql (sql_statement, executed)
[0258] VALUES ('UPDATE sales_order SET discount = NEW.discount, tax =NEW.tax WHERE id = NEW.order_id', FALSE);
[0259] END;
[0260] The above trigger code examples include implementation examples of configuring triggers and implementation examples of executing corresponding changes through triggers.
[0261] The above examples show in detail how the entire technical solution is implemented, from configuring data entry items, generating and executing SQL statements, to using triggers to achieve data synchronization and calculation, and finally calling the backend interface to execute SQL statements. This solution effectively solves the problems of multi-table linkage and frequent data matching in complex business scenarios, reduces the communication costs of developers, and improves the system's automation and development efficiency.
[0262] In the above-mentioned embodiment, the entity table or the extended information table mapped by the trigger change may be improved in various ways in practice, for example:
[0263] Implementation method 1: The same field information can be changed in the entity table or other extended information table through the trigger.
[0264] Alternatively, implementation method 2: querying a pre-configured field information matching table through the trigger, wherein the field information matching table records association functions between fields;
[0265] Extracting the changed field information through the trigger and passing it as a parameter to the associated function;
[0266] The output of the associated target field information is calculated by the associated function, and the corresponding field information in the entity table or the extended information table or other extended information tables is changed by the trigger.
[0267] In the embodiment, the field information in the entity table or the extended information table can be changed by triggers, and there are multiple implementation methods. Two implementation methods are described in detail below: directly changing the same field information and changing through the field information matching table and the associated function.
[0268] Implementation method 1: Directly change the same field information
[0269] This method is relatively direct, and the same field information is changed in the entity table or extended information table through triggers.
[0270] Example:
[0271] Assume that there are two tables entity_table and entity_ext_table. When a field in entity_table is changed, the same field in entity_ext_table is changed synchronously.
[0272] Implementation method 2: Change through field information matching table and associated function
[0273] This method is more complex and flexible. It queries the pre-configured field information matching table through triggers, calculates the output of the associated target field information, and updates the corresponding field information in the entity table or extended information table.
[0274] The following is a specific implementation example:
[0275] -- Create a function to calculate the target field information based on the configuration in the matching table
[0276] CREATE FUNCTION calculate_target_value(
[0277] source_table VARCHAR,
[0278] source_column VARCHAR,
[0279] source_value VARCHAR
[0280] ) RETURNS VARCHAR AS $$
[0281] DECLARE
[0282] target_value VARCHAR;
[0283] transformation_function VARCHAR;
[0284] BEGIN
[0285] SELECT transformation_function INTO transformation_function
[0286] FROM field_mapping_table
[0287] WHERE source_table = source_table AND source_column = source_column;
[0288] IF transformation_function = 'UPPER' THEN
[0289] target_value := UPPER(source_value);
[0290] ELSE
[0291] target_value := source_value; -- No transformation is done by default
[0292] END IF;
[0293] RETURN target_value;
[0294] END;
[0295] This implementation requires pre-configuration of the field information table and triggers. The specific configuration process is as follows:
[0296] Create a field information matching table: store the association relationship and calculation formula between fields.
[0297] field_mapping_table is used to store the mapping relationship between fields and the rules for how to convert. Each record in this table defines the relationship between a source field and a target field and specifies a conversion function.
[0298] Write an association function: Calculate the target field information based on the configuration in the field matching table.
[0299] Configure triggers: Use triggers to call associated functions to make changes.
[0300] The present application also provides an embodiment of a multi-level data linkage method in a complex business scenario. In the method provided by the present application, field information is uniformly entered through an entry item data table, that is, a unified data entry method is specified. Based on this, when data is input, the input data can be checked through regular check rules to determine whether the input data conforms to a predetermined format specification. The embodiment includes:
[0301] S201, reading an entry item data table, wherein the entry item data table is configured with regularity check rules, the entry item data table is used to record field information, and the entry item data table stores entity tables and / or extended information tables mapped by the field information;
[0302] S202, when the field information in the entry data table is changed, a regular check is performed on the input content; the regular check rule is used to verify whether the format of the input content conforms to a predefined specification;
[0303] If the input content satisfies the regularity check rule, step S203 is executed; if not, step S206 is executed.
[0304] In this embodiment, it is first necessary to define a regular expression rule, and configure the regular expression rule for each field in the entry data table.
[0305] When the field information changes, obtain the user input and perform regular expression validation.
[0306] If the input content meets the regular expression rules, continue to execute the subsequent steps; if not, execute the error handling steps.
[0307] The following example illustrates this:
[0308] Assume there is a sys_input_columns table that contains regular expression rules for the fields:
[0309] CREATE TABLE sys_input_columns (
[0310] id INT PRIMARY KEY AUTO_INCREMENT,
[0311] column_name VARCHAR(50),
[0312] display_name VARCHAR(50),
[0313] input_type VARCHAR(20),
[0314] display_width INT,
[0315] sort_order INT,
[0316] enum_code VARCHAR(50),
[0317] regex_pattern VARCHAR(255) -- A new column for storing regular expression rules );
[0319] -- Insert sample data
[0320] INSERT INTO sys_input_columns (column_name, display_name, input_type,display_width, sort_order, enum_code, regex_pattern) VALUES
[0321] ('id', 'ID', 'number', 10, 1, NULL, '^\d+$'),
[0322] ('value1', 'Value 1', 'number', 20, 2, NULL, '^\d+(\.\d{1,2})?$'), --matches a number with up to two decimal places
[0323] ('value2', 'Value 2', 'number', 20, 3, NULL, '^\d+(\.\d{1,2})?$'),
[0324] ('computed_value', 'Computed Value', 'number', 20, 4, NULL, '^\d+(\.\d{1,2})?$');
[0325] Then configure the backend code to perform regular expression validation when field information changes. For example, you can create a Flask application to verify whether the input content conforms to the regular expression rules through the / validate_input route.
[0326] The front end or back end performs corresponding operations according to the verification result. If the input content meets the regular expression rules, continue to execute the subsequent steps (S203); if not, execute the error handling step (S206).
[0327] S203, generating SQL statements according to the changes, storing the SQL statements in a pre-configured dynamic SQL data table, and marking the execution status of each SQL statement in the dynamic SQL data table;
[0328] S204, calling the backend API interface to execute the SQL statement stored in the dynamic SQL data table and marked as unexecuted, so that the field information in the mapped target extended information table synchronizes the change;
[0329] S205. A trigger is configured in the target extended information table, and a trigger rule and an execution rule are pre-configured in the trigger. When the field information in the target extended information table changes to meet the trigger rule, based on the execution rule, the corresponding field information in the mapped entity table or the extended information table or other extended information tables is changed through the trigger.
[0330] S206: Reject this input.
[0331] In this step, when the input does not meet the regularity check rules, the error step can be executed, including processing the errors in the user input content to ensure that the user corrects the errors in time and meets the input requirements. The following are some possible error steps:
[0332] Display error message: inform the user that the input content does not meet the requirements and display specific error information.
[0333] Block submission operations: Prevent data that does not meet the requirements from being submitted or saved in the database.
[0334] Focus on error field: Move the cursor to the error input field to facilitate users to modify it.
[0335] Highlight error fields: Highlight error input fields by changing color or style to alert users.
[0336] Record error logs: record error information in log files or databases for subsequent analysis and troubleshooting.
[0337] Provide correct examples: Provide examples or prompts that meet the requirements to help users understand the correct input format.
[0338] In another optional embodiment, when a new business data table needs to be inserted, the method further includes: creating a business data table and configuring each field information in the business data table; configuring the association relationship between each field information in the newly added business data table, and the association relationship between each field information in the business data table and the field information of the existing entity table and / or extended information table; configuring a trigger in the business data table, and detecting the business data table through the trigger; when the field information in the business data table changes, the associated entity table or extended information table is changed based on the association relationship through the trigger.
[0339] In this embodiment, for the newly inserted business data table, how to configure table fields, set association relationships, and use triggers are further described in detail. The following is a detailed explanation of each step:
[0340] 1. Create a business data table and configure field information
[0341] First, create a new business data table and configure the field information in the table.
[0342] 2. Configure the relationship between field information
[0343] Configure the information of each field in the new table, including the relationship between them and the relationship with the existing entity table and extended information table.
[0344] 3. Configure triggers and detect field information changes through triggers
[0345] Configure triggers in the new business data table. When field information changes, the triggers are used to detect and update other tables based on the associated relationships.
[0346] Example scenario:
[0347] Assume that a new business table new_business_table is added, which contains the fields: ticket_amount, fuel_surcharge, airport_fee, and total_amount. The existing tax calculation table tax_calculation_table contains the fields: tax_amount_due, prepaid_tax_amount, and data tracing fields.
[0348] Implementation process:
[0349] New table creation and configuration:
[0350] When the new table is created, the field ticket_amount is annotated as "taxable".
[0351] The fields fuel_surcharge and airport_fee are annotated as "taxes paid on behalf of others".
[0352] Configuration related information:
[0353] Configure the field information of the new table in the sys_input_columns table.
[0354] Configure the association between the new table and the tax calculation table in the sys_rows_column_mapping table.
[0355] Trigger creation:
[0356] Create a trigger to automatically update the relevant fields of the tax calculation table when inserting or updating new table data.
[0357] Automatically generate SQL statements and execute:
[0358] When a new table is inserted or updated, the trigger automatically generates a SQL statement and stores it in the fact_dynamic_sql table and marks it as "PENDING".
[0359] The backend API calls the scheduled task to execute the unexecuted SQL statement and updates the status to "EXECUTED".
[0360] Through the above steps, the automatic association and data update of the new table and the existing table are realized, which improves the automation and efficiency of data processing.
[0361] The above content describes the method provided by the present application in detail. The following describes the device provided by the present application:
[0362] See also Figure 3 The present application provides a multi-level data linkage device in a complex business scenario, the device comprising:
[0363] A reading unit 301 is used to read an entry item data table, wherein the entry item data table is configured with regularity check rules, wherein the entry item data table is used to record field information, wherein the entry item data table stores entity tables and / or extended information tables mapped by the field information;
[0364] The SQL statement generating unit 302 is used to generate SQL statements according to the changes in the field information in the entry item data table, store the SQL statements in a pre-configured dynamic SQL data table, and mark the execution status of each SQL statement in the dynamic SQL data table;
[0365] The SQL statement execution unit 303 is used to call the backend API interface to execute the SQL statement stored in the dynamic SQL data table and marked as unexecuted, so that the field information in the mapped target extension information table synchronizes the change;
[0366] A trigger unit 304, wherein a trigger is configured in the target extended information table, wherein the trigger is pre-configured with trigger rules and execution rules, and wherein the trigger unit is used to change the corresponding field information in the mapped entity table or the extended information table or other extended information tables through the trigger based on the execution rules when the field information in the target extended information table changes to meet the trigger rules.
[0367] Optionally, the trigger unit 304 is specifically configured to change the same field information in the entity table or other extended information table through the trigger.
[0368] Optionally, the trigger unit 304 is specifically used to query a preconfigured field information matching table through the trigger, wherein the field information matching table records association functions between fields;
[0369] Extracting the changed field information through the trigger and passing it as a parameter to the associated function;
[0370] The output of the associated target field information is calculated by the associated function, and the corresponding field information in the entity table or the extended information table or other extended information tables is changed by the trigger.
[0371] Optionally, a regularity checking unit 305 is further included, which is used to perform regularity checking on the input content when the field information in the entry data table is changed; the regularity checking rule is used to verify whether the format of the input content meets the predefined specification;
[0372] If the input content meets the regularity check rule, the subsequent processing flow continues;
[0373] If the input content does not satisfy the regular check rule, the input is rejected.
[0374] Optionally, the entry data table defines the following fields:
[0375] id: primary key that uniquely identifies each data entry item;
[0376] column_name: the field name of the data entry item;
[0377] column_type: data type of the field;
[0378] table_name: the name of the table to which the field belongs;
[0379] dictionary_key: dictionary key, used to associate data in the dictionary table;
[0380] display_width: interface display width;
[0381] validation_regex: validation regular expression.
[0382] Optionally, the field information matching table defines the following fields:
[0383] source_table: source table name;
[0384] source_column: source table field name;
[0385] target_table: target table name;
[0386] target_column: target table field name;
[0387] calculation_formula: The correlation function.
[0388] The present application also provides a multi-level data linkage device in a complex business scenario, including:
[0389] Processor 401, memory 402, input and output unit 403, bus 404;
[0390] The processor 401 is connected to the memory 402, the input and output unit 403 and the bus 404;
[0391] The memory 402 stores a program, and the processor 401 calls the program to execute the multi-level data linkage method in any complex business scenario as described above.
[0392] The present application also relates to a computer-readable storage medium on which a program is stored. When the program runs on a computer, the computer executes the multi-level data linkage method in any complex business scenario as described above.
[0393] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0394] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, 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, such as 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 an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0395] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0396] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0397] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk and other media that can store program code.
Claims
1. A multi-level data linkage method in complex business scenarios. It is characterized in that The method comprises: Reading an entry data table, wherein the entry data table is configured with regularity check rules, the entry data table is used to record field information, and the entry data table stores entity tables and / or extended information tables mapped by the field information; When the field information in the entry item data table changes, an SQL statement is generated according to the change, and the SQL statement is stored in a pre-configured dynamic SQL data table, and the execution status of each SQL statement is marked in the dynamic SQL data table; Calling the backend API interface to execute the SQL statement stored in the dynamic SQL data table and marked as unexecuted, so that the field information in the mapped target extended information table synchronizes the change; A trigger is configured in the target extended information table, and a trigger rule and an execution rule are pre-configured in the trigger. When the field information in the target extended information table changes to meet the trigger rule, based on the execution rule, the corresponding field information in the mapped entity table or the extended information table or other extended information tables is changed through the trigger.
2. According to the multi-level data linkage method in complex business scenarios described in claim 1, It is characterized in that The changing of the corresponding field information in the mapped entity table or the extended information table or other extended information tables through the trigger based on the execution rule includes: The same field information is changed in the entity table or other extended information table through the trigger.
3. According to the multi-level data linkage method in complex business scenarios described in claim 1, It is characterized in that The changing of the corresponding field information in the mapped entity table or the extended information table or other extended information tables through the trigger based on the execution rule includes: A pre-configured field information matching table is queried through the trigger, wherein the field information matching table records association functions between fields; Extracting the changed field information through the trigger and passing it as a parameter to the associated function; The output of the associated target field information is calculated by the associated function, and the corresponding field information in the entity table or the extended information table or other extended information tables is changed by the trigger.
4. According to the multi-level data linkage method in complex business scenarios described in claim 1, It is characterized in that When the field information in the entry data table is changed, the input content is subjected to regularity check; the regularity check rule is used to verify whether the format of the input content conforms to the predefined specification; If the input content meets the regularity check rule, the subsequent processing flow continues; If the input content does not satisfy the regular check rule, the input is rejected.
5. According to the multi-level data linkage method in complex business scenarios described in claim 3, It is characterized in that The entry data table defines the following fields: id: primary key that uniquely identifies each data entry item; column_name: the field name of the data entry item; column_type: data type of the field; table_name: the name of the table to which the field belongs; dictionary_key: dictionary key, used to associate data in the dictionary table; display_width: interface display width; validation_regex: validation regular expression.
6. According to the multi-level data linkage method in complex business scenarios described in claim 3, It is characterized in that The field information matching table defines the following fields: source_table: source table name; source_column: source table field name; target_table: target table name; target_column: target table field name; calculation_formula: The correlation function.
7. According to the multi-level data linkage method in complex business scenarios described in claim 1, It is characterized in that When a new business data table needs to be inserted, the method further includes: Create a business data table and configure each field information in the business data table; Configuring the association relationship between each field information in the newly added business data table, and the association relationship between each field information in the business data table and the field information in the existing entity table and / or extended information table; Configure a trigger in the business data table, and detect the business data table through the trigger; When the field information in the business data table is changed, the associated entity table or extended information table is changed based on the association relationship through the trigger.
8. A multi-level data linkage device in a complex business scenario, the device include: A reading unit, used for reading an entry item data table, wherein the entry item data table is configured with regularity checking rules, wherein the entry item data table is used for recording field information, wherein the entry item data table stores an entity table and / or an extended information table mapped by the field information; An SQL statement generating unit, configured to generate SQL statements according to changes in field information in the entry item data table when the changes occur, store the SQL statements in a pre-configured dynamic SQL data table, and mark the execution status of each SQL statement in the dynamic SQL data table; An SQL statement execution unit, configured to call a backend API interface to execute the SQL statement stored in the dynamic SQL data table and marked as unexecuted, so that the field information in the mapped target extended information table is synchronized with the change; A trigger unit, wherein a trigger is configured in the target extended information table, wherein the trigger is pre-configured with trigger rules and execution rules, and wherein the trigger unit is used to change the corresponding field information in the mapped entity table or the extended information table or other extended information tables through the trigger based on the execution rules when the field information in the target extended information table changes to meet the trigger rules.
9. A multi-level data linkage device for complex business scenarios. It is characterized in that The device comprises: Processor, memory, input-output unit, and bus; The processor is connected to the memory, the input and output unit, and the bus; The memory stores a program, and the processor calls the program to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a program, and when the program is executed on a computer, the method according to any one of claims 1 to 7 is performed.
Citation Information
Patent Citations
Service data processing method, medium and computer equipment
CN117033417A
Private data processing method and device, computer equipment and storage medium
CN117113392A
