Method, device, equipment and medium for updating database table and querying business data
By mapping entity metadata names to database tables, a custom field configuration information collection and dynamically generating target forms is provided, which solves the problem of low efficiency in database table updates and query business data development, achieves high flexibility and scalability, and improves development efficiency.
Patent Information
- Application Number
- CN202410262050.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-07
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2044-03-07
AI Technical Summary
In the prior art, the development efficiency of updating database tables and querying business data is low, and a large amount of code is required to manually write, resulting in insufficient flexibility and scalability.
Mapping entity metadata names to database tables provides a way to update database tables and query business data, allowing developers to customize a collection of field configuration information and dynamically generate target forms, automatically create or update database tables, and reduce manual coding needs.
It improves the flexibility and scalability of the database management system, simplifies database management tasks, enhances the consistency and accuracy of data storage, and improves development efficiency.
Smart Images

Figure CN118193551B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of database technology, and in particular to a method, device, computer equipment and storage medium for updating database tables and querying business data. Background Art
[0002] In recent years, the technical threshold for developing Web programs has been relatively high. Usually, developing a Web program requires taking into account the codes of the client, server, and database.
[0003] In the related art, every time a new database table is created or the data structure of a database table is modified, a technician needs to write new code related to the database table. For example, when a new field is added to a database table, a technician needs to develop new code related to the field so that data processing operations related to the field can be performed later.
[0004] This results in low development efficiency of database-related codes. Summary of the invention
[0005] In view of this, the present invention provides a method for updating database tables and querying business data to solve the problem of low development efficiency of database related codes.
[0006] In a first aspect, the present invention provides a method for updating a database table, the method being applied to a database management system, the method comprising:
[0007] receiving a save request;
[0008] Extracting a first entity metadata name and a target form from the save request, wherein the target form is generated according to a field configuration information set pre-input by a user and a selected page template;
[0009] Determining whether a first database table exists according to the first entity metadata name;
[0010] When it is determined that the first database table exists, updating the first database table according to the target form;
[0011] or,
[0012] When it is determined that the first database table does not exist, a second database table is created according to the target form.
[0013] The method for updating a database table provided by the present invention has the following advantages:
[0014] First, developers can customize the field configuration information set and dynamically generate the target form based on the selected page template, so as to adapt to different business scenarios and data structure requirements and improve the flexibility of the database management system.
[0015] Second, when it is detected that the first database table corresponding to the metadata name of the first entity does not exist, the second database table can be automatically created according to the target form, without the need to manually write SQL scripts or for developers to update the data structure of the database table by writing code, which greatly simplifies database management tasks and enhances the scalability of the database management system.
[0016] Third, by mapping entity metadata names to database tables, the consistency and accuracy of data storage are ensured, avoiding data redundancy or omissions caused by human operations.
[0017] Fourth, this flexible data preservation mechanism eliminates the need for developers to consider the creation and modification of underlying database tables every time they add new features, thereby improving development efficiency.
[0018] In an optional implementation manner, determining whether a first database table exists according to the first entity metadata name includes:
[0019] Determining, according to the first entity metadata name, first entity metadata corresponding to the first entity metadata name;
[0020] Extracting a first database table name from the first entity metadata;
[0021] According to the first database table name, it is determined whether the first database table corresponding to the first database table name exists.
[0022] Specifically, by locating and operating database tables through entity metadata names, the business logic layer and the data storage layer are decoupled. In this way, developers can independently design and manage entity metadata without having to directly deal with complex database details, which can improve the development efficiency of database-related code.
[0023] In an optional implementation, when it is determined that the first database table exists, updating the first database table according to the target form includes:
[0024] Parsing the target form to obtain a first field set and field configuration information corresponding to each field in the first field set;
[0025] Eliminate fields of a preset type from the first field set to obtain a second field set;
[0026] The data structure of the first database table is updated according to the second field set and the field configuration information corresponding to each field in the second field set.
[0027] Specifically, since some fields in the database table are not applicable to modification operations, these fields can be screened, which can not only improve the efficiency of updating the database table, but also avoid the destruction of fields of preset types in the database table.
[0028] In an optional implementation, updating the data structure of the first database table according to the second field set and the field configuration information corresponding to each field in the second field set includes:
[0029] Traversing the second field set;
[0030] Each time a field is traversed, determining whether there is a first field matching the traversed field in the first database table;
[0031] When it is determined that the first field does not exist, adding the traversed field and field configuration information corresponding to the traversed field to the first database table;
[0032] or,
[0033] When it is determined that the first field exists, determining whether the field configuration information of the first field matches the field configuration information corresponding to the traversed field;
[0034] or,
[0035] When it is determined that the field configuration information of the first field does not match the field configuration information corresponding to the traversed field, updating the field configuration information of the first field according to the field configuration information corresponding to the traversed field;
[0036] When it is determined that the field configuration information of the first field matches the field configuration information corresponding to the traversed field, traverse the next field in the second field set;
[0037] After traversing all the fields in the second field set, a database table with an updated data structure is obtained.
[0038] Specifically, by traversing the fields and matching the field configuration information, it is possible to accurately determine whether to perform a new field operation, an update field operation, or no operation is required, thereby ensuring that the data structure of the database table is in a correct state.
[0039] In an optional implementation, when the target form further includes at least one piece of business data and a business data identifier corresponding to each piece of business data, when it is determined that the first database table exists, updating the first database table according to the target form includes:
[0040] Determine, according to the target business data identifier, whether there is first business data corresponding to the target business data identifier in the first database table, wherein the target business data identifier is a business data identifier corresponding to any business data in the at least one business data;
[0041] When it is determined that the first business data exists, updating the first business data according to the second business data corresponding to the target business data identifier in at least one piece of business data;
[0042] or,
[0043] When it is determined that the first business data does not exist, the identifier of the second business data and the second business data are added to the first database table.
[0044] Specifically, according to the business data identifier, it can be accurately determined whether there is corresponding business data in the database table, thereby achieving accurate update of the database table.
[0045] In an optional implementation, when the second business data includes an associated entity metadata field, the method further includes:
[0046] Extracting a second entity metadata name and at least one piece of associated business data from an associated entity metadata field of the second business data;
[0047] According to the second entity metadata name, determining a third database table corresponding to the second entity metadata name;
[0048] Add each piece of associated business data to the third database table;
[0049] The target business data identifier is added to the association table field corresponding to each piece of associated business data in the third database table.
[0050] Specifically, by setting the associated entity metadata field, the association relationship between two database tables can be realized, so as to adapt to various types of business needs. For example, by realizing a one-to-many or many-to-many relationship through the associated entity metadata field and the associated table field, compared with nested storage of a large amount of associated information in a single table, storage space utilization and query performance can be improved.
[0051] In a second aspect, the present invention provides a method for querying business data, the method being applied to the database management system as described in the first aspect, the method comprising:
[0052] receiving a query request;
[0053] Parsing the query request to obtain entity metadata name and query conditions;
[0054] According to the entity metadata name, determining a target database table corresponding to the entity metadata name;
[0055] According to the query condition and the target database table, at least one piece of business data corresponding to the query condition is acquired.
[0056] The method for querying business data provided by the present invention has the following advantages:
[0057] First, parsing query requests into entity metadata names and query conditions can achieve modular processing of database operations. Each step is independent of each other. When the requirements change, only the corresponding module needs to be modified or expanded without affecting other parts of the overall system.
[0058] Second, the target database table is dynamically determined by the entity metadata name, making the database management system highly flexible and able to cope with different business scenarios and data models. There is no need to write specific query code for each table, which can improve the development efficiency of database-related code.
[0059] Third, searching directly in the target database table according to the query conditions can reduce the scanning of all tables in the database and improve data query efficiency.
[0060] In an optional implementation, the query condition includes at least one business data identifier; and acquiring at least one business data corresponding to the query condition according to the query condition and the target database table includes:
[0061] According to each business data identifier, business data corresponding to each business data identifier is obtained from the target database table.
[0062] Specifically, the database table is first determined based on the entity metadata name, and then a unique business data identifier is used for accurate search, which can quickly locate the business data and improve data retrieval efficiency.
[0063] In an optional implementation, when the database table includes an associated entity metadata field, the method further includes:
[0064] According to the entity metadata name, determining the target entity metadata corresponding to the entity metadata name;
[0065] According to the target entity metadata, acquiring associated entity metadata corresponding to the target entity metadata;
[0066] Parsing the associated entity metadata to obtain an associated database table name;
[0067] According to the associated database table name, determining a target associated database table corresponding to the associated database table name;
[0068] According to the target business data identifier, determining at least one associated business data corresponding to the target business data identifier in the target associated database table, wherein the target business data identifier is any one of the at least one business data identifier;
[0069] The target business data and at least one associated business data corresponding to the target business data identifier are spliced to obtain spliced business data, wherein the target business data is the business data corresponding to the target business data identifier in the at least one business data.
[0070] Specifically, the associated business data is obtained by associating entity metadata, thereby ensuring the integrity of the business data and making the displayed or processed business data more comprehensive.
[0071] In an optional embodiment, the method further includes:
[0072] Acquire field configuration information corresponding to each field in the target business data from the database table;
[0073] According to the field configuration information corresponding to each field in the target business data, the field value corresponding to each field in the target business data is converted to obtain the target business data after the field value is converted.
[0074] Specifically, by converting field values through field configuration information, effective verification and processing can be performed before data enters the database, thereby avoiding database anomalies caused by data that does not meet the specifications.
[0075] In a third aspect, the present invention provides a device for updating a database table, the device being applied to a database management system, the device comprising:
[0076] A receiving module, used for receiving a saving request;
[0077] An extraction module, configured to extract a first entity metadata name and a target form from the save request, wherein the target form is generated according to a field configuration information set pre-input by a user and a selected page template;
[0078] A determination module, configured to determine whether a first database table exists according to the first entity metadata name;
[0079] An updating module, configured to update the first database table according to the target form when it is determined that the first database table exists;
[0080] or,
[0081] A creation module is used to create a second database table according to the target form when it is determined that the first database table does not exist.
[0082] In a fourth aspect, the present invention provides a device for querying business data, the device being applied to a database management system, the device comprising:
[0083] A receiving module, used for receiving a query request;
[0084] A parsing module, used to parse the query request to obtain the entity metadata name and query conditions;
[0085] A determination module, configured to determine a target database table corresponding to the entity metadata name according to the entity metadata name;
[0086] The acquisition module is used to acquire at least one piece of business data corresponding to the query condition according to the query condition and the target database table.
[0087] In a fifth aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for updating a database table of the above-mentioned first aspect or any corresponding embodiment thereof, or executes the method for querying business data of the above-mentioned second aspect or any corresponding embodiment thereof by executing the computer instructions.
[0088] In a sixth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for updating a database table according to the first aspect or any corresponding embodiment thereof, or to execute the method for querying business data according to the second aspect or any corresponding embodiment thereof.
[0089] In the seventh aspect, the present invention provides a computer program product, comprising computer instructions, which are used to enable a computer to execute the method for updating a database table according to the above-mentioned first aspect or any corresponding embodiment, or to execute the method for querying business data according to the above-mentioned second aspect or any corresponding embodiment. BRIEF DESCRIPTION OF THE DRAWINGS
[0090] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions 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.
[0091] Figure 1 is a schematic diagram of an entity metadata design interface according to an embodiment of the present invention;
[0092] Figure 2 is a flowchart of a method for updating a database table according to an embodiment of the present invention;
[0093] Figure 3 is a flow chart of another method for updating a database table according to an embodiment of the present invention;
[0094] Figure 4 is a flowchart of another method for updating a database table according to an embodiment of the present invention;
[0095] Figure 5 is a flow chart of a method for querying business data according to an embodiment of the present invention;
[0096] Figure 6 is a flowchart of another method for querying business data according to an embodiment of the present invention;
[0097] Figure 7 is a structural block diagram of a device for updating a database table according to an embodiment of the present invention;
[0098] Figure 8 It is a structural block diagram of a device for querying service data according to an embodiment of the present invention.
[0099] Fig. 9 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0100] 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0101] In recent years, the software industry has developed rapidly, and most business functions are implemented based on the architecture of combining Web applications and databases, such as various shopping applications, office applications, etc. In traditional Web program development, adding or modifying any database-related function requires writing a lot of code.
[0102] The embodiment of the present invention provides a method for updating a database table and querying business data. The database table is updated and business data is queried through intermediate variable entity metadata, which can greatly improve the development efficiency of related codes.
[0103] The present invention is applied to a database management system, which may include a client and a server. The client may be a terminal, such as a desktop computer, a laptop computer, a mobile phone, etc. The server may be a server or a server cluster, etc. The client may be a terminal where a developer is located, or a terminal where an ordinary user is located, with a Web-side program installed. The server may be installed with a server-side program and store a database, and a large number of database tables are stored in the database.
[0104] The following is an explanation of entity metadata. Entity metadata is used to describe the corresponding database table, including the entity metadata name, database table name, default fields, custom fields, and field configuration information of custom fields.
[0105] Among them, the default fields may include primary key (ID), foreign key (MAINID, used to associate other tables), creator ID (CREATORID), creator name (CREATORNAME), creation time (CREATTIME), updater ID (UPDATERID), updater name (UPDATERNAME), update time (UPDATETIME), department (DEPT), unit (UNIT), domain ID (DOMAINID), confidentiality level (SECURITY), process instance ID (PROCESSINSTID), process current node (CURRENTNODE), process processor (CURRENTNODEUSER), process status (PROCESSSTATUS), etc. It should be noted that the default fields are not displayed in the client's form, but are only recorded in the entity metadata stored on the server. Developers can only operate on the field configuration information of custom fields on the client.
[0106] Entity metadata names, database table names, custom fields, and field configuration information for custom fields can be found in Figure 1 Configure in the design interface shown. Figure 1 The entity metadata design interface of the above-mentioned Web-side program includes three modules: entity metadata setting module, field list and form. Among them, the entity metadata setting module includes entity metadata name input box, database table name input box, page template input box and field collection input box.
[0107] The following is a detailed description of the entity metadata setting rules.
[0108] First, enter the entity metadata name in the Entity Metadata Name input box. The entity metadata name is a required entry. In the Database Table Name input box, you can select the database table name from the drop-down list, or you can leave it blank. Generally, the entity metadata name can be the same as the database table name. In the case of two different situations, the entity metadata name shall prevail. If a database table name is selected, the client can obtain the field configuration information set of the corresponding database table from the server, and the developer can modify the field configuration information set. If no database table name is entered, it means that a new entity metadata is created.
[0109] Second, the page template can be selected or not. If not selected, the default page template is used. Page templates are created in advance by developers and configured in the Web-side program. Developers can create page templates through page template editing software, such as online Velocity. Page templates can be in various page formats such as native Htm, JQueryUI, Vue, React, Amis, etc. The page template can include the form layout and the definition of each component, where the form layout includes the number of rows and columns of the form, the number of components in each row or column, etc. The definition of the component can include the display form of the component (for example, drop-down box, options, color, etc.), and the length of data that the component can fill.
[0110] Third, the field configuration information of the entity metadata can be set through the field list and field collection input box. The setting rules of the field configuration information can be as follows:
[0111] 1. Field layout.
[0112] (1) Use carriage return and line feed to separate lines;
[0113] (2) Comma separates each field in a line;
[0114] (3) The fields in each row divide the space of one row of form input equally, forming a form with one row and multiple columns;
[0115] (4) Multiple consecutive commas indicate that the preceding fields occupy multiple columns.
[0116] 2. Field type.
[0117] The default is string type, and the default display mode is a text input box. You can enter directly or select from existing options. For example, you can use "~date", "~time", "~number", "~password", "~drop-down box", "~tree", "~pop-up box" and other methods to specify input boxes of other input types. If different types of input boxes have their own unique attributes, for example, the display format of time, use the "attribute=value" format setting after the "^" symbol to set multiple attributes in sequence.
[0118] 3. Field options.
[0119] If a field needs to be selected from options, you need to use an English colon ":" to specify the option. If there is a value after the colon, select it from the value after the colon. Multi-level data uses "-" to indicate the level. View metadata (starting with "$") can be connected after the colon. In particular, if it starts with "::", it means that the value of this field can be selected multiple times. If you need to fill the data of the option band into other fields, use ">>" to start, and use the form of "value1>field name1&value2>field name2" to fill in other fields. The value supports the full expression language (EL) expression.
[0120] 4. Field hiding and read-only settings.
[0121] You can use "!" to set a field not to be displayed. You can use EL expression after "!". In this way, when the value of a field is calculated in real time to meet the preset conditions, the field will be hidden. "!!" means that the field is read-only and is used in the same way as "!".
[0122] 5. Field verification.
[0123] You can use the "*" symbol as a validation condition, which is a mandatory validation by default. You can use a regular expression or view metadata after the "*" as a validation condition (for example, a return value of "0" or "1" based on the view metadata indicates that the validation result is correct or incorrect). You can connect multiple "*" symbols in series and validate in order.
[0124] 6. Field default value.
[0125] You can use the content wrapped in %xxx% as the default value, for example, %user ID%, %current time%, %view metadata%, etc., and EL expressions are supported. In particular, when %%xxx%% is used, it means a mandatory default value. Whether adding or updating, the data will only be calculated and stored according to the default value rules, and will not be overwritten by the attributes entered in the form.
[0126] 7. Fields that associate metadata with other entities.
[0127] When you need to store fields on a form in another entity's metadata, such as in a one-to-many subtable, you can use "$$entity metadata@[0]field name" to flatten certain fields of the associated entity's metadata on this form, you can use "$$entity metadata#field name" to store comma-separated data to write associated entity data in batches, you can use "$$entity metadata" to reference an entity form as a subform, and you can use $view metadata to introduce query results as part of the form.
[0128] After the developer has configured the field configuration information, the save operation can be performed. When the client detects the developer's save operation, the page template identifier can be obtained (that is, the developer's selected or default page template). In addition, the client converts the entity metadata name, database table name, field configuration information, etc. entered by the developer into full pinyin. If the full pinyin is repeated, a suffix number 1, 2, 3, etc. is added after the full pinyin. Then, according to the page template identifier, the JS (JavaScript) file, Cascading Style Sheets file, etc. corresponding to the target page template can be obtained in the client's page template library. Finally, the client can generate the target form based on the converted field configuration information and the form layout and definitions of each component in the target page template, and display it.
[0129] The following is an example of a specific entity metadata. The corresponding form of this example is as follows: Figure 1 As shown in the upper right corner. The entity metadata name is "Employee Basic Information", the database table name is "Employee Basic Information", the page template is the default page template, and the field configuration information is:
[0130] "Name*, ID number**$ID number unique query,
[0131] Date of birth*~date, age%%YEARDIFF(CURRENTTIME-date of birth)%%,
[0132] Gender*: Male: Female, Political Status: $ Education Query>> ID> Education ID&SFBY> Graduated, Graduate School! Graduated == No, Education ID! ,
[0133] Graduation?~Switch! !, Graduation date~Date! Graduation==No, Graduation years%%YEARDIFF(CURRENTTIME-graduation date)%%,
[0134] $$Work experience^type=tab,"
[0135] Among them, except for the "Work Experience" field, every two fields occupy one line of the form. The "Name" field is required to be checked. The "ID Number" field is checked in order, and the check condition is the view metadata "ID Number Unique Query". The "Date of Birth" field is required to be checked, and the field type is "Date". The "Age" field is a mandatory default value, and the calculation method of age is specified. The "Gender" field is required to be checked, and this field is in the form of options. Ordinary users can choose "Male" or "Female" when filling in the form. The "Graduation" field is in the form of options. The values that can be selected by the options are obtained from the view metadata "Education Query", and the values with options need to be filled in other fields. The filling form is "ID>Education ID" and "SFBY>Whether to Graduate", which stipulates that the data with the "Education" option needs to be filled in other fields (that is, "Whether to Graduate"). The field type of the "Whether to Graduate" field is a switch type, and this field is in read-only mode. The field type of the "Graduation Date" field is a date type, and it is not displayed when "Whether to Graduate" is "No". The "Years of graduation" field is not displayed when the "Graduation" field is "No", and the "Years of graduation" is a mandatory default value, which specifies the calculation method of "Years of graduation". The entity metadata "Employee Basic Information" is associated with the "Work Experience" entity metadata, and the associated fields can be selected by ordinary users. For example, Figure 1 Two fields, "Unit" and "Working Time", are added.
[0136] The web application also provides an EL expression editor. Developers can assemble EL expressions in the EL expression editor using pre-made functions and custom functions. Pre-made functions can include logic judgment, digital functions, time functions, string functions, array functions, interface call functions, and other functions. Custom functions can be JS (JavaScript) functions.
[0137] According to an embodiment of the present invention, a method embodiment for updating a database table is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0138] In this embodiment, a method for updating a database table is provided, which is executed by the above-mentioned server. Figure 2 is a flowchart of a method for updating a database table according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0139] Step S201: receiving a save request, and extracting a first entity metadata name and a target form from the save request.
[0140] In implementation, when developers Figure 1 After completing the design of the entity metadata in the design interface shown, a save operation can be performed. When the client detects the save operation, a save request can be generated and sent to the server based on the name of the first entity metadata, the first database table name, the field configuration information set and the generated target form input by the developer. After receiving the save request, the server can parse the save request to obtain the first entity metadata name, the first database table name, the field configuration information set and the target form. Alternatively, the client can also only send the first entity metadata name and the target form to the server. After receiving the save request, the server can parse the save request to obtain the first entity metadata name and the target form. Among them, the first entity metadata name can be in the form of $$=xxx, or, in the JSON format "$$"="xxx".
[0141] In some optional implementations, if the server determines the first entity metadata based on the first entity metadata name, the server may update the original field configuration information set in the first entity metadata based on the field configuration information set extracted from the save request. Alternatively, the server may also parse the target form to obtain the field configuration information set, and update the original field configuration information set in the first entity metadata based on the parsed field configuration information set. If the server does not determine the first entity metadata corresponding to the first entity metadata name, the server may generate the first entity metadata based on the first entity metadata name, the first database table name, and the field configuration information set.
[0142] It should be noted that the field configuration information in the field configuration information set parsed from the target form is different from the field configuration information in the field configuration information set pre-entered by the developer, that is, the field configuration information in the target form also includes the definition of the component corresponding to the field, for example, the data length that can be filled in the field.
[0143] Step S202: Determine whether a first database table exists according to the first entity metadata name.
[0144] In implementation, the server may determine, based on the first entity metadata name, whether there is a first database table matching the first entity metadata name in the database.
[0145] Step S203: when it is determined that the first database table exists, the first database table is updated according to the target form.
[0146] In implementation, when the server determines that the first database table exists, the target form may be parsed to obtain the field types allowed by the target form, and the field types allowed by the first database table may be updated according to the field types allowed by the target form.
[0147] Step S204: when it is determined that the first database table does not exist, create a second database table according to the target form.
[0148] In implementation, when the server determines that the first database table does not exist, a data definition language (DDL) may be generated according to the target form and the entity metadata name, and the DDL may be executed to create the second database table.
[0149] The method for updating a database table provided in this embodiment enables the server to automatically update the data structure of a database table according to a received save request, or to create a new database table. Developers only need to input the entity metadata name, field configuration information set, and page template, without having to worry about the data structure in the database table, which is relatively convenient.
[0150] In this embodiment, a method for updating a database table is provided, which is executed by the above-mentioned server. Figure 3 is a flowchart of a method for updating a database table according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0151] Step S301: receiving a save request, and extracting a first entity metadata name and a target form from the save request.
[0152] The specific processing of step S301 is similar to that of step S201 and will not be repeated here.
[0153] Step S302: Determine whether a first database table exists according to the first entity metadata name.
[0154] Specifically, the above step S302 includes:
[0155] Step S3021: Determine, according to the first entity metadata name, first entity metadata corresponding to the first entity metadata name.
[0156] In implementation, the server can determine whether there is first entity metadata corresponding to the first entity metadata name according to the first entity metadata name, and if so, directly proceed to the next step. If not, the first entity metadata can be generated according to the first entity metadata name, the first database table name and the field configuration information set.
[0157] Step S3022: extract the first database table name from the first entity metadata.
[0158] In implementation, the server may parse the first entity metadata to obtain the first database table name.
[0159] Step S3023: Determine, according to the first database table name, whether there is a first database table corresponding to the first database table name.
[0160] In implementation, the server may determine, based on the first database table name, whether there is a first database table corresponding to the first database table name in the database.
[0161] Step S303: when it is determined that the first database table exists, the first database table is updated according to the target form.
[0162] Specifically, the above step S303 includes:
[0163] Step S3031: parse the target form to obtain a first field set and field configuration information corresponding to each field in the first field set.
[0164] In implementation, the server may parse the target form to obtain multiple fields and field configuration information corresponding to each field.
[0165] Step S3032: remove fields of a preset type from the first field set to obtain a second field set.
[0166] Among them, the field of the preset type is the associated entity metadata field.
[0167] In implementation, the server may remove the associated entity metadata fields from the first field set to obtain the second field set.
[0168] Step S3033: Update the data structure of the first database table according to the second field set and the field configuration information corresponding to each field in the second field set.
[0169] In some optional implementations, the above step S3033 includes:
[0170] Step a1, traverse the second field set, and each time a field is traversed, determine whether there is a first field in the first database table that matches the traversed field.
[0171] Step a2: when it is determined that the first field does not exist, the traversed field and the field configuration information corresponding to the traversed field are added to the first database table.
[0172] Step a3: When it is determined that the first field exists, determine whether the field configuration information of the first field matches the field configuration information corresponding to the traversed field.
[0173] Step a4: when it is determined that the field configuration information of the first field does not match the field configuration information corresponding to the traversed field, the field configuration information of the first field is updated according to the field configuration information corresponding to the traversed field.
[0174] Step a5, when it is determined that the field configuration information of the first field matches the field configuration information corresponding to the traversed field, traverse the next field in the second field set, and after traversing all fields in the second field set, obtain the database table with updated data structure.
[0175] For example, the data length that can be filled in the field can be modified. The data length that can be filled in the field configuration information corresponding to the traversed field is "36", and the data length that can be filled in the field configuration information of the first field is "26". "26" can be replaced with "36".
[0176] Step S304: when it is determined that the first database table does not exist, create a second database table according to the target form.
[0177] The specific processing of step S304 is similar to that of step S204 and will not be repeated here.
[0178] The method for updating a database table provided in this embodiment, first, locates and operates the database table through the entity metadata name, thereby realizing the decoupling of the business logic layer and the data storage layer. In this way, developers can independently design and manage entity metadata without having to directly deal with complex database details, which can improve the development efficiency of database-related codes. Second, since some fields in the database table are not suitable for modification operations, these fields can be screened, which can not only improve the efficiency of updating the database table, but also avoid the destruction of the fields of preset types in the database table. Third, by traversing the fields and matching the field configuration information, it can be accurately determined whether to perform a new field operation, an update field operation, or no operation is required, which can ensure that the data structure of the database table is processed in the correct state.
[0179] After developers design entity metadata, they can fill in business data in the input box of the target form. Alternatively, after developers design entity metadata and publish the target form, ordinary users can fill in business data in the input box of the target form. The client can also send the filled business data to the server, and the server will fill the business data into the corresponding database table.
[0180] Taking the example of a developer filling in business data in a target form when designing entity metadata, that is, the target form also includes at least one piece of business data and a business data identifier corresponding to each piece of business data, a method for updating a database table is provided in this embodiment, which is executed by the above-mentioned server. Figure 4 is a flowchart of a method for updating a database table according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:
[0181] Step S401: receiving a save request, and extracting a first entity metadata name and a target form from the save request.
[0182] Step S402: Determine whether a first database table exists according to the first entity metadata name.
[0183] The specific processing from step S401 to step S402 is similar to the specific processing from step S201 to step S202 (or step S301 to step S302), and will not be repeated here.
[0184] Step S403: when it is determined that the first database table exists, the first database table is updated according to the target form.
[0185] Specifically, the above step S403 includes:
[0186] Step S4031: Determine, according to the target business data identifier, whether there is first business data corresponding to the target business data identifier in the first database table.
[0187] The target business data identifier is a business data identifier corresponding to any business data in the at least one piece of business data.
[0188] In implementation, when the target form includes business data, the server can obtain at least one piece of business data and a business data identifier corresponding to each piece of business data after parsing the target form. The server can determine whether the corresponding business data exists in the first database table according to the business data identifier.
[0189] Step S4032: when it is determined that the first business data exists, the first business data is updated according to the second business data corresponding to the target business data identifier in the at least one business data.
[0190] In implementation, when the server determines that the corresponding business data exists, the corresponding business data in the first database table can be updated according to the business data extracted from the target form. Before updating the business data, the server can generate an update structured query language (SQL) according to the first database table name, business data identifier and business data, and the business data update operation can be completed after executing the SQL.
[0191] Step S4033: When it is determined that the first business data does not exist, the identifier of the second business data and the second business data are added to the first database table.
[0192] In implementation, when the server determines that the corresponding business data does not exist, an insert SQL can be generated according to the first database table name, the business data identifier and the business data, and the business data adding operation can be completed after the SQL is executed.
[0193] In some optional implementations, for each field of business data, the server can determine whether the field configuration information corresponding to the field contains configuration information of "default value setting" or "EL expression". If so, the field value of the field can be calculated according to the configuration information of "default value setting" or "EL expression" corresponding to the field to generate new business data, and then the new business data can be updated or added to the first database table.
[0194] In some optional implementations, the second business data may include an associated entity metadata field. Accordingly, the following steps may also be performed:
[0195] Step b1: extracting the second entity metadata name and at least one piece of associated business data from the associated entity metadata field of the second business data.
[0196] Step b2: determining, according to the second entity metadata name, a third database table corresponding to the second entity metadata name.
[0197] Step b3: adding each piece of associated business data to the third database table.
[0198] Step b3: adding the target business data identifier to the association table field corresponding to each piece of associated business data in the third database table.
[0199] For example, the first entity metadata name is "order", the second business data is the order data that needs to be added to the first database table, and the associated entity data field of the second business data includes the second entity metadata name "product" and multiple product purchase record information. The server needs to store the second business data in the "order table", and also needs to add multiple product purchase record information to the "product table", and record the order ID corresponding to each product purchase record in the associated table field. The second business data can be as follows:
[0200] {
[0201] "meta":"Order",
[0202] "id":"001",
[0203] …
[0204] "Product":[{"name":"Product 1"}……,{"name":"Product 2"}]……
[0205] }
[0206] An "Order Table" could be:
[0207] id:001……
[0208] id:002……
[0209] The "Product Table" can be:
[0210] name: product 1, mainid: 001, ...;
[0211] name: product 2, mainid: 001, ...;
[0212] name: product 1, mainid: 002, ...;
[0213] name: product 3, mainid: 002, ...;
[0214] Among them, mainid is the association table field.
[0215] In some optional implementations, after an ordinary user fills in business data in the input box of the target form and saves it, the save request received by the server does not include the first entity metadata name, but includes multiple business data and public business data, and each business data includes the second entity metadata name. The server can add each business data to the database table corresponding to the second entity metadata name, and add the public business data to the public attribute field of each business data.
[0216] Step S404: when it is determined that the first database table does not exist, create a second database table according to the target form.
[0217] The specific processing of step S404 is similar to that of step S204 and will not be repeated here.
[0218] The method for updating a database table provided in this embodiment can accurately determine whether there is corresponding business data in the database table according to the business data identifier, thereby accurately updating the database table. In addition, by setting the associated entity metadata field, the association relationship between two database tables can be realized, thereby adapting to various types of business needs. For example, by realizing a one-to-many or many-to-many relationship through the associated entity metadata field and the associated table field, compared with nested storage of a large amount of associated information in a single table, storage space utilization and query performance can be improved.
[0219] According to an embodiment of the present invention, a method embodiment for querying business data is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0220] In this embodiment, a method for querying business data is provided, which is executed by the above-mentioned server. Figure 5 is a flowchart of a method for updating a database table according to an embodiment of the present invention. Figure 5 As shown, the process includes the following steps:
[0221] Step S501: receiving a query request, parsing the query request, and obtaining an entity metadata name and a query condition.
[0222] In implementation, after receiving the query request, the server may parse the query request to obtain the entity metadata name and the query condition.
[0223] Step S502: Determine the target database table corresponding to the entity metadata name according to the entity metadata name.
[0224] In implementation, the server determines whether there is target entity metadata corresponding to the entity metadata name according to the entity metadata name. If yes, the server extracts the target database table name from the target entity metadata and determines the database corresponding to the target database table name in the database. If no, the server determines whether there is a target database table corresponding to the entity metadata name in the database according to the entity metadata name.
[0225] Step S503: acquiring at least one piece of business data corresponding to the query condition according to the query condition and the target database table.
[0226] In implementation, after determining the target database table, the server can generate a query SQL according to the query condition and execute the query SQL to query at least one piece of business data corresponding to the query condition. The server encapsulates the at least one piece of business data corresponding to the query condition to obtain a return result and sends it to the client, which parses the return result and displays it.
[0227] In some optional implementations, after obtaining the returned result, for each field in the database table, the server can determine whether the field configuration information of the field includes field configuration information such as "default value setting" or "EL expression". If so, the field value of the corresponding field of the business data can be calculated according to the corresponding field configuration information to obtain new business data. The server can encapsulate the new business data and send it to the client, which then parses and displays it.
[0228] The method for updating a database table provided in this embodiment, first, parses the query request into entity metadata names and query conditions, which can realize modular processing of database operations. Each step is independent of each other. When the demand changes, only the corresponding module needs to be modified or expanded without affecting other parts of the overall system. Second, the target database table is dynamically determined by the entity metadata name, so that the system has high flexibility and can cope with different business scenarios and data models. There is no need to write specific query code for each table, which can improve the development efficiency of database-related code. Third, searching directly in the target database table according to the query conditions can reduce the scanning of all tables in the database and improve data query efficiency.
[0229] In this embodiment, a method for querying business data is provided, which is executed by the above-mentioned server. Figure 6 is a flowchart of a method for updating a database table according to an embodiment of the present invention. Figure 6 As shown, the process includes the following steps:
[0230] Step S601: receiving a query request, parsing the query request, and obtaining an entity metadata name and a query condition.
[0231] Step S602: Determine the target database table corresponding to the entity metadata name according to the entity metadata name.
[0232] The specific processing from step S601 to step S602 is similar to the specific processing from step S501 to step S502, and will not be repeated here.
[0233] Step S603: acquiring at least one piece of business data corresponding to the query condition according to the query condition and the target database table.
[0234] Specifically, when the query condition includes at least one business data identifier, the above step S603 includes:
[0235] Step S6031, according to each business data identifier, obtain the business data corresponding to each business data identifier from the target database table.
[0236] In implementation, the server can traverse each of the at least one business data identifier, and each time a business data identifier is traversed, the service data corresponding to the business data identifier can be obtained from the database table. After the business data corresponding to all business data identifiers are obtained, the obtained business data can be encapsulated to generate a return result.
[0237] In some optional implementations, when the database table includes an associated entity metadata field, after step S603, the following processing may also be performed:
[0238] Step S604: Determine, according to the entity metadata name, the target entity metadata corresponding to the entity metadata name.
[0239] Step S605: acquiring, according to the target entity metadata, associated entity metadata corresponding to the target entity metadata.
[0240] Step S606: parse the associated entity metadata to obtain the associated database table name.
[0241] Step S607: determining the target associated database table corresponding to the associated database table name according to the associated database table name.
[0242] Step S608: According to the target business data identifier, at least one associated business data corresponding to the target business data identifier is determined in the target associated database table.
[0243] The target business data identifier is any business data identifier among the at least one business data identifier.
[0244] Step S609: splice the target business data and at least one piece of associated business data corresponding to the target business data identifier to obtain spliced target business data.
[0245] The target business data is business data corresponding to the target business data identifier in at least one piece of business data.
[0246] In implementation, the server can determine the target entity metadata according to the entity metadata name, and parse the target entity metadata to obtain the associated entity metadata name, and determine the associated entity metadata according to the associated entity metadata name. Then, parse the associated entity metadata to obtain the associated database table name, and determine the corresponding target associated database table according to the associated database table name. Further, the following processing is performed for each business data identifier: according to the target business data identifier, at least one associated business data corresponding to each business data identifier is obtained in the target associated database table. Specifically, the field value of the associated table field of each associated business data in the target associated database table can be compared with the target business data identifier. When the comparison result is the same, it can be determined that the associated business data is determined as the associated business data corresponding to the target business data identifier. Finally, at least one associated business data corresponding to the target business data is added to the associated entity metadata field of the target business data. In this way, the complete business data corresponding to each business data identifier can be obtained.
[0247] In some optional implementations, after obtaining at least one piece of business data, or obtaining at least one piece of spliced business data, the following operations may be performed:
[0248] Step S609: Acquire field configuration information corresponding to each field in the target business data from the database table.
[0249] Step S610 , converting the field value corresponding to each field in the target business data according to the field configuration information corresponding to each field in the target business data, to obtain the target business data after the field value is converted.
[0250] In implementation, for each field in the database table, the server can determine whether the field configuration information of the field includes configuration information such as "default value setting" or "EL expression". If so, the field value of the corresponding field of the business data can be calculated according to the corresponding configuration information to obtain new business data. The server can encapsulate the new business data and send it to the client, which then parses it and displays it.
[0251] For example, an Orders table could be:
[0252] id:001……
[0253] id:002……
[0254] The "Product Table" can be:
[0255] name: product 1, mainid: 001, ...;
[0256] name: product 2, mainid: 001, ...;
[0257] name: product 1, mainid: 002, ...;
[0258] name: product 3, mainid: 002, ...;
[0259] Where mainid is the associated table field. When the target database table is the "order table", the associated database table is the "product table", and the target business data identifier is "001", the business data is the first business data in the "order table", and the multiple associated business data are the first and second business data in the "product table".
[0260] In some optional implementations, the query conditions may also include a target field name and a target field value corresponding to the target field name. The server may determine the target field corresponding to the target field name in each piece of business data in the target database table, and determine whether the field value corresponding to the target field is equal to the target field value. If so, the business data may be determined as the target query data.
[0261] The method for querying business data provided in this embodiment obtains associated data by associating entity metadata, thereby ensuring the integrity of business data and its associated data, making the displayed or processed business data more comprehensive. In addition, by converting field values through field configuration information, effective verification and processing can be performed before data enters the database, avoiding database anomalies caused by data that does not meet the specifications.
[0262] In the present embodiment, a device for updating the database table is also provided, and the device is used to implement the above-mentioned embodiment and the preferred implementation mode, and the descriptions have been made no further. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device 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.
[0263] This embodiment provides a device for updating a database table, such as Figure 7 As shown, including:
[0264] Receiving module 701, used for receiving a save request;
[0265] An extraction module 702 is used to extract the first entity metadata name and the target form from the save request, wherein the target form is generated according to the field configuration information set pre-input by the user and the selected page template;
[0266] A determination module 703 is used to determine whether a first database table exists according to the first entity metadata name;
[0267] An updating module 704, configured to update the first database table according to the target form when it is determined that the first database table exists;
[0268] or,
[0269] The creation module 705 is used to create a second database table according to the target form when it is determined that the first database table does not exist.
[0270] In an optional implementation, the determination module 703 is configured to:
[0271] According to the first entity metadata name, determining first entity metadata corresponding to the first entity metadata name;
[0272] Extracting a first database table name from first entity metadata;
[0273] According to the first database table name, it is determined whether there is a first database table corresponding to the first database table name.
[0274] In an optional implementation, the updating module 704 is configured to:
[0275] Parsing the target form to obtain a first field set and field configuration information corresponding to each field in the first field set;
[0276] Eliminate the fields of the preset type in the first field set to obtain a second field set;
[0277] The data structure of the first database table is updated according to the second field set and the field configuration information corresponding to each field in the second field set.
[0278] In an optional implementation, the updating module 704 is configured to include:
[0279] Traverse the second field set;
[0280] Each time a field is traversed, determining whether there is a first field matching the traversed field in the first database table;
[0281] When it is determined that the first field does not exist, adding the traversed field and the field configuration information corresponding to the traversed field to the first database table;
[0282] or,
[0283] When it is determined that the first field exists, determining whether the field configuration information of the first field matches the field configuration information corresponding to the traversed field;
[0284] When it is determined that the field configuration information of the first field does not match the field configuration information corresponding to the traversed field, updating the field configuration information of the first field according to the field configuration information corresponding to the traversed field;
[0285] or,
[0286] When it is determined that the field configuration information of the first field does not match the field configuration information corresponding to the traversed field, traverse the next field in the second field set;
[0287] After traversing all the fields in the second field set, a database table with an updated data structure is obtained.
[0288] In an optional implementation, when the target form further includes at least one piece of business data and a business data identifier corresponding to each piece of business data, the updating module 704 is further configured to:
[0289] Determine, according to the target business data identifier, whether there is first business data corresponding to the target business data identifier in the first database table, wherein the target business data identifier is a business data identifier corresponding to any business data in the at least one business data;
[0290] When it is determined that the first business data exists, the first business data is updated according to the second business data corresponding to the target business data identifier in the at least one business data;
[0291] or,
[0292] When it is determined that the first business data does not exist, the identifier of the second business data and the second business data are added to the first database table.
[0293] In an optional implementation, when the second business data includes an associated entity metadata field, the updating module 704 is further configured to:
[0294] Extracting a second entity metadata name and at least one piece of associated business data from an associated entity metadata field of the second business data;
[0295] According to the second entity metadata name, determining a third database table corresponding to the second entity metadata name;
[0296] Add each piece of associated business data to the third database table;
[0297] The target business data identifier is added to the association table field corresponding to each piece of associated business data in the third database table.
[0298] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0299] The device for updating the database in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0300] In the present embodiment, a device for querying business data is also provided, and the device is used to implement the above-mentioned embodiment and preferred implementation mode, and the description has been made no further. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device 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.
[0301] This embodiment provides a device for querying business data, such as Figure 8 As shown, including:
[0302] Receiving module 801, used for receiving a query request;
[0303] The parsing module 802 is used to parse the query request to obtain the entity metadata name and the query condition;
[0304] A determination module 803 is used to determine a target database table corresponding to the entity metadata name according to the entity metadata name;
[0305] The acquisition module 804 is used to acquire at least one piece of business data corresponding to the query condition according to the query condition and the target database table.
[0306] In an optional implementation, the query condition includes at least one business data identifier; the acquisition module 804 is used to:
[0307] According to each business data identifier, the business data corresponding to each business data identifier is obtained from the target database table.
[0308] In an optional implementation, when the database table includes an associated entity metadata field, the acquisition module 804 is further configured to:
[0309] According to the entity metadata name, determine the target entity metadata corresponding to the entity metadata name;
[0310] According to the target entity metadata, obtaining the associated entity metadata corresponding to the target entity metadata;
[0311] Parse the metadata of the associated entity to obtain the associated database table name;
[0312] According to the associated database table name, determine the target associated database table corresponding to the associated database table name;
[0313] According to the target business data identifier, determining at least one associated business data corresponding to the target business data identifier in the target associated database table, wherein the target business data identifier is any one of the at least one business data identifier;
[0314] The target business data and at least one associated business data corresponding to the target business data identifier are spliced to obtain spliced business data, wherein the target business data is the business data corresponding to the target business data identifier in the at least one business data.
[0315] In an optional implementation, the acquisition module 804 is further configured to:
[0316] Obtain field configuration information corresponding to each field in the target business data from the database table;
[0317] According to the field configuration information corresponding to each field in the target business data, the field value corresponding to each field in the target business data is converted to obtain the target business data after the field value is converted.
[0318] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0319] The device for querying business data in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0320] The embodiment of the present invention also provides a computer device having the above Figure 7 The device for updating the database table shown, or having the above Figure 8 The device for querying business data is shown.
[0321] See also Fig. 9 , Fig. 9 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Fig. 9As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig. 9 A processor 10 is taken as an example.
[0322] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0323] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0324] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0325] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0326] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0327] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0328] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0329] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for updating a database table, characterized in that: The method is applied to a database management system, and the method comprises: receiving a save request; Extracting the first entity metadata name and the target form from the save request, wherein the target form is generated according to the field configuration information set pre-input by the user and the selected page template, and the target form includes at least one piece of business data and a business data identifier for each piece of business data; Determining whether a first database table exists according to the first entity metadata name; When it is determined that the first database table exists, the target form is parsed to obtain a first field set and field configuration information of each field in the first field set; Eliminate fields of a preset type from the first field set to obtain a second field set, wherein the preset type is an associated entity metadata field; updating the data structure of the first database table according to the second field set and the field configuration information of each field in the second field set; Determine, according to the target business data identifier, whether there is first business data corresponding to the target business data identifier in the first database table, wherein the target business data identifier is a business data identifier corresponding to any business data in the at least one business data; When it is determined that the first business data exists, updating the first business data according to the second business data corresponding to the target business data identifier in at least one piece of business data; Extracting a second entity metadata name and at least one piece of associated business data from an associated entity metadata field of the second business data; According to the second entity metadata name, determining a third database table corresponding to the second entity metadata name; Add each piece of associated business data to the third database table; Adding the target business data identifier to the association table field corresponding to each piece of associated business data in the third database table; or, When it is determined that the first database table does not exist, a second database table is created according to the target form.
2. The method according to claim 1, characterized in that The determining whether a first database table exists according to the first entity metadata name includes: Determining, according to the first entity metadata name, first entity metadata corresponding to the first entity metadata name; Extracting a first database table name from the first entity metadata; According to the first database table name, it is determined whether the first database table corresponding to the first database table name exists.
3. The method according to claim 1, characterized in that The updating of the data structure of the first database table according to the second field set and the field configuration information corresponding to each field in the second field set includes: Traversing the second field set; Each time a field is traversed, determining whether there is a first field matching the traversed field in the first database table; When it is determined that the first field does not exist, adding the traversed field and field configuration information corresponding to the traversed field to the first database table; or, When it is determined that the first field exists, determining whether the field configuration information of the first field matches the field configuration information corresponding to the traversed field; When it is determined that the field configuration information of the first field does not match the field configuration information corresponding to the traversed field, updating the field configuration information of the first field according to the field configuration information corresponding to the traversed field; or, When it is determined that the field configuration information of the first field does not match the field configuration information corresponding to the traversed field, traverse the next field in the second field set; After traversing all the fields in the second field set, a database table with an updated data structure is obtained.
4. The method according to claim 1, characterized in that: The method further comprises: When it is determined that the first business data does not exist, the identifier of the second business data and the second business data are added to the first database table.
5. A method for querying business data, characterized in that: The method is applied to the database management system according to any one of claims 1 to 4, and the method comprises: receiving query requests; Parsing the query request to obtain entity metadata name and query conditions; According to the entity metadata name, determining a target database table corresponding to the entity metadata name; According to the query condition and the target database table, at least one piece of business data corresponding to the query condition is acquired.
6. The method according to claim 5, characterized in that The query condition includes at least one business data identifier; and acquiring at least one business data corresponding to the query condition according to the query condition and the target database table includes: According to each business data identifier, business data corresponding to each business data identifier is obtained from the target database table.
7. The method according to claim 6, characterized in that When the database table includes an associated entity metadata field, the method further includes: According to the entity metadata name, determining the target entity metadata corresponding to the entity metadata name; According to the target entity metadata, acquiring associated entity metadata corresponding to the target entity metadata; Parsing the associated entity metadata to obtain an associated database table name; According to the associated database table name, determining a target associated database table corresponding to the associated database table name; According to the target business data identifier, determining at least one associated business data corresponding to the target business data identifier in the target associated database table, wherein the target business data identifier is any one of the at least one business data identifier; The target business data and at least one associated business data corresponding to the target business data identifier are spliced to obtain spliced business data, wherein the target business data is the business data corresponding to the target business data identifier in the at least one business data.
8. The method according to claim 6 or 7, characterized in that: The method further comprises: Acquire field configuration information corresponding to each field in the target business data from the database table; According to the field configuration information corresponding to each field in the target business data, the field value corresponding to each field in the target business data is converted to obtain the target business data after the field value is converted.
9. A device for updating a database table, characterized in that: The device is applied to a database management system, and comprises: A receiving module, used for receiving a saving request; an extraction module, configured to extract the first entity metadata name and a target form from the save request, wherein the target form is generated according to a set of field configuration information pre-input by a user and a selected page template, and the target form includes at least one piece of business data and a business data identifier of each piece of business data; A determination module, configured to determine whether a first database table exists according to the first entity metadata name; An update module, used for parsing the target form to obtain a first field set and field configuration information of each field in the first field set when it is determined that the first database table exists; removing fields of a preset type in the first field set to obtain a second field set, wherein the preset type is an associated entity metadata field; updating the data structure of the first database table according to the second field set and the field configuration information of each field in the second field set; determining whether there is first business data corresponding to the target business data identifier in the first database table according to a target business data identifier, wherein the target business data identifier is a business data identifier corresponding to any business data in at least one business data; when it is determined that the first business data exists, updating the first business data according to second business data corresponding to the target business data identifier in at least one business data; extracting a second entity metadata name and at least one associated business data from the associated entity metadata field of the second business data; determining a third database table corresponding to the second entity metadata name according to the second entity metadata name; adding each associated business data to the third database table; adding the target business data identifier to the associated table field corresponding to each associated business data in the third database table; or, A creation module is used to create a second database table according to the target form when it is determined that the first database table does not exist.
10. A device for querying business data, characterized in that: The device is applied to a database management system, and comprises: A receiving module, used for receiving a query request; A parsing module, used to parse the query request to obtain the entity metadata name and query conditions; A determination module, configured to determine a target database table corresponding to the entity metadata name according to the entity metadata name; The acquisition module is used to acquire at least one piece of business data corresponding to the query condition according to the query condition and the target database table.
11. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method for updating a database table as described in any one of claims 1 to 4, or executes the method for querying business data as described in any one of claims 5 to 8 by executing the computer instructions.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method for updating a database table according to any one of claims 1 to 4, or the method for querying business data according to any one of claims 5 to 8.
13. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to enable a computer to execute the method for updating a database table according to any one of claims 1 to 4, or the method for querying business data according to any one of claims 5 to 8.
Citation Information
Patent Citations
Data query method and device
CN113760948A
Updating method of front-end field
CN115033827A
System and method for updating database based on target form, electronic equipment and medium
CN116049196A
Data processing method and device, equipment and medium
CN117033454A