A method to automatically check if the enumeration field value is out of bounds
By defining the constraint value range and logical meaning of enumerated fields, constructing string descriptions of specific syntax structures, and checking database remark information through scheduled scheduling tasks, we solve the problem of out-of-bounds enumerated field values in the database and realize automatic Checks and alerts reduce operation and maintenance costs, are suitable for small and medium-sized software development teams, and ensure the stability and compatibility of the database field structure.
Patent Information
- Application Number
- CN202111170123.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-08
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-10-08
AI Technical Summary
Existing technology is difficult to effectively manage the problem of out-of-bounds values of enumerated fields in the database, resulting in a disconnect between system design requirements documents and code information, high operation and maintenance costs, and low efficiency, especially in distributed microservice architectures.
By defining the constrained value range and logical meaning of the enumerated field, construct a string description of a specific grammatical structure, write the database remark information, and regularly check whether the value of the enumerated field is out of bounds through custom scheduled scheduling tasks. If so, An alarm will be issued and the remark information will be updated.
It implements the function of automatically checking enumerated field values out of bounds, saving operation and maintenance labor costs, avoiding system data contamination, expanding the usage scenarios of database table field notes, suitable for small and medium-sized software development teams, and ensuring the stability of the database field structure. Long-term stability and compatibility.
Smart Images

Figure CN113900659B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database operation and maintenance and software system development, and in particular to a method for automatically checking whether an enumeration field value is out of bounds. Background Art
[0002] When a general software application system uses a database, it needs to perform long-term daily maintenance of the database. In particular, database administrators generally deal with multiple software systems. They cannot timely understand the original intention of the system designer for the information stored in the database table. The system development team has personnel changes and the long software maintenance cycle leads to a disconnection between the system design requirements document code information. When encountering system problems and needing to check the data storage content and code implementation logic, there are often many problems, resulting in increased operation and maintenance costs and reduced efficiency. This problem is particularly common for small and medium-sized development teams, that is, due to the high cost of the display development team, more manpower cannot be invested in the continuous update of daily system code and database operation and maintenance documents. Enumeration fields in the database are very common field types. They generally have core business process attributes and determine the different directions of system information flow and control flow. Traditionally, the value range and actual meaning of enumeration fields are generally saved and updated through code comments and development documents. There will inevitably be inconsistencies between code comments and actual operation logic, especially in modern software development, which generally turns to distributed microservice architecture and complex data sources. There are complex associations between multiple systems. Once a data source is contaminated and not discovered and processed in a timely manner, the defects of enumeration fields causing system process errors or difficult maintenance will become more obvious.
[0003] Therefore, a method is needed to automatically check if the enumeration field value is out of bounds. Summary of the invention
[0004] The technical problem to be solved by the present invention is to overcome the shortcomings of existing database field information management and provide a method for automatically checking whether an enumeration field value is out of bounds.
[0005] In order to solve the above technical problems, the present invention provides a method for automatically checking enumeration field value out of bounds, characterized in that the value of the enumeration field in the current database is automatically checked according to the rules agreed in the remark information of the relevant enumeration field in the database, so as to find the enumeration field value out of bounds exception and give an alarm, and specifically comprises the following steps:
[0006] Step 1: For the enumeration type fields in the business system, define a check object that constrains the value range and field type;
[0007] Step 2: Convert the inspection object into a string description of a specific grammatical structure;
[0008] Step 3: Write the string description of the inspection object into the remark information of the corresponding enumeration field in each corresponding table of the corresponding database;
[0009] Step 4: Through a custom scheduled task, regularly read the inspection object information in the remark information of the current database table field, and compare the value information of the current database table field with its corresponding inspection object information to determine whether it meets the preset conditions. If not, it is determined to be out of bounds;
[0010] Step 5: When it is determined that the boundary is crossed in step 4, the relevant stakeholders are alerted to investigate the cause of the inconsistency, submit a new inspection object definition, and update it to the corresponding note field of the database through the database administrator;
[0011] Step 6: Continue the scheduled task check in step 4 until the scheduled task is terminated.
[0012] The specific steps of step 1 include:
[0013] Step 1-1: Define the value range attribute in the check object as FV. Specifically, according to the selected enumeration field, define the value range of the enumeration value as {V1…V m};
[0014] Step 1-2: Define the logical meaning attribute in the check object as FD. Specifically, according to the selected enumeration field, define the logical meaning of the enumeration value as {D1…D m};
[0015] Step 1-3: Define the inspection level attribute in the inspection object as CL. Specifically, when CL is 0, it means that the inspection object does not need to be inspected and notified regularly; when CL is 1, it means that the inspection object needs to be inspected regularly, no notification is made, and only the inspection result is recorded in the log; when CL is 2, it means that the inspection object needs to be inspected and notified regularly;
[0016] Step 1-4: Define the value type attribute in the inspection object as FT. Specifically, according to the selected enumeration field, define its value type as: 0 for floating point type, 1 for integer type, and 2 for string or character type;
[0017] Step 1-5: define the logical name attribute in the inspection object as FL, specifically, according to the selected enumeration field, define its logical name as FL, and the length n of the logical name does not exceed 99 and is at least 00;
[0018] The specific steps of step 2 include:
[0019] Step 2-1: For all the enumeration fields that need to be defined {F1…F n}, build inspection object {CRO1...CROn}, the properties of each inspection object include: value range, logical meaning, inspection level, value type, and logical name.
[0020] Step 2-2: Construct an ordered empty string;
[0021] Step 2-3: The value of the first character of the ordered empty string is the inspection level attribute of the inspection object;
[0022] Step 2-4: The value of the second character of the ordered empty string is the value type attribute of the inspection object;
[0023] Step 2-5: the values of the 3rd and 4th characters of the ordered empty string are the string length n of the logical name attribute of the inspection object, and the values of the 5th to n+3rd characters of the ordered empty string are the actual character values of the logical name attribute;
[0024] Step 2-6: Starting from the n+4th character of the ordered empty string, the value starts with "[" and ends with "];", and the value range is {V1...V m} and the logical meaning of {D1…D m}Composition[V i ,D i ],i∈{1…m} key-value pairs.
[0025] In step 4, the preset condition is that for the value range set agreed in the inspection object information and the value range set of the actual enumeration value of the current enumeration type field, the value range set agreed in the inspection object information must be completely contained in the value range set of the actual enumeration value of the current enumeration type field.
[0026] The specific steps of step 4 include:
[0027] Step 4-1: Customize the scheduled task program to configure the scheduled strategy for scheduled scheduling;
[0028] Step 4-2: When the timing policy condition is triggered, the timing scheduling task program reads all enumeration fields of all data writing behaviors within the timing range to form {F1…F m}gather;
[0029] Step 4-3: Traverse all the enumeration type field sets where data is written, and determine the remark information of the enumeration type field one by one. If it contains a string starting with {0,1,2} and ending with "];", then the enumeration type field contains the inspection object string remark information CRO, and add the CRO object to {CRO1…CRO n};
[0030] Step 4-4: Read all inspection objects {CRO1…CRO n}, and check the first character of each inspection object one by one, and determine the inspection level attribute according to the definition rules of the inspection level attribute in steps 1-3;
[0031] Step 4-5: When the check level attribute is CL=0, the enumeration type field is not checked. When the check level attribute is CL=1 or CL=2, the enumeration value of the enumeration type field is read and grouped to obtain {V′1…V′ k}, {V′1…V′ k} and the {V1…V m} to compare and check if V′ exists i ∈{V′1…V′ k But there is no V′ i ∈{V1…V m}, it can be determined that the enumeration value in the enumeration field is out of bounds;
[0032] Step 4-6: If the check level attribute is CL=1, the check time and the corresponding table name, field name, and field value out-of-bounds set are recorded in the system log file. The table name is the table name of the table where the enumeration type field is located, the field name is the field name of the enumeration type field, and the field value out-of-bounds set is the enumeration type field found in the previous step that does not belong to the value range {V1…V m V′ in i gather.
[0033] The beneficial effects achieved by the present invention are:
[0034] (1) The usage scenarios of database table field notes have been expanded from general simple comments to interpretable regular definitions.
[0035] (2) The present invention takes into account scenarios that are particularly suitable for use by small and medium-sized software development teams, saving the document synchronization costs of software development and operation and maintenance, and can be effective for a long time based on a database configuration.
[0036] (3) The present invention makes full use of the long-term and relative stability of the database. That is, no matter how the application system is iterated and the version is improved, the table field structure based on the database is a relatively long-term and stable structure. The subsequent iteration and upgrade of the system will consider compatibility and preservation of the DDL information of the current business database. This cleverly avoids the problem of loss and asynchrony of documents in different periods and between multiple systems.
[0037] (4) The enumeration type fields commonly used in the design of general business application systems provided by the present invention can be automatically executed by the timing software once the out-of-bounds range of the field is maintained according to the rule setting and data structure, without the need for manual intervention, thus saving the operation and maintenance manpower cost and making the business system have certain automatic maintenance characteristics. It avoids the pollution of system data due to human errors.
[0038] (5) The present invention creatively proposes to use the serialized structure of a string to store the description of the automatic inspection rules for the field, and the inspection rules support various types of extensions, and retain the key-value pair structure of the value and meaning, so as to achieve the intuitive interpretability of its own meaning, and facilitate understanding and maintenance. The addition and modification of the string can be completed through traditional database operation and maintenance tools, which is convenient and fast, and has high practical value. It has no invasive effect on the original system code structure, and has wide applicability. The method of the present invention can be used for future business systems and existing business systems to perform automatic inspection and management of enumeration field out-of-bounds. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 The present invention is a method flow chart of an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0040] The following is combined with Figure 1 The present invention is further described as follows:
[0041] like Figure 1 A method for automatically checking enumeration field value out of bounds using database field remark information is shown. By automatically checking the value of the field in the current database according to the rules agreed in the database-related enumeration field remark information, the enumeration field value is found to be out of bounds, so that the database administrator can find data anomalies in time and remind the system development team to fix the problem of inconsistency between field constraints and actual values. It is mentioned here that the database table fields include enumeration fields, but not all of them. For example, when this method monitors a database field with data written to it (which may include various types of database fields, such as general text and numeric fields), and the value actually stored in the enumeration field is also text or numeric, the enumeration field refers to the business characteristics of the field in the database table, and the business characteristics are manifested in that the value of the field is enumerable, such as type, gender, and level.
[0042] The specific steps include:
[0043] Step 1: Define a check object CheckRuleObject (CRO) with constraint value set and field type for a specific business system enumeration field through a specific format. The following is a detailed implementation description of the steps according to an example;
[0044] Step 1-1: For example, there is an order business table T in the database. There are several fields in T, among which the order status field F is an enumeration field. Define the value range attribute FV of the CRO object corresponding to the field F, and define the enumeration value set as {'0', '1', '2'}.
[0045] Step 1-2: Define the logical meaning attribute FD in the CRO object of field F, and the logical meaning description set of the corresponding FV attribute definition enumeration value is {'unpaid', 'unshipped', 'shipped'};
[0046] Step 1-3: Define the inspection level attribute CL in the CRO object of field F. When CL is 0, it means that no scheduled inspection is required. When CL is 1, it means that scheduled inspection is required but no notification is required and only the inspection result is recorded in the log. When CL is 2, it means that scheduled inspection and notification are required. In this example, field F needs to be scheduled and notified, so the CL attribute value of field F is 2;
[0047] Step 1-4: Define the field value type attribute FT in the CRO object of field F. The value type definition can be selected as floating point type 0, integer 1, string (including character type) 2. In this example, it is defined as integer, and the FT attribute value of field F is 1;
[0048] Step 1-5: Define the field logical name attribute FL in the CRO object of field F, define its logical name as "Order Type", and its length is 4 characters;
[0049] Step 2: Convert the CRO object of field F into a string description of a specific syntax structure;
[0050] Step 2-1: Construct an ordered empty string S;
[0051] Step 2-2: The first character S1 of S takes the inspection level attribute CL of the CRO object. According to the example, S = "2" at this time.
[0052] Step 2-3: The value of the second character S2 of S is the field value type attribute FT of the CRO object. According to the example, S = "21" at this time;
[0053] Step 2-4: The values of the third character S3 and the fourth character S4 of S are the string length n of the field logical name attribute FL of the CRO object. According to the example, n = 4 at this time, and S = "2104 Order Type";
[0054] Step 2-5: The n+4th character S of S n+4 It starts with "[", ends with "];", and has {V1...V m} and FD's {D1…Dm}Composition[V i ,D i ], i∈{1…m} key-value pairs, according to the example, n=4, m=3, S=“2104 Order type [0, unpaid]; [1, not shipped]; [2, shipped];”.
[0055] Step 3: Write S into the remark information of the corresponding field F in the corresponding table T of the corresponding database;
[0056] Step 4: Through a custom scheduled task, regularly read the CRO information in all the notes of the current database table field and the value information of the field in the current database, and compare them to check whether they are consistent. If they are not consistent, it is determined to be out of bounds;
[0057] Step 4-1: Customize the scheduled task program. The task program can configure the scheduled strategy for scheduled scheduling. For example, it is defined as executing once every 24 hours.
[0058] Step 4-2: Every 24 hours, the program reads all the changed values in the current target database during this period. The read information includes the changed table name, the changed field, the value before the field, and the value after the field is changed. For example, if new data is written to the order table T, and the order type field F is written in a data, and the value of F is 3, then the database change information is expressed as {table: "T", field: "F", before_value: NULL, current_value: "3"};
[0059] Step 4-3: According to the data change information in step 4-2, read the remark information of the field F where the data has changed;
[0060] Step 4-4: Read the remark information of field F as "2104 Order Type [0, Unpaid]; [1, Unshipped]; [2, Shipped];". Based on the remark CRO object string format agreed in step 1, it can be determined that field F is an enumeration field. ;
[0061] Step 4-5: Read the first character in the string, and you can get the check level CL=2, which means that the field F needs to be checked, and group all the values of the field F in the current table T to get {'0', '1', '3'}. According to the remark information string S= "2104 Order type [0, unpaid]; [1, unshipped]; [2, shipped];", it can be determined that the value range of the field F in the table T is constrained in the set {'0', '1', '2'}, because {'3'} does not belong to the subset of {'0', '1', '2'}, so it can be determined that the value of field F is out of bounds;
[0062] Step 4-6: At this time, according to the CRO object, the CL is 2, and the check time and the corresponding table name, field name, and field value are recorded in the system log file.
[0063] Step 5: Because CL = 2, it is determined to be out of bounds, and the data administrator and system development team are notified via email or SMS. If CL = 0, skip step 5.
[0064] Step 6: Relevant stakeholders investigate the causes of inconsistency, and the system development team submits a new CRO definition for field F, which is updated to the corresponding remark field of the database by the database administrator. Assuming that the CRO expression of field F should be added with check constraint support for the value, the remark information of field F should be changed to "2104[0, unpaid]; [1, not shipped]; [2, shipped, [3, returned];", thereby implementing the update of the new version of the CRO object of field F and enabling the database administrator to timely understand the business changes of table T;
[0065] Step 7: Continue the scheduled task check in step 4 until the scheduled task is terminated. During this period, continue to check whether a new value is written or modified in field F according to the scheduled task cycle. If the automatic cross-border check is terminated, the automatic cross-border check ends. In this way, automatic checking is realized without manual intervention, and the scheduled time can be set differently according to the characteristics of the project.
[0066] Compared with the prior art, the present invention overcomes the shortcomings of the existing database field information management and provides a method for automatically checking the enumeration field value out of bounds using the database field remark information, so as to find the enumeration field value out of bounds exception, so that the database administrator can find the data exception in time and remind the system development team to fix the problem of inconsistency between the field constraint and the actual value. The beneficial effects achieved are as follows:
[0067] (1) The usage scenarios of database table field notes have been expanded from general simple comments to interpretable regular definitions.
[0068] (2) The present invention takes into account scenarios that are particularly suitable for use by small and medium-sized software development teams, saving the document synchronization costs of software development and operation and maintenance, and can be effective for a long time based on a database configuration.
[0069] (3) The present invention makes full use of the long-term and relative stability of the database. That is, no matter how the application system is iterated and the version is improved, the table field structure based on the database is a relatively long-term and stable structure. The subsequent iteration and upgrade of the system will consider compatibility and preservation of the DDL information of the current business database. This cleverly avoids the problem of loss and asynchrony of documents in different periods and between multiple systems.
[0070] (4) The enumeration type fields commonly used in the design of general business application systems provided by the present invention can be automatically executed by the timing software once the out-of-bounds range of the field is maintained according to the rule setting and data structure, without the need for manual intervention, thus saving the operation and maintenance manpower cost and making the business system have certain automatic maintenance characteristics. It avoids the pollution of system data due to human errors.
[0071] (5) The present invention creatively proposes to use the serialized structure of a string to store the description of the automatic inspection rules for the field, and the inspection rules support various types of extensions, and retain the key-value pair structure of the value and meaning, so as to achieve the intuitive interpretability of its own meaning, and facilitate understanding and maintenance. The addition and modification of the string can be completed through traditional database operation and maintenance tools, which is convenient and fast, and has high practical value. It has no invasive effect on the original system code structure, and has wide applicability. The method of the present invention can be used for future business systems and existing business systems to perform automatic inspection and management of enumeration field out-of-bounds.
[0072] The above embodiments do not limit the present invention in any way. Any other improvements and applications made to the above embodiments in an equivalent transformation manner belong to the protection scope of the present invention.
Claims
1. A method for automatically checking whether an enumeration field value is out of bounds, characterized in that: By automatically checking the value of the enumeration field in the current database according to the rules agreed in the remark information of the relevant enumeration field in the database, the enumeration field value is found to be out of range and an alarm is issued, which specifically includes the following steps: Step 1: For the enumeration type fields in the business system, define a check object that constrains the value range and field type; Step 2: Convert the inspection object into a string description of a specific grammatical structure; The specific steps of step 2 include: Step 2-1: For all the enumeration fields that need to be defined {F1…F n }, build the inspection object {CRO1...CRO n }, the attributes of each inspection object include: value range, logical meaning, inspection level, value type, and logical name; Step 2-2: Construct an ordered empty string; Step 2-3: The value of the first character of the ordered empty string is the inspection level attribute of the inspection object; Step 2-4: The value of the second character of the ordered empty string is the value type attribute of the inspection object; Step 2-5: the values of the 3rd and 4th characters of the ordered empty string are the string length n of the logical name attribute of the inspection object, and the values of the 5th to n+3rd characters of the ordered empty string are the actual character values of the logical name attribute; Step 2-6: Starting from the n+4th character of the ordered empty string, the value starts with "[" and ends with "];", and the value range is {V1...V m } and the logical meaning of {D1…D m }Composition[V i ,D i ], i∈{1…m} key-value pairs; Step 3: Write the string description of the inspection object into the remark information of the corresponding enumeration field in each corresponding table of the corresponding database; Step 4: Through a custom scheduled task, regularly read the inspection object information in the remark information of the current database table field, and compare the value information of the current database table field with its corresponding inspection object information to determine whether it meets the preset conditions. If not, it is determined to be out of bounds; Step 5: When it is determined that the boundary is crossed in step 4, the relevant stakeholders are alerted to investigate the cause of the inconsistency, submit a new inspection object definition, and update it to the corresponding note field of the database through the database administrator; Step 6: Continue the scheduled task check in step 4 until the scheduled task is terminated.
2. A method for automatically checking enumeration field value out of bounds as claimed in claim 1, characterized in that: The specific steps of step 1 include: Step 1-1: Define the value range attribute in the check object as FV. Specifically, according to the selected enumeration field, define the value range of the enumeration value as {V1…V m }; Step 1-2: Define the logical meaning attribute in the check object as FD. Specifically, according to the selected enumeration field, define the logical meaning of the enumeration value as {D1…D m }; Step 1-3: Define the inspection level attribute in the inspection object as CL. Specifically, when CL is 0, it means that the inspection object does not need to be inspected and notified regularly; when CL is 1, it means that the inspection object needs to be inspected regularly, no notification is made, and only the inspection result is recorded in the log; when CL is 2, it means that the inspection object needs to be inspected and notified regularly; Step 1-4: Define the value type attribute in the inspection object as FT. Specifically, according to the selected enumeration field, define its value type as: 0 for floating point type, 1 for integer type, and 2 for string or character type; Step 1-5: define the logical name attribute in the inspection object as FL. Specifically, according to the selected enumeration field, define its logical name as FL. The length n of the logical name does not exceed 99 and is at least 00.
3. A method for automatically checking enumeration field value out of bounds as claimed in claim 2, characterized in that: In step 4, the preset condition is that for the value range set agreed in the inspection object information and the value range set of the actual enumeration value of the current enumeration type field, the value range set agreed in the inspection object information must be completely contained in the value range set of the actual enumeration value of the current enumeration type field.
4. A method for automatically checking enumeration field value out of bounds as claimed in claim 3, characterized in that: The specific steps of step 4 include: Step 4-1: Customize the scheduled task program to configure the timing strategy triggered by the scheduled scheduling; Step 4-2: When the timing policy condition is triggered, the timing scheduling task program reads all enumeration fields of all data writing behaviors within the timing range to form {F1…F m }gather; Step 4-3: Traverse all the enumeration type field sets where data is written, and determine the remark information of the enumeration type field one by one. If it contains a string starting with {0,1,2} and ending with "];", then the enumeration type field contains the check pair. Like string comment information CRO, and add the CRO object to {CRO1...CRO n }; Step 4-4: Read all inspection objects {CRO1…CRO n }, and check the first character of each inspection object one by one, and determine the inspection level attribute according to the definition rules of the inspection level attribute in steps 1-3; Step 4-5: When the check level attribute is CL=0, the enumeration type field is not checked. When the check level attribute is CL=1 or CL=2, the enumeration value of the enumeration type field is read and grouped to obtain {V′1…V′ k }, {V′1…V′ k } and the {V1…V m } to compare and check if V′ exists i ∈{V′1…V′ k But there is no V′ i ∈{V1…V m }, it can be determined that the enumeration value in the enumeration field is out of bounds; Step 4-6: If the check level attribute is CL=1, the check time and the corresponding table name, field name, and field value out-of-bounds set are recorded in the system log file. The table name is the table name of the table where the enumeration type field is located, the field name is the field name of the enumeration type field, and the field value out-of-bounds set is the enumeration type field found in the previous step that does not belong to the value range {V1…V m V′ in i gather.
