Table establishment script generation method and related device

By generating table creation scripts that align with business interfaces, the problem of inconsistency between database table design and business interfaces was resolved, enabling efficient database table creation and improving development efficiency and accuracy.

CN120872308APending Publication Date: 2025-10-31ASIAINFO TECH CHINA INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511041727.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-28
Publication Date
2025-10-31

AI Technical Summary

Technical Problem

The separation of database table design and business interface design leads to inconsistencies, resulting in problems such as distorted business implementation, low operating efficiency, and an explosion of technical debt.

Method used

By obtaining the Prompt text, including the OAS Schema, database type, and prompt words, and inputting it into a pre-built script generation model, a table creation script aligned with the business interface is automatically generated.

Benefits of technology

Completely avoid missing fields, misaligned relationships, or type mismatches, achieving 100% restoration of business interfaces, improving development efficiency, and reducing the workload of manually writing programs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120872308A_ABST
    Figure CN120872308A_ABST
Patent Text Reader

Abstract

The invention provides a table establishment script generation method and a related device, and is applied to the technical field of database-based application development. The method comprises the following steps: firstly, acquiring a Prompt prompt text, wherein the Prompt prompt text comprises an OAS Schema for describing grammar and structure of business data, a target database type of a database for storing the business data and a prompt word; and inputting the Prompt prompt text into a pre-constructed target script generation model, and outputting a table establishment script through the script generation model, so that a data table structure completely aligned with a service interface can be created. The problems of field missing, relation dislocation or type mismatching and the like caused by'two-piece 'type manual design are thoroughly avoided. According to the method, a table building script does not need to be manually designed, the processing work of analyzing and mapping OAS Schema, differences of different databases and the like of a manually written program can be greatly reduced, a large amount of time is saved, and therefore the development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database-based application development technology, and more specifically, to a method and apparatus for generating table creation scripts. Background Technology

[0002] A database stores multiple database tables; each database table stores multiple business data sets. Database design includes two aspects: database table design and business interface design. Database table design refers to planning the structure of database tables, the relationships and constraints between them, based on business requirements, data characteristics, and system goals. This includes designing table names, fields, data types, primary / foreign keys, indexes, constraints (such as NOT NULL, uniqueness, and check conditions), and the relationship methods between tables (such as one-to-one, one-to-many, and many-to-many). Business interface design, from the user and business perspective, defines the interaction specifications with the database, clarifying how external systems (such as front-ends and third-party systems) interact with the database in a standardized way to complete business operations.

[0003] In related technologies, database table design and business interface design are both done separately by humans, which may lead to inconsistencies between database tables and business interfaces, potentially causing distortion of business implementation or reduced operating efficiency. Summary of the Invention

[0004] In view of this, this application provides a method and related apparatus for generating table creation scripts, which are used to achieve consistency between database tables and business interfaces.

[0005] To achieve the above objectives, the following solution is proposed: The first aspect of this application provides a method for generating table creation scripts, including: Obtain the Prompt text, which includes the OAS Schema describing the syntax and structure of the business data, the target database type of the database storing the business data, and prompt words. The prompt words are used to suggest how to combine the OAS Schema and the target database type to obtain the table creation script. The Prompt text is input into a pre-built target script generation model, which then outputs a table creation script.

[0006] In one possible implementation, obtaining the Prompt text includes: Obtain the OAS Schema through the input boxes in the user interface; The target database type is determined from multiple database types using a first selection box in the user interface; Set the OAS Schema and the target database type in the Prompt template to obtain the Prompt prompt text, the Prompt template including the prompt words.

[0007] In one possible implementation, the input box corresponds to the first placeholder, the first selection box corresponds to the second placeholder, and setting the OAS Schema and the target database type in the Prompt template includes: Replace the first placeholder in the Prompt template with the OAS Schema; Replace the second placeholder in the Prompt template with the target database type.

[0008] In one possible implementation, the input box includes a file import button and an editing window, and obtaining the OAS Schema through the input box of the user interface includes: Import the OAS Schema using the file import button, or; Edit the OAS Schema through the editing window.

[0009] In one possible implementation, the user interface further includes a display window, and after the step of generating the table creation script through the script model, it also includes: The table creation script is displayed through the display window.

[0010] In one possible implementation, the user interface further includes a second selection box, which, before executing the step of inputting the Prompt text into a pre-built target script generation model and outputting a table creation script through the target script generation model, also includes: The target script generation model is determined from multiple script generation models using the second selection box.

[0011] A second aspect of this application provides a table creation script generation apparatus, comprising: The first acquisition module is used to acquire the Prompt text, which includes the OAS Schema describing the syntax and structure of the business data, the target database type of the database storing the business data, and prompt words. The prompt words are used to suggest how to combine the OAS Schema and the target database type to obtain the table creation script. The second acquisition module is used to input the Prompt text into a pre-built target script generation model and output a table creation script through the target script generation model.

[0012] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the table creation script generation method as described in the first aspect.

[0013] A fourth aspect of this application provides an electronic device, including at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to enable the electronic device to implement the table creation script generation method as described in the first aspect.

[0014] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the table creation script generation method as described in the first aspect.

[0015] As can be seen from the above technical solution, this application provides a method for generating table creation scripts. It obtains a Prompt text, which includes an OAS Schema describing the syntax and structure of the business data, the target database type for storing the business data, and prompt words. These prompt words indicate how to combine the OAS Schema and the target database type to obtain the table creation script. By inputting the Prompt text into a pre-built target script generation model, and outputting the table creation script through the script generation model, a data table structure perfectly aligned with the business interface can be automatically created. This completely avoids problems such as missing fields, misaligned relationships, or type mismatches caused by manual design that is disconnected from the business interface; the business implementation 100% replicates the interface definition.

[0016] This application eliminates the need for manually designing table creation scripts, significantly reducing the manual work involved in parsing, mapping, and handling differences between different databases in OAS Schema, saving considerable time and thus improving development efficiency. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a schematic diagram of a system architecture according to an embodiment of this application; Figure 2A flowchart illustrating a table creation script generation method provided in an embodiment of this application; Figure 3 A schematic diagram illustrating one implementation of the user interface provided in this application embodiment; Figure 4 A schematic diagram of yet another user interface provided for an embodiment of this application; Figure 5 A schematic diagram of a table creation script generation device provided in this application embodiment; Figure 6 This is a block diagram of an electronic device according to an embodiment of this application. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0020] The table creation script generation method and related apparatus provided in this application are applicable to any application scenario that needs to use OAS (Open API Specification) to provide a RESTful access API (Application Programming Interface) and needs to persist business data using a database. OAS, also known as the Swagger specification, is a standard specification for describing and defining RESTful web services. It provides a unified way to describe the structure, operation, and interaction of APIs, enabling developers, API providers, and consumers to better understand and use APIs.

[0021] OAS, based on JSON (JavaScript Object Notation) or YAML format, provides a set of structured specifications and conventions for defining various aspects of an API, including resources, paths, operations, parameters, responses, and security. Its main goal is to make API documentation easy to understand and highly readable, and to provide an interactive way to test and call APIs. OAS Schema is widely used in OAS to describe the data model of resources, request parameters, and response bodies. It allows defining resource attributes, data types, validation rules, etc., to ensure the accuracy and consistency of API request and response data. A Relational Database Management System (RDBMS) is a database based on the relational model, which uses tables and relationships between tables to organize data. The following are some key characteristics of relational databases: Database tables and relationships: Business data is stored in the form of database tables, each consisting of rows and columns. Relationships can be established between database tables, and these relationships are well supported in relational databases.

[0022] Structured Query Language (SQL): Relational databases use SQL as the standard query language. SQL makes querying, updating, and managing databases very convenient, enabling data manipulation in a standardized way.

[0023] Common relational databases include, but are not limited to: MySQL, Oracle, Microsoft SQL Server, PostgreSQL, AntDB, etc.

[0024] In related technologies, database table design and business interface design are often done separately, which can lead to inconsistencies between the database tables and the business interfaces. When database table design and business interface design are artificially separated and completed independently, inconsistencies in semantics, structure, or constraints are highly likely to occur. These problems can be amplified along the entire chain of "requirements → development → testing → operation → maintenance," manifesting in the following six typical categories of issues: Issue 1: Data distortion (business semantics do not match storage) Example: The business interface allows "one order to contain multiple products" (array), but the database table design only stores the single product field.

[0025] Consequence: The user actually purchased 3 items, but the system only recorded 1 item → the amount, inventory, and statistics were all incorrect.

[0026] Question 2: Runtime error (type / constraint conflict) Example: The business interface defines the amount as decimal(10,2), but the database table field uses INT.

[0027] Consequences: loss of accuracy, truncated payment amount; or direct error during insertion, resulting in ghost orders.

[0028] Question 3: Performance degradation (index / structure mismatch) Example: The business interface frequently queries orders by time period, but the database table does not have an index on order_time.

[0029] Consequences: Full table scan, QPS dropped from 200 to 5, and there were many timeouts during peak periods.

[0030] Question 4: Costs of demand changes are rising exponentially. Example: Add a "Order Remarks" field. The business interface modification takes 1 hour, but the database table structure requires review, DDL (Detailed Definition Language) processing, and a rollback window, totaling 3 days.

[0031] Consequences: Dual-track maintenance, misaligned version windows, and a 3-10 times longer deployment cycle.

[0032] Question 5: Security / Compliance Vulnerabilities Example: The business interface validates that "the user ID must exist", but the database table has no foreign key constraints.

[0033] Consequences: Forged user IDs can be inserted, leading to unauthorized access, data breaches, or non-compliant audits.

[0034] Question 6: Difficulties in operation and maintenance troubleshooting (inconsistent naming and formatting) Example: The field in the business interface is userId (camel case), while the field in the database table is user_id (underscore), resulting in discrepancies between logs and monitoring.

[0035] Consequences: Locating bugs requires repeated confirmation of field mappings across teams, doubling the mean time to recovery (MTTR) for faults.

[0036] The "two-tiered" manual design damages all six core capabilities: business semantics, data accuracy, system performance, iteration efficiency, security and compliance, and operational observability. Ultimately, this manifests as business distortion, low operational efficiency, and an explosion of technical debt.

[0037] Based on this, the table creation script generation method provided in this application obtains a Prompt text. The Prompt text includes an OAS Schema describing the syntax and structure of the business data, the target database type for storing the business data, and prompt words. These prompt words indicate how to combine the OAS Schema and the target database type to obtain the table creation script. The Prompt text is input into a pre-built target script generation model, which then outputs the table creation script, automatically generating a data table structure perfectly aligned with the business interface. This completely avoids problems such as missing fields, misaligned relationships, or type mismatches caused by manual design that is disconnected from the business interface; the business implementation 100% replicates the interface definition.

[0038] This application eliminates the need for manually designing table creation scripts, significantly reducing the manual work involved in parsing, mapping, and handling differences between different databases in OAS Schema, saving considerable time and thus improving development efficiency.

[0039] This application uses table creation scripts to create database tables. This approach focuses more on meeting user needs and business logic than on table creation techniques, helping to capture and express the core functions of the system and providing clearer operation and data interaction methods. Furthermore, the business interface design can be independent of the underlying database structure, without being limited by a specific database implementation. It can be optimized according to the needs of different platforms (such as Web and mobile applications), providing better cross-platform compatibility.

[0040] The following details the method for generating table creation scripts and the related equipment.

[0041] See Figure 1 , Figure 1 A schematic diagram of a system architecture is shown. The system may include a terminal 100 and a server 200. The server 200 can provide the methods provided in the embodiments of this application to one or more terminals.

[0042] The terminal 100 may have an application or webpage installed on it. The application or webpage can provide an interface. The terminal 100 can receive relevant parameters input by the user on the interface and send the parameters to the server 200. The server 200 can obtain the processing result based on the received parameters and return the processing result to the terminal 100.

[0043] It should be understood that in some optional implementations, the terminal 100 can also complete the action of obtaining the processing result based on the received parameters on its own, without the need for the server to cooperate. This application embodiment is not limited to this.

[0044] The following description Figure 1 The product form of the mid-terminal 100; The terminal 100 in this application embodiment can be a mobile phone, tablet computer, wearable device, vehicle device, augmented reality (AR) / virtual reality (VR) device, laptop computer, ultra-mobile personal computer (UMPC), netbook, personal digital assistant (PDA), etc., and this application embodiment does not impose any restrictions on it.

[0045] Terminal 100 may include a radio frequency unit, memory, input unit, display unit, camera (optional), audio circuitry (optional), speaker (optional), microphone (optional), headphone jack (optional), processor, external interface, power supply, and other components. Those skilled in the art will understand that the above-mentioned components are merely examples and do not constitute a limitation on the terminal or multifunctional device; it may include more or fewer components, or a combination of certain components, or different components.

[0046] The input unit can be used to receive input numeric or character information, and to generate key signal inputs related to user settings and function control of the portable multi-functional device. Specifically, the input unit may include a touchscreen (optional) and / or other input devices. Other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.

[0047] Among them, the input device can receive input data, etc.

[0048] The display unit can be used to display information input by the user or information provided to the user, various menus of the terminal, interactive interfaces, file display, and / or playback of any multimedia file. In the embodiments of this application, the display unit can be used to display interfaces, processing results, etc.

[0049] The memory can be used to store software code related to the table creation script generation method, the processor can execute the steps of the table creation script generation method, and can also schedule other units (such as the above-mentioned input unit and display unit) to achieve the corresponding functions.

[0050] This radio frequency unit (optional) can be used to receive and send signals during information transmission or calls.

[0051] In this embodiment of the application, the radio frequency unit can send data to the server 200 and receive the processing results sent by the server 200.

[0052] It should be understood that this radio frequency unit is optional and can be replaced with other communication interfaces, such as a network port.

[0053] Terminal 100 also includes a power source (such as a battery) for supplying power to the various components.

[0054] Terminal 100 also includes an external interface, which can be a standard Micro USB interface or a multi-pin connector, which can be used to connect terminal 100 to other devices for communication or to connect a charger to charge terminal 100.

[0055] Server 200 includes a bus, a processor, a communication interface, and memory. The processor, memory, and communication interface communicate with each other via the bus.

[0056] The memory can be used to store software code related to the table creation script generation method, the processor can execute the steps of the chip's table creation script generation method, and can also schedule other units to achieve the corresponding functions.

[0057] Reference Figure 2 , Figure 2 This is a flowchart illustrating a method for generating a table creation script provided in an embodiment of this application, as shown below. Figure 2 As shown in the figure, the table creation script generation method provided in this application embodiment may include steps S201 to S202, which are described in detail below.

[0058] The table creation script generation method provided in this application is applied to electronic devices, which can be understood as computers, servers, or cloud platforms with data computing and information processing capabilities.

[0059] Step S201: Obtain the Prompt text, which includes the OAS Schema describing the syntax and structure of the business data, the target database type of the database storing the business data, and a prompt word. The prompt word is used to suggest how to combine the OAS Schema and the target database type to obtain the table creation script.

[0060] It is understandable that the business interface is equivalent to the "real-world running instance" of the OAS Schema.

[0061] For example, the syntax and structure of OAS Schema describing business data include, but are not limited to: the content of one or more business objects, and the relationships between one or more business objects.

[0062] The following example illustrates the OAS Schema.

[0063] OAS Schema: components:\n schemas:\n Customer:\n type: object\nproperties:\n id:\n type: integer\n name:\n type: string\naddresses:\n type: array\n items:\n $ref: '# / components / schemas / Address'\n Address:\n type: object\n properties:\n id:\n type:integer\n street:\n type: string\n city:\n type: string\npostCode:\n type: string\n required:\n -street\n -city\n -postCode", "Sql script: " For example, the target database type includes, but is not limited to, any one of MySQL, Oracle, Microsoft SQL Server, PostgreSQL, and AntDB.

[0064] For example, prompts may include, but are not limited to: prompting the role of the script generation model (e.g., "an expert proficient in OASSchema and various relational databases"), prompting the input parameters of the script generation model (including but not limited to database type and OAS Schema), prompting the output target of the script generation model (e.g., generating corresponding table creation scripts for each business object in OAS Schema), prompting the relationship mapping rules (e.g., one-to-one, one-to-many, many-to-many), prompting database dialect adaptation, etc.

[0065] The following example illustrates the prompt words.

[0066] You are an expert proficient in OAS Schema and various relational databases (such as Oracle, MySQL, PqSql, SQL Server, AntDB, etc.). Your responsibility is to generate table creation scripts for the corresponding business objects in the OAS Schema based on the database type and OAS Schema input by the user. If there is a relationship between two business objects, you should also establish the relationship between the two database tables. If the relationship type between the two business objects is `type: array`, then the relationship is one-to-many, and should be handled correctly according to the selected database type. For example, if the relationship between the two business objects is a one-sided one-to-many relationship, you only need to add the primary key attribute of the main related table to the related database table. If the relationship between the two business objects is a two-sided one-to-many relationship, you need to add a related table to express the relationship between the two database tables. The table creation script needs to consider the characteristics of the relational database specified by the user, such as data types.

[0067] Step S202: Input the Prompt text into the pre-built target script generation model, and output the table creation script through the target script generation model.

[0068] For example, the target script generation model can be a large language model (LLM).

[0069] For example, the target script generation model is trained by taking the sample Prompt text as input and the labeled table-building script corresponding to the sample Prompt text as the training target.

[0070] For the sample Prompt text, please refer to the Prompt text documentation; it will not be repeated here. The annotation and table creation script corresponding to the sample Prompt text can be a manually written table creation script.

[0071] This application provides a method for generating table creation scripts. It obtains a Prompt text, which includes an OAS Schema describing the syntax and structure of the business data, the target database type for storing the business data, and prompt words. These prompt words indicate how to combine the OAS Schema and the target database type to obtain the table creation script. The Prompt text is input into a pre-built target script generation model, which then outputs the table creation script, creating a data table structure perfectly aligned with the business interface. This completely avoids problems such as missing fields, misaligned relationships, or type mismatches caused by disjointed manual design; the business implementation 100% replicates the interface definition.

[0072] This application eliminates the need for manually designing table creation scripts, significantly reducing the manual work involved in parsing, mapping, and handling differences between different databases in OAS Schema, saving considerable time and thus improving development efficiency.

[0073] It is understood that there are multiple ways to implement step S201. The embodiments of this application provide, but are not limited to, the following method, which includes the following steps A11 to A13.

[0074] Step A11: Obtain the OAS Schema through the input box of the user interface.

[0075] Step A12: Determine the target database type from multiple database types using the first selection box in the user interface.

[0076] Step A13: Set the OAS Schema and the target database type in the Prompt template to obtain the Prompt prompt text, the Prompt template including the prompt words.

[0077] For example, step A13 can be executed via background program code.

[0078] To help those skilled in the art better understand steps A11 to A13 provided in this application, the following examples are provided for illustration. (See also...) Figure 3 This is a schematic diagram illustrating one implementation of the user interface provided in an embodiment of this application.

[0079] Figure 3 The input boxes include, but are not limited to: the file import button 31 and the editing window 32.

[0080] For example, multiple OAS Schemas can be set up in advance, and then the required OAS Schema can be imported through the file import button.

[0081] For example, the OAS Schema can be manually written in the editing window.

[0082] For example, the required OAS Schema can be imported via the file import button, and the imported OAS Schema is displayed in the editing window 32, which can be manually edited.

[0083] like Figure 3 As shown, the first selection box can be selection box 33.

[0084] For example, the drop-down menu of selection box 33 may include, but is not limited to: MySQL, Oracle, Microsoft SQL Server, PostgreSQL, and AntDB.

[0085] As you can see, the table creation scripts generated by the same OAS Shema differ depending on the selected database type. For example, if the target database type is MySQL, the table creation script uses the VARCHAR data type; if the target database type is Oracle, the table creation script uses the VARCHAR2 data type; if the target database type is MySQL, the table creation script uses the INT data type; and if the target database type is Oracle, the table creation script uses the NUMBER data type.

[0086] For example, if the user clicks the "Confirm" button in the user interface, step A13 can be executed. That is, after clicking the "Confirm" button, the target script can be invoked to generate the model. Specifically, clicking the "Confirm" button calls the background program code with the selected target database type and OAS Schema content as parameters. The background program code calls the API of the target script to generate the model, generates the table creation scripts for the corresponding database tables, and displays them in the display window.

[0087] Here is an example of code that calls the target script to generate the model: response = model.generate_content(prompt_parts).

[0088] It is understood that there are multiple ways to implement step A13. The embodiments of this application provide, but are not limited to, the following methods, which may include steps B1 to B2.

[0089] The input box corresponds to the first placeholder, and the first selection box corresponds to the second placeholder.

[0090] Step B1: Replace the first placeholder in the Prompt template with the OAS Schema.

[0091] Step B2: Replace the second placeholder in the Prompt template with the target database type.

[0092] The following example illustrates the prompt text for populating the OAS Schema and the target database type.

[0093] prompt_parts = [ "You are an expert in OAS Schema and various relational databases(e.g. Oracle,Mysql, PqSql, Sql Server, AntDB, etc.). Your responsibility isto generate the table building statement for the corresponding object in OASSchema based on the relational database type and OAS Schema entered by theuser. If there is a relationship between the two objects, please build therelationship between the two tables at the same time. If the type of therelationship between the two objects is type: array, the relationship betweenthe two objects is a one-to-many relationship, and it should be based on theselected database type should be handled correctly depending on the databasetype chosen. For example, if the relationship between two objects is aunilateral one-to-many relationship, you only need to add the primary keyattribute of the primary associated table to the associated table.If therelationship between two objects is a bilateral one-to-many relationship, you need to add the associated table to express the association relationship between two tables. The table building statement needs to consider the characteristics of the user-specified relational database, such as datatypes. ",. "database type: Oracle", "OAS Schema : components:\n schemas:\n Customer:\n type:object\n properties:\n id:\n type: integer\nname:\n type: string\n addresses:\n type: array\nitems:\n $ref: '# / components / schemas / Address'\n Address:\ntype: object\n properties:\n id:\n type: integer\nstreet:\n type: string\n city:\n type: string\npostCode:\n type: string\n required:\n - street\n- city\n - postCode", "Sql script: ",] In an alternative implementation, after performing step S202, the method may further include: displaying the table creation script through the display window.

[0094] like Figure 3 As shown, the display window is window 34.

[0095] For example, users can modify the table creation script displayed in the display window.

[0096] The following example illustrates the table creation script. The example used is a one-to-many relationship between two database tables.

[0097] like Figure 3 As shown in the figure, assume that the OAS Shema in the prompt text is as follows: components: schemas:Customer: type: object properties: id: type: integer name: type: stringaddresses: type: array items: $ref: '# / components / schemas / Address'Address: type: object properties: id: type: integer street: type:string city: type: string postCode: type: string required: - street -city - postCode If the target database type is Oracle, the table creation script displayed in window 34 is as follows: CREATE TABLE Customer ( id NUMBER PRIMARY KEY, name VARCHAR2(255) ); CREATE TABLE Address ( id NUMBER PRIMARY KEY, street VARCHAR2(255), city ​​VARCHAR2(255), postCode VARCHAR2(20), customer_id NUMBER, FOREIGN KEY (customer_id) REFERENCES Customer(id) ); If the target database type is MySQL, the table creation script displayed in window 34 is as follows: CREATE TABLE Customer ( id INT PRIMARY KEY, name VARCHAR(255) ); CREATE TABLE Address ( id INT PRIMARY KEY, street VARCHAR(255), city ​​VARCHAR(255), postCode VARCHAR(20), customer_id INT, FOREIGN KEY (customer_id) REFERENCES Customer(id) ); Understandably, the table creation script displayed in the window can be copied to the database management tool for execution, or saved to the relevant database management script for easy maintenance of the production database during subsequent development, testing, and production.

[0098] For example, a test database can be configured, such as Figure 3 The "Test SQL Script" button corresponds to the connection information of the test database. The connection information can be the database connection URL (Uniform Resource Locator), username, password, etc.

[0099] Clicking the "Test SQL Script" button allows you to input the table creation script into the test database to test its accuracy.

[0100] The following example illustrates a many-to-many relationship between two database tables (i.e., a customer can have multiple addresses, and an address can be used by multiple customers).

[0101] like Figure 4 The diagram shown is a schematic representation of another user interface provided in an embodiment of this application.

[0102] like Figure 4As shown, assume the OAS Schema in the Prompt prompt text is as follows: components: schemas: Customer: type: object properties: id: type: integer name: type: string Address: type: object properties: id: type: integer street: type: string city: type: string postCode: type: string required: - street - city - postCode CustomerAddress: type: object properties: customerId: type: integer addressId: type: integer required: - customerId - addressId If the target database type is Oracle, the generated table creation script is as follows: CREATE TABLE Customer ( id NUMBER GENERATED ALWAYS AS IDENTITY, name VARCHAR2(255), PRIMARY KEY (id) ); CREATE TABLE Address ( id NUMBER GENERATED ALWAYS AS IDENTITY, street VARCHAR2(255) NOT NULL, city VARCHAR2(255) NOT NULL, postCode VARCHAR2(255) NOT NULL, PRIMARY KEY (id) ); CREATE TABLE CustomerAddress ( customerId NUMBER NOT NULL, addressId NUMBER NOT NULL, PRIMARY KEY (customerId, addressId), FOREIGN KEY (customerId) REFERENCES Customer(id), FOREIGN KEY (addressId) REFERENCES Address(id) ); In an alternative implementation, the user interface further includes a second selection box 35, which, before executing the step of inputting the Prompt prompt text into a pre-built target script generation model and outputting a table creation script through the target script generation model, further includes: determining the target script generation model from multiple script generation models through the second selection box.

[0103] like Figure 3 As shown, the target script generation model can be one or more of ChatGPT4, Llama 2, and Gemini Pro.

[0104] This application utilizes a script generation model to obtain table creation scripts based on prompt text, which can significantly reduce the manual programming work of parsing, mapping, and handling differences between different databases of OAS Schema, saving a lot of coding time and greatly improving the accuracy of converting OAS Schema into table creation scripts.

[0105] If the Prompt text is the same but the database types are different, the generated table creation scripts will also be different. Therefore, this application supports various different database types and can quickly generate table creation scripts when the application migrates between different types of databases.

[0106] This application utilizes a script generation model to obtain table creation scripts based on Prompt text. The automatically generated table creation scripts are consistent with the OAS Shema, avoiding inconsistencies that may occur when writing manually, and ensuring that the database design meets business requirements and user interaction requirements.

[0107] If the database tables need to be modified, the table creation scripts can be easily regenerated based on the modified OAS Shema, thus speeding up the development process.

[0108] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0109] Although the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous.

[0110] It should be understood that the steps described in the method embodiments of this disclosure may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of this disclosure is not limited in this respect.

[0111] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including but not limited to object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer.

[0112] The above describes a method for generating a table creation script according to an embodiment of this application. The following describes the apparatus for executing the above-described method for generating a table creation script.

[0113] Please see Figure 5 , Figure 5 This is a schematic diagram of a table creation script generation device provided in an embodiment of this application. Figure 5 As shown, the table creation script generation device includes: The first acquisition module 501 is used to acquire Prompt text, which includes an OAS Schema describing the syntax and structure of the business data, the target database type of the database storing the business data, and prompt words. The prompt words are used to suggest how to combine the OAS Schema and the target database type to obtain the table creation script. The second acquisition module 502 is used to input the Prompt text into a pre-built target script generation model and output a table creation script through the target script generation model.

[0114] In one optional implementation, the first acquisition module includes: The first acquisition unit is used to acquire the OAS Schema through an input box in the user interface; The first determining unit is configured to determine the target database type from multiple database types via a first selection box in the user interface; The second acquisition unit is used to set the OAS Schema and the target database type in the Prompt template to obtain the Prompt prompt text, wherein the Prompt template includes the prompt words.

[0115] In one optional implementation, the input box corresponds to the first placeholder, the first selection box corresponds to the second placeholder, and the second acquisition unit includes: The first replacement subunit is used to replace the first placeholder in the Prompt template with the OASSchema; The second replacement subunit is used to replace the second placeholder in the Prompt template with the target database type.

[0116] In one optional implementation, the input box includes a file import button and an editing window, and the first acquisition unit includes: The import subunit is used to import the OAS Schema via the file import button, or; An editing subunit is used to edit the OAS Schema through the editing window.

[0117] In an alternative implementation, the user interface further includes a display window, and also includes: The display module is used to display the table creation script through the display window.

[0118] In an alternative implementation, the user interface further includes a second selection box, and also includes: The determination module is used to determine the target script generation model from multiple script generation models through the second selection box.

[0119] The following is for reference. Figure 6 This document illustrates a structural diagram suitable for implementing the electronic device in the embodiments of this disclosure. The electronic device in the embodiments of this disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. This electronic device is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this disclosure.

[0120] The electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from an input device 606 into a random access memory (RAM) 603. The RAM also stores various programs and data required for the operation of the electronic device. The processing unit, ROM, and RAM are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0121] Typically, the following devices can be connected to the I / O interface: input devices including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, magnetic tapes, hard disks, etc.; and communication devices 609. Communication device 609 allows the electronic device to communicate wirelessly or wiredly with other devices to exchange data. Although electronic devices with various devices are shown in the figures, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0122] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the table creation script generation methods provided in this application.

[0123] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the table creation script generation methods provided in this application.

[0124] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.

[0125] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0126] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.

[0127] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

Claims

1. A method for generating table creation scripts, characterized in that, include: Obtain the Prompt text, which includes the OASSchema describing the syntax and structure of the business data, the target database type of the database storing the business data, and prompt words. The prompt words are used to suggest how to combine the OAS Schema and the target database type to obtain the table creation script. The Prompt text is input into a pre-built target script generation model, which then outputs a table creation script.

2. The method for generating table creation scripts according to claim 1, characterized in that, The obtained Prompt prompt text includes: Obtain the OAS Schema through the input boxes in the user interface; The target database type is determined from multiple database types using a first selection box in the user interface; Set the OAS Schema and the target database type in the Prompt template to obtain the Prompt prompt text, the Prompt template including the prompt words.

3. The method for generating table creation scripts according to claim 2, characterized in that, The input box corresponds to the first placeholder, the first selection box corresponds to the second placeholder, and setting the OAS Schema and the target database type in the Prompt template includes: Replace the first placeholder in the Prompt template with the OAS Schema; Replace the second placeholder in the Prompt template with the target database type.

4. The method for generating table creation scripts according to claim 2 or 3, characterized in that, The input box includes a file import button and an editing window. Obtaining the OAS Schema through the input box of the user interface includes: Import the OAS Schema using the file import button, or; Edit the OAS Schema through the editing window.

5. The method for generating table creation scripts according to any one of claims 2 or 3, characterized in that, The user interface also includes a display window, and after the step of generating the table creation script from the target script, it further includes: The table creation script is displayed through the display window.

6. The method for generating table creation scripts according to any one of claims 2 or 3, characterized in that, The user interface also includes a second selection box, and before executing the step of inputting the Prompt prompt text into the pre-built target script generation model and outputting the table creation script through the target script generation model, it further includes: The target script generation model is determined from multiple script generation models using the second selection box.

7. A table creation script generation device, characterized in that, The table creation script generation device includes: The first acquisition module is used to acquire the Prompt text, which includes the OAS Schema describing the syntax and structure of the business data, the target database type of the database storing the business data, and prompt words. The prompt words are used to suggest how to combine the OAS Schema and the target database type to obtain the table creation script. The second acquisition module is used to input the Prompt text into a pre-built target script generation model and output a table creation script through the target script generation model.

8. A computer program product, characterized in that, It includes computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the table creation script generation method as described in any one of claims 1 to 6.

9. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the electronic device can implement the table creation script generation method as described in any one of claims 1 to 6.

10. A computer storage medium, characterized in that, The storage medium carries one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the table creation script generation method as described in any one of claims 1 to 6.