DB processing unit, query production method, and program
The DB processing device facilitates easy and automated database operations through natural language queries, addressing the limitations of existing systems by incorporating schema management and query execution units.
Patent Information
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- PROFINANSS INC
- Filing Date
- 2024-12-10
- Publication Date
- 2026-06-22
AI Technical Summary
Existing database systems are not easily operable using queries in natural language sentences.
A DB processing device that includes a schema management unit, query reception unit, query acquisition unit, and query output unit to handle queries in natural language, with additional features for execution, management, and automatic execution based on natural language sentences.
Enables easy and automated database manipulation using natural language queries, allowing for efficient query execution and result output.
Smart Images

Figure 2026100928000001_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a DB processing device that acquires queries for a database and the like.
Background Art
[0002] Conventionally, there has been a database processing device that can easily change the setting of data extraction conditions according to a user (see Patent Document 1). Such a device is a database processing device that extracts data from a database that stores tables in which data is stored, and includes an acquisition unit that acquires information representing a user and information representing data to be extracted, and a setting information storage unit that stores, in association with each other, information representing a user and dataset information representing conditions for data that can be referred to by the user. A query generation unit that acquires the dataset information corresponding to the information representing the user acquired by the acquisition unit from the setting information storage unit, and generates a query based on the acquired dataset information and the information representing the data to be extracted acquired by the acquisition unit; and a query execution unit that extracts data from the database by executing the query generated by the query generation unit. It is a database processing device characterized by comprising:
Prior Art Documents
Patent Documents
[0003]
Patent Document 1
Summary of the Invention
Problems to be Solved by the Invention
[0004] However, in the prior art, the database could not be easily operated using queries in natural language sentences.
Means for Solving the Problems
[0005] The DB processing device of this first invention comprises a schema management unit that stores schema information that identifies the structure of the database, a query reception unit that accepts queries in natural language, a query acquisition unit that provides the schema information and queries to a generating AI and retrieves queries from the generating AI, and a query output unit that outputs the queries obtained by the query acquisition unit.
[0006] This configuration allows for easy database manipulation by obtaining queries using natural language sentences.
[0007] Furthermore, the DB processing device of this second invention is a DB processing device that, compared to the first invention, further comprises an execution unit that executes queries acquired by a query acquisition unit and acquires the execution results, and a result output unit that outputs the execution results acquired by the execution unit.
[0008] This configuration allows for easy manipulation of the database through queries using natural language sentences.
[0009] Furthermore, the DB processing device of this third invention, compared to the second invention, further comprises a query management unit that stores queries that are automatically executed when execution conditions are met, and a determination unit that determines whether or not the execution conditions have been met. The execution unit is a DB processing device that executes the queries in the query management unit and obtains the execution results when the determination unit determines that the execution conditions have been met.
[0010] This configuration allows for easy and automated manipulation of the database using queries obtained from natural language statements.
[0011] Furthermore, the DB processing device of this fourth invention, compared to the third invention, further comprises an execution information acquisition unit that acquires execution information, which is information relating to the automatic execution of queries, based on queries in natural language sentences, and a query output unit that stores queries in a query management unit, associating them with the execution information acquired by the execution information acquisition unit.
[0012] With this configuration, it is possible to obtain queries based on natural language statements, as well as information regarding the automatic execution of those queries.
[0013] Furthermore, the DB processing device of this fifth invention is a DB processing device that, in addition to any one of the first to fourth inventions, has a schema management unit that stores two or more schema information corresponding to different user identifiers, a query reception unit that receives queries corresponding to user identifiers, and a query acquisition unit that acquires schema information from the schema management unit that is paired with the user identifier corresponding to the query received by the query reception unit, provides the schema information and the query to the generation AI, and acquires the query from the generation AI.
[0014] This configuration allows for easier manipulation of the database through queries using natural language sentences.
[0015] Furthermore, the DB processing device of this sixth invention is a DB processing device that, in addition to any one of the first to fourth inventions, has a schema management unit that stores two or more schema information, a schema determination unit that determines schema information corresponding to a natural language query received by a query reception unit, and a query acquisition unit that acquires the schema information determined by the schema determination unit from the schema management unit, provides the schema information and the query to a generation AI, and acquires the query from the generation AI.
[0016] This configuration allows for easier manipulation of the database through queries using natural language sentences.
[0017] Furthermore, the DB processing device of the seventh invention further comprises a template management unit that stores prompt templates which are the basis for constructing prompts given to the generating AI, and a query acquisition unit that places schema information and queries in the variable locations of the prompt template to construct a prompt, provides the prompt to the generating AI, and acquires queries from the generating AI.
[0018] This configuration allows for easy manipulation of the database through queries using natural language sentences.
[0019] Also, the DB processing apparatus of the eighth invention is a DB processing apparatus in which the query is a SQL statement for any one of the first to seventh inventions.
[0020] With such a configuration, it is possible to easily obtain a SQL statement that can operate a database by a query in a natural language sentence.
Effect of the Invention
[0021] According to the DB processing apparatus of the present invention, a database can be easily operated by a query in a natural language sentence.
Brief Description of the Drawings
[0022] [Figure 1] Conceptual diagram of information system A in Embodiment 1 [Figure 2] Block diagram of the information system A [Figure 3] Flowchart for explaining an operation example of the DB processing apparatus 1 [Figure 4] Flowchart for explaining an example of the query acquisition process [Figure 5] Flowchart for explaining an example of the schema acquisition process [Figure 6] Flowchart for explaining an example of the schema determination process [Figure 7] Flowchart for explaining an example of the execution information acquisition process [Figure 8] Flowchart for explaining an example of the automatic execution process of the query [Figure 9] Flowchart for explaining an operation example of the terminal device 2 [Figure 10] Diagram showing an example of the prompt template [Figure 11] Diagram showing an example of the schema management table [Figure 12] Diagram showing an example of the execution condition management table [Figure 13] Diagram showing an example of the schema information [Figure 14] Diagram showing an example of the prompt [Figure 15] A diagram showing an example of the same query. [Figure 16] A diagram showing an example of the query management table. [Figure 17] A diagram showing an example of the execution result. [Figure 18] Block diagram of the computer system [Modes for carrying out the invention]
[0023] The following describes embodiments of the DB processing device and the like with reference to the drawings. Note that components denoted by the same reference numerals in these embodiments perform similar operations, and therefore, further explanation may be omitted.
[0024] (Embodiment 1) In this embodiment, a DB processing device is described that provides a natural language query and schema information of a database (hereinafter referred to as "DB" as appropriate) to a generating AI, retrieves the query from the generating AI, and outputs it.
[0025] In this embodiment, a DB processing device that executes the acquired query and outputs the execution result will be described.
[0026] In this embodiment, a DB processing device that automatically executes queries based on execution information associated with acquired queries will be described.
[0027] In this embodiment, a database processing device that automatically acquires execution information based on queries in natural language will be described.
[0028] In this embodiment, a DB processing device that manages schema information for each user will be described.
[0029] In this embodiment, a database processing device that automatically determines schema information corresponding to a query will be described.
[0030] In this embodiment, a DB processing device that uses a prompt template to configure prompts to be given to the generating AI will be described.
[0031] In this specification, information X being associated with information Y means that information Y can be obtained from information X, or information X can be obtained from information Y, and the method of association is irrelevant. Information X and information Y may be linked, may reside in the same buffer, may information X be contained in information Y, or information Y may be contained in information X, and so on.
[0032] Furthermore, in this specification, selecting or determining information Z means obtaining information Z, obtaining a pointer to information Z, obtaining the ID of information Z, setting a flag on information Z, etc., and it is sufficient to be able to access information Z.
[0033] Figure 1 is a conceptual diagram of information system A in this embodiment.
[0034] Information system A comprises a DB processing device 1, one or more terminal devices 2, and one or more generation AI devices 3.
[0035] DB Processing Unit 1 is a device that receives natural language queries and database schema information, provides them to Generation AI Device 3, retrieves queries from Generation AI Device 3, and outputs them. DB Processing Unit 1 is usually a server. DB Processing Unit 1 can be, for example, a cloud server or an ASP server, but the type is not specified. DB Processing Unit 1 can also be a terminal. If DB Processing Unit 1 is a terminal, DB Processing Unit 1 can be, for example, a smartphone, a personal computer, or a tablet device, but the type is not specified. If DB Processing Unit 1 is a terminal, Terminal Device 2 is not required.
[0036] Terminal device 2 is a terminal used by a user. Such a user is someone who wants to obtain information using a so-called database.
[0037] The generation AI device 3 is a device that has the functionality of a generation AI. In this context, the generation AI device 3 typically has the functionality of a text generation AI. The generation AI may be, for example, ChatGPT or Google Bard, but is not limited to that. Note that Google is a registered trademark. The generation AI device 3 may be, for example, a cloud server or an ASP server, but is not limited to that type. The generation AI device 3 will be referred to as the generation AI as appropriate. The DB processing device 1 may also have the functionality of a generation AI. In such cases, the generation AI device 3 is not necessary.
[0038] The DB processing unit 1 and the terminal device 2, and the DB processing unit 1 and the generation AI device 3 can communicate with each other via a network such as the Internet.
[0039] Figure 2 is a block diagram of information system A in this embodiment. The DB processing device 1 comprises a storage unit 11, a receiving unit 12, a processing unit 13, and an output unit 14.
[0040] The storage unit 11 includes a template management unit 111, a schema management unit 112, and a query management unit 113. The reception unit 12 includes a query reception unit 121. The processing unit 13 includes a schema determination unit 131, a query acquisition unit 132, an execution information acquisition unit 133, a judgment unit 134, and an execution unit 135. The output unit 14 includes a query output unit 141 and a result output unit 142.
[0041] The terminal device 2 includes a terminal storage unit 21, a terminal receiving unit 22, a terminal processing unit 23, a terminal transmission unit 24, a terminal receiving unit 25, and a terminal output unit 26.
[0042] The storage unit 11, which constitutes the DB processing unit 1, stores various types of information. These types of information include, for example, prompt templates and schema information, which will be described later.
[0043] The template management unit 111 stores one or more prompt templates.
[0044] A prompt template is a template for a prompt given to a generating AI. A prompt template typically has one or more variables, but it can also be a prompt itself. If a prompt template has variables, information is assigned to those variables to complete the prompt. These variables include, for example, variables for natural language queries and variables for schema information (described later). A prompt is the input that the generating AI uses to generate an answer.
[0045] The schema management unit 112 stores one or more schema information. Preferably, each of the one or more schema information entries is associated with a user identifier. Each of the one or more schema information entries may also be associated with other information. This other information may be, for example, information that provides an overview of the database or table corresponding to the schema information.
[0046] Schema information is information that identifies the structure of a database. Schema information typically contains one or more attribute pieces of information. Attribute information refers to information about the attributes (columns, etc.) of the database tables. Attribute information includes attribute names. Attribute information also includes type information, such as identifying the type of attribute value (data type). Attribute information also includes information indicating whether an attribute is a key or not. Schema information may also include information such as constraints and relationships between tables. Here, schema information can refer to the database itself or the tables themselves.
[0047] Furthermore, databases are typically relational databases. However, databases can also be object-oriented databases, NoSQL databases, XML databases, graph databases, CSVs, etc. In other words, you can think of it as not being limited to any particular type of database. You can also think of a database as a data source. You can think of a database as simply a collection of data.
[0048] A user identifier is information that identifies a user. Examples of user identifiers include a user ID, email address, and phone number.
[0049] The query management unit 113 stores one or more queries. Preferably, these queries are those that are automatically executed when their execution conditions are met.
[0050] It is preferable that a user identifier is associated with each of the one or more queries in the query management unit 113. It is preferable that execution information is associated with each of the one or more queries in the query management unit 113. It is preferable that a user identifier is associated with each of the one or more queries in the query management unit 113.
[0051] A query is an interface or language for manipulating a database. Preferably, queries are in SQL. However, queries can also be in other languages such as MongoDB's query language, Cassandra's CQL, or Gremlin. The query shown above is an example of such a query. In other words, a query here is typically a query written in natural language.
[0052] Execution information refers to information related to the automatic execution of queries. For example, execution information indicates whether or not to automatically execute a query. For example, execution information indicates the conditions (execution conditions) for automatically executing a query. Execution conditions are, for example, conditions that specify a time (for example, 12:00 on the last day of each month, 18:00 every day, or 24:00 from Monday to Friday).
[0053] The reception unit 12 receives various instructions and information. These instructions and information include, for example, inquiries. These instructions and information include, for example, inquiries in natural language.
[0054] Here, "reception" typically refers to the reception of information transmitted via wired or wireless communication lines, but it may also be a concept that includes the reception of information input from input devices such as keyboards, mice, and touch panels, as well as the reception of information read from recording media such as optical discs, magnetic discs, and semiconductor memory.
[0055] The inquiry reception unit 121 accepts inquiries. The inquiry reception unit 121 accepts inquiries in natural language. The inquiry reception unit 121 may also accept queries. It is preferable for the inquiry reception unit 121 to accept inquiries that correspond to user identifiers.
[0056] A query is a request or question made to a database. Examples of queries in natural language include: "I want to aggregate sales by plan for each month" and "I want to know the sales figures for each sales representative in Division A for the previous month."
[0057] The processing unit 13 performs various processes. These processes include, for example, those performed by the schema determination unit 131, the query acquisition unit 132, the execution information acquisition unit 133, the judgment unit 134, and the execution unit 135.
[0058] The processing unit 13 determines, for example, whether the inquiry received by the inquiry reception unit 121 is a natural language query. The processing unit 13 determines, for example, whether the inquiry received by the inquiry reception unit 121 is a natural language query or a query.
[0059] The schema determination unit 131 determines the schema information corresponding to the natural language query received by the query reception unit 121.
[0060] The schema determination unit 131 obtains, for example, schema information from the schema management unit 112.
[0061] The schema determination unit 131, for example, obtains a user identifier that corresponds to a natural language query received by the query reception unit 121, and obtains schema information that corresponds to that user identifier from the schema management unit 112.
[0062] The schema determination unit 131, for example, vectorizes the natural language sentence received by the query reception unit 121 and obtains a natural language sentence vector. Next, the schema determination unit 131 obtains a schema vector by vectorizing the schema information for each of the two or more schema information of the schema management unit 112. Next, the schema determination unit 131 obtains the schema information corresponding to the schema vector with the highest similarity to the natural language sentence vector.
[0063] The schema determination unit 131 retrieves, for example, one or more nouns from the natural language sentence received by the inquiry reception unit 121. Next, the schema determination unit 131 retrieves, for example, schema information from the schema management unit 112 that has all the retrieved nouns as attribute names.
[0064] The query acquisition unit 132, for example, provides the schema information determined by the schema determination unit 131 and the query received by the query reception unit 121 to the generation AI, and obtains a query from the generation AI for manipulating the database. This query is the query corresponding to the query in question. In other words, this query is the information needed to obtain the information requested by the query by manipulating the database.
[0065] The query retrieval unit 132 retrieves schema information from the schema management unit 112 that corresponds to a user identifier associated with a query received by the inquiry reception unit 121. Next, the query retrieval unit 132 provides the schema information and the query received by the inquiry reception unit 121 to the generation AI, and retrieves a query from the generation AI to operate the database in response to the query.
[0066] The query acquisition unit 132, for example, acquires schema information determined by the schema determination unit 131 from the schema management unit 112, provides the schema information and the query received by the query reception unit 121 to the generation AI, and acquires a query from the generation AI to respond to the query and operate the database.
[0067] The query acquisition unit 132 constructs a prompt by, for example, placing schema information in the first variable of the prompt template and placing the query received by the query reception unit 121 in the second variable. Next, the query acquisition unit 132 provides the prompt to the generation AI and obtains the query from the generation AI.
[0068] The execution information acquisition unit 133 acquires execution information based on a query in natural language.
[0069] Execution information refers to information about the automatic execution of queries. Execution information includes execution conditions. Execution conditions are the conditions that determine when a query is executed.
[0070] The execution information acquisition unit 133, for example, determines whether periodic information exists in the natural language query, and if periodic information exists, acquires execution information indicating that the query will be automatically executed.
[0071] Regular information refers to information that indicates that the database will be operated on a regular basis. This includes information for "this month," "last month," "this week," "last week," "today," and "yesterday."
[0072] The execution information acquisition unit 133 acquires execution information indicating that the query will be executed at a predetermined time each month (for example, 12:00 on the 1st of each month) if the natural language query contains strings that indicate it will be executed monthly, such as "this month" or "last month". The execution information acquisition unit 133 acquires execution information indicating that the query will be executed at a predetermined time each week (for example, 17:00 on Friday) if the natural language query contains strings that indicate it will be executed weekly, such as "this week" or "last week". The execution information acquisition unit 133 acquires execution information indicating that the query will be executed at a predetermined time each day (for example, 24:00) if the natural language query contains strings that indicate it will be executed daily, such as "today" or "yesterday".
[0073] The determination unit 134 determines whether the execution conditions have been met. For example, the determination unit 134 obtains the current time from a clock (not shown) and determines whether the current time satisfies the execution conditions of the execution information associated with the query.
[0074] The execution unit 135 executes the query and obtains the execution result. The execution unit 135 executes the query obtained by the query acquisition unit 132 and obtains the execution result. For example, if the determination unit 134 determines that the execution conditions have been met, the execution unit 135 obtains the query corresponding to those execution conditions from the query management unit 113, executes the query, and obtains the execution result.
[0075] The output unit 14 outputs various types of information. These types of information include, for example, queries and execution results.
[0076] Here, output usually refers to transmission to terminal device 2 or storage on a recording medium, but it may also be a concept that includes display on a screen, projection using a projector, printing with a printer, sound output, transmission to devices other than terminal device 2, and delivery of processing results to other processing devices or other programs.
[0077] The query output unit 141 outputs the queries obtained by the query acquisition unit 132. The query output unit 141 stores the queries obtained by the query acquisition unit 132 in the query management unit 113, for example, by associating them with natural language queries. The query output unit 141 stores the queries obtained by the query acquisition unit 132 in the query management unit 113, for example, by associating them with user identifiers that are paired with natural language queries.
[0078] The query output unit 141, for example, associates queries with the execution information acquired by the execution information acquisition unit 133 and stores them in the query management unit 113.
[0079] The result output unit 142 outputs the execution results obtained by the execution unit 135. The result output unit 142, for example, sends the execution results obtained by the execution unit 135 to the terminal device 2. The transmission to the terminal device 2 is, for example, notification of the execution results obtained by the execution unit 135 to the user identified by the user identifier paired with the query that forms the basis of the query on which the execution results are based. The means of notifying the user include email, short message, output to the terminal device 2 when the user logs in to the DB processing unit 1, etc. The means of notifying the user is not limited.
[0080] The terminal storage unit 21, which constitutes the terminal device 2, stores various types of information. These types of information include, for example, natural language query data and user identifiers.
[0081] The terminal reception unit 22 receives input such as instructions and information from the user. Instructions and information include, for example, inquiries in natural language.
[0082] The means of inputting instructions and information can be anything, such as a touch panel, keyboard, mouse, or menu screen. The terminal reception unit 22 can be implemented using device drivers for input means such as touch panels and keyboards, or control software for menu screens.
[0083] The terminal processing unit 23 performs various processes. These processes include, for example, changing the instructions and information received by the terminal receiving unit 22 into instructions and information for transmission, and changing the information received by the terminal receiving unit 25 into an output structure.
[0084] The terminal transmission unit 24 transmits various information and instructions to the DB processing unit 1. These various information and instructions include, for example, a user identifier and a query in natural language.
[0085] The terminal receiving unit 25 receives various types of information from the DB processing unit 1. These types of information include, for example, queries and execution results.
[0086] The terminal output unit 26 outputs various types of information. These types of information include, for example, various screens, queries, and execution results.
[0087] Here, output refers to, for example, display on a screen, but may also be a concept that includes projection using a projector, printing with a printer, sound output, transmission to an external device, storage on a recording medium, and transfer of processing results to other processing devices or other programs.
[0088] The storage unit 11, template management unit 111, schema management unit 112, query management unit 113, and terminal storage unit 21 are preferably made of non-volatile recording media, but can also be made of volatile recording media.
[0089] The process by which information is stored in the storage unit 11, etc. is not relevant. For example, information may be stored in the storage unit 11, etc. via a recording medium, information transmitted via a communication line, etc. may be stored in the storage unit 11, etc., or information input via an input device may be stored in the storage unit 11, etc.
[0090] The reception unit 12 and the inquiry reception unit 121 are preferably implemented by wireless or wired communication means, but may also be implemented by means of receiving broadcasts, device drivers for input means such as touch panels and keyboards, or control software for menu screens.
[0091] The processing unit 13, schema determination unit 131, query acquisition unit 132, execution information acquisition unit 133, decision unit 134, and execution unit 135 can typically be implemented using a processor, memory, etc. The processing procedures of the processing unit 13, etc., are usually implemented in software, and this software is recorded on a recording medium such as ROM. However, it may also be implemented in hardware (dedicated circuitry). The processor can be a CPU, MPU, GPU, etc., and the type is not limited.
[0092] The output unit 14, the query output unit 141, and the result output unit 142 are usually implemented by wireless or wired communication means, but they may also be implemented by a processor or memory, or by driver software for an output device such as a display or speaker, or by driver software for an output device and the output device itself.
[0093] The terminal reception unit 22 is preferably implemented by wireless or wired communication means, but may also be implemented by means of receiving broadcasts, device drivers for input means such as touch panels and keyboards, or control software for menu screens.
[0094] The terminal transmission unit 24 is usually implemented by wireless or wired communication means, but it may also be implemented by broadcasting means.
[0095] The terminal receiving unit 25 is usually implemented by wireless or wired communication means, but it may also be implemented by means of receiving broadcasts.
[0096] The terminal output unit 26 may or may not be considered to include output devices such as a display or speakers. The terminal output unit 26 can be implemented using driver software for an output device, or driver software for an output device and an output device.
[0097] Next, an example of the operation of the DB processing unit 1 will be explained using the flowchart in Figure 3.
[0098] (Step S301) The inquiry reception unit 121 determines whether or not it has received an inquiry. If it has received an inquiry, it proceeds to step S302; otherwise, it proceeds to step S310. Here, the inquiry is assumed to be associated with a user identifier. At this point, the inquiry reception unit 121 also determines, for example, whether or not it received an inquiry from terminal device 2.
[0099] (Step S302) The query retrieval unit 132 determines whether the query received in step S301 is a natural language query or a query. If it is a natural language query, it proceeds to step S303; if it is a query, it proceeds to step S305.
[0100] (Step S303) The query retrieval unit 132 retrieves a query using a natural language query. An example of such query retrieval process will be explained using the flowchart in Figure 4.
[0101] (Step S304) The query output unit 141 obtains a user identifier that corresponds to the query received in step S301. The query output unit 141 stores the query obtained in step S303 in the query management unit 113, paired with the user identifier.
[0102] (Step S305) The execution unit 135 executes the query obtained in step S303 and obtains the execution result.
[0103] (Step S306) The result output unit 142 outputs the execution result obtained in step S305.
[0104] At this point, the result output unit 142 transmits, for example, the execution result obtained in step S305 to the terminal device 2.
[0105] (Step S307) The execution information acquisition unit 133 acquires execution information. An example of this execution information acquisition process will be explained using the flowchart in Figure 7.
[0106] (Step S308) The output unit 14 determines whether or not execution information has been obtained. If execution information has been obtained, then; If execution information has not been obtained, then
[0107] (Step S309) The output unit 14 stores the execution information obtained in step S307, associated with the query obtained in step S303. Return to step S301.
[0108] (Step S310) The execution unit 135 performs automatic execution processing for one or more queries. The process returns to step S301. An example of the automatic execution processing of queries will be explained using the flowchart in Figure 8.
[0109] In the flowchart in Figure 3, processing is terminated by power-off or processing termination interrupts.
[0110] Next, an example of the query retrieval process in step S303 will be explained using the flowchart in Figure 4.
[0111] (Step S401) The query acquisition unit 132 acquires a prompt template from the template management unit 111.
[0112] (Step S402) The query retrieval unit 132 retrieves the natural language query received by the query reception unit 121.
[0113] (Step S403) The query retrieval unit 132 places the natural language query in the variable where the prompt template query is placed.
[0114] (Step S404) The schema determination unit 131 obtains schema information using a query in natural language. An example of such schema acquisition process will be explained using the flowchart in Figure 5.
[0115] (Step S405) The query acquisition unit 132 places the schema information obtained in step S404 into the variable location for placing the schema information in the prompt template. The prompt is completed through the above process.
[0116] (Step S406) The query acquisition unit 132 provides the prompt created in step S405 to the generation AI.
[0117] (Step S407) The query acquisition unit 132 determines whether or not it has obtained a response from the generating AI. If a response has been obtained, it proceeds to step S408; otherwise, it proceeds to step S407.
[0118] (Step S408) The query retrieval unit 132 retrieves the query from the answer obtained in step S407. It then returns to the higher-level processing unit. The query is the answer or a part of the information within the answer.
[0119] Next, an example of the schema acquisition process in step S404 will be explained using the flowchart in Figure 5.
[0120] (Step S501) The schema determination unit 131 determines whether or not two or more schema information exists in the schema management unit 112. If two or more schema information exists, the process proceeds to step S502; otherwise, the process proceeds to step S508.
[0121] (Step S502) The schema determination unit 131 obtains a user identifier that corresponds to the received query.
[0122] (Step S503) The schema determination unit 131 obtains one or more schema information from the schema management unit 112 that corresponds to the user identifier obtained in step S502. Note that the schema information that corresponds to the user identifier may be schema information that does not correspond to any user identifier.
[0123] (Step S504) The schema determination unit 131 determines whether there are two or more schema entries in the schema information obtained in step S503. If there are two or more schema entries, the unit proceeds to step S505; otherwise, the unit proceeds to step S507.
[0124] (Step S505) The schema determination unit 131 determines one schema from among the two or more schema information obtained in step S503. An example of such schema determination process will be explained using the flowchart in Figure 6.
[0125] (Step S506) The schema determination unit 131 retrieves the schema information determined in step S505. It returns to the higher-level processing unit.
[0126] (Step S507) The schema determination unit 131 retrieves the schema information obtained in step S503. It returns to the higher-level processing unit.
[0127] (Step S508) The schema determination unit 131 obtains schema information from the schema management unit 112. It then returns to the higher-level processing unit.
[0128] Next, an example of the schema determination process in step S505 will be explained using the flowchart in Figure 6.
[0129] (Step S601) The schema determination unit 131 retrieves the query of the received natural language sentence.
[0130] (Step S602) The schema determination unit 131 vectorizes the query obtained in step S601 and obtains a query vector. Note that the technique for vectorizing queries, which are natural language sentences, is a known technique.
[0131] (Step S603) The schema determination unit 131 assigns 1 to counter i.
[0132] (Step S604) The schema determination unit 131 determines whether the i-th schema information exists in the schema management unit 112. If the i-th schema information exists, the process proceeds to step S605; otherwise, the process proceeds to step S608. The i-th schema information is a set of words, and the technique for vectorizing such a set of words is a publicly known technique.
[0133] (Step S605) The schema determination unit 131 vectorizes the i-th schema information and obtains a schema vector.
[0134] (Step S606) The schema determination unit 131 obtains the similarity between the query vector and the i-th schema vector, associates this similarity with the i-th schema information, and temporarily stores it in a buffer (not shown).
[0135] (Step S607) The schema determination unit 131 increments counter i by 1. The process returns to step S604.
[0136] (Step S608) The schema determination unit 131 determines one or more similarities that match the selection criteria from among the similarities temporarily stored in a buffer (not shown). The selection criteria are, for example, "the similarity is the highest" or "the similarity is equal to or greater than a threshold."
[0137] (Step S609) The schema determination unit 131 determines schema information to be paired with one or more similarity values. It then returns to the higher-level processing.
[0138] Next, an example of the execution information acquisition process in step S307 will be explained using the flowchart in Figure 7.
[0139] (Step S701) The execution information acquisition unit 133 acquires the query.
[0140] (Step S702) The execution information acquisition unit 133 assigns 1 to counter i.
[0141] (Step S703) The execution information acquisition unit 133 determines whether the i-th periodic information exists in the storage unit 11. If the i-th periodic information exists, the process proceeds to step S704; otherwise, the process proceeds to step S709.
[0142] (Step S704) The execution information acquisition unit 133 acquires the i-th periodic information from the storage unit 11.
[0143] (Step S705) The execution information acquisition unit 133 determines whether or not the i-th periodic information exists in the received natural language sentence query. If the i-th periodic information exists, the unit proceeds to step S706; otherwise, it proceeds to step S708.
[0144] (Step S706) The execution information acquisition unit 133 acquires the execution condition that corresponds to the i-th periodic information from the storage unit 11.
[0145] (Step S707) The execution information acquisition unit 133 constructs execution information including the execution conditions. It then returns to the higher-level processing.
[0146] The execution information includes, for example, a flag. The flag indicates whether or not to execute automatically. For example, if information indicating that automatic execution is not performed is stored in conjunction with a user identifier, the execution information acquisition unit 133 will determine that the flag in the execution information based on the query paired with that user identifier is "Do not execute automatically (for example, "0")".
[0147] (Step S708) The execution information acquisition unit 133 increments counter i by 1. The process returns to step S703.
[0148] (Step S709) The execution information acquisition unit 133 assigns NULL to the execution information. It returns to the higher-level process.
[0149] Next, an example of the automated query execution process in step S310 will be explained using the flowchart in Figure 8.
[0150] (Step S801) The execution unit 135 obtains the current time from a clock (not shown).
[0151] (Step S802) The execution unit 135 assigns 1 to counter i.
[0152] (Step S803) The execution unit 135 determines whether or not the i-th query exists in the query management unit 113. If the i-th query exists, the process proceeds to step S804; otherwise, it returns to the higher-level processing.
[0153] (Step S804) The execution unit 135 determines whether or not execution information corresponding to the i-th query exists in the query management unit 113. If execution information exists, the process proceeds to step S805; otherwise, the process proceeds to step S809.
[0154] (Step S805) The execution unit 135 obtains execution information corresponding to the i-th query from the query management unit 113. Based on the current time and execution information obtained in step S801, it decides whether or not to automatically execute the query. If it is to be automatically executed, it proceeds to step S806; otherwise, it proceeds to step S807.
[0155] Furthermore, the execution unit 135 determines, for example, whether the current time obtained in step S801 satisfies the execution conditions of the execution information paired with the i-th query.
[0156] Furthermore, the execution unit 135 determines, for example, whether the current time obtained in step S801 satisfies the execution conditions of the execution information paired with the i-th query, and whether the flag in the execution information is "Execute automatically (e.g., "1")".
[0157] (Step S806) The execution unit 135 receives the i-th query from the query management unit 113. The execution unit 135 executes the query and obtains the execution result.
[0158] (Step S807) The execution unit 135 obtains the user identifier corresponding to the i-th query from the query management unit 113.
[0159] (Step S808) The result output unit 142 notifies the user identified by the user identifier of the execution conditions.
[0160] (Step S809) The execution unit 135 increments counter i by 1. The process returns to step S803.
[0161] Next, an example of the operation of terminal device 2 will be explained using the flowchart in Figure 9.
[0162] (Step S901) The terminal reception unit 22 determines whether or not it has received the inquiry. If the inquiry has been received, it proceeds to step S902; otherwise, it proceeds to step S906.
[0163] (Step S902) The terminal processing unit 23 obtains a user identifier from the terminal storage unit 21.
[0164] (Step S903) The terminal processing unit 23 associates the user identifier obtained in step S902 with the query received in step S901. The terminal transmission unit 24 transmits the user identifier and the query to the DB processing unit 1.
[0165] (Step S904) The terminal receiving unit 25 determines whether or not it has received an execution result from the DB processing unit 1. If an execution result has been received, the unit proceeds to step S905; otherwise, it returns to step S904.
[0166] (Step S905) The terminal processing unit 23 uses the execution result received in step S904 to construct the execution result to be output. The terminal output unit 26 outputs the execution result. The process returns to step S901.
[0167] (Step S906) The terminal receiving unit 25 determines whether or not it has received the execution result that was automatically executed and acquired by the DB processing device 1. If the execution result has been received, the process proceeds to step S907; otherwise, the process returns to step S901.
[0168] (Step S907) The terminal processing unit 23 uses the execution result received in step S906 to construct the execution result to be output. The terminal output unit 26 outputs the execution result. The process returns to step S901.
[0169] In the flowchart shown in Figure 9, processing is terminated by power-off or processing termination interrupts.
[0170] The following describes a specific example of the operation of information system A in this embodiment. Here, a query is an SQL statement.
[0171] The template management unit 111 of the DB processing unit 1 stores the prompt template shown in Figure 10. In the prompt template, strings enclosed in "{}" and "}" are variables. That is, in Figure 10, {data source / segment name}, {data source ID / segment ID}, {data source / segment summary}, {schema information}, and {natural language query from user} are variables. Note that {data source / segment name}, {data source ID / segment ID}, and {data source / segment summary} are information managed in pairs with schema information.
[0172] Furthermore, the schema management unit 112 stores the schema management table shown in Figure 11. The schema management table is a table that manages schema information. The schema management table is a table that manages one or more records that have "ID", "schema information", "data source / segment overview", etc. "Data source / segment overview" is information that shows an overview of the data source and segment. A segment is information that sets up data operations in the database. For example, a segment is information that shows the aggregation method and mapping settings. Mapping is information that sets which table and which column to store the retrieved data (query output) in when data is retrieved and aggregated from the database.
[0173] Furthermore, the storage unit 11 stores the execution condition management table shown in Figure 12. The execution condition management table is a table that manages execution conditions. The execution condition management table manages one or more records that have "ID", "period information", and "execution condition". The "execution condition" is information that identifies when a query is executed. In the "execution condition", "$time", "$day of the week", "$day", and "$month" are variables, and the information obtained when a natural language query is received is substituted into them.
[0174] The time when the natural language query was received is assigned to "$time". The day of the week when the natural language query was received is assigned to "$day". The day of the week when the natural language query was received is assigned to "$day". If "$day" is the last day of the month, information indicating "last day" is assigned to it. The month when the natural language query was received is assigned to "$month".
[0175] In the above situation, suppose user U, identified by user identifier "U01", enters the following natural language query into terminal device 2: "I would like to aggregate sales by plan on a monthly basis. Additionally, I would like to aggregate customer segments as follows: large companies with 1000 or more customers, and SMBs with fewer."
[0176] Next, terminal device 2 receives the inquiry and configures the following: "<User Identifier>U01 <Inquiry>I would like to aggregate sales by plan on a monthly basis. Additionally, I would like to aggregate customer segments as follows: large companies with 1000 or more users, and SMBs with fewer users." and sends it to DB processing device 1.
[0177] Next, the query receiving unit 121 of the DB processing unit 1 receives the user identifier and the query. Then, the query retrieval unit 132 determines that the query is a natural language query.
[0178] Next, the query retrieval unit 132 retrieves the query using the natural language query as follows: That is, the query retrieval unit 132 retrieves a prompt template (Figure 10) from the template management unit 111. Next, the query retrieval unit 132 assigns the query "I want to aggregate sales by plan on a monthly basis. Additionally, I want to aggregate customer segments as follows: large companies if there are 1000 or more customers, and SMBs if there are fewer." to the area of the variable {natural language query from the user} in the prompt template.
[0179] Furthermore, the schema determination unit 131 obtains schema information through the process described above. Here, an example of the obtained schema information is shown in Figure 13. Here, the schema determination unit 131 obtains two pieces of schema information.
[0180] Next, the query retrieval unit 132 places the two retrieved schema pieces in the variable {schema information} where the schema information of the prompt template is placed. The query retrieval unit 132 also places information that corresponds to the retrieved schema pieces in the other variable locations. As a result of the above processing, the prompt shown in Figure 14 is constructed.
[0181] Next, the query acquisition unit 132 provides the prompt (Figure 14) to the generating AI. Then, the query acquisition unit 132 obtains the answer from the generating AI. This answer is an SQL query. An example of such a query is shown in Figure 15.
[0182] Next, the query output unit 141 obtains the user identifier "U01" that corresponds to the received query. The query output unit 141 stores the obtained query (Figure 15) in the query management table (Figure 16) in pairs with the user identifier "U01".
[0183] The query management table (Figure 16) is a table stored in the query management unit 113. The query management table (Figure 16) manages one or more records that have "ID", "Query", "Execution Conditions", and "User Identifier".
[0184] Next, the execution unit 135 executes the query (Figure 15) and obtains the execution result. Then, the result output unit 142 sends the execution result to the terminal device 2.
[0185] Next, terminal device 2 receives and outputs the execution result. An example of the execution result is shown in Figure 17.
[0186] Furthermore, the execution information acquisition unit 133 acquires execution information as follows through the process described above. First, the execution information acquisition unit 133 acquires the query "I want to aggregate sales by plan on a monthly basis. Additionally, I want to aggregate customer segments as follows: if there are more than 1000 people, I want to aggregate them as large companies, and if there are fewer, I want to aggregate them as SMBs." Next, the execution information acquisition unit 133 detects that the "monthly" in the query is included in the periodic information of "ID=3" in the execution condition management table (Figure 12). Next, the execution information acquisition unit 133 acquires the execution condition "monthly.$day.$time" which is paired with the said periodic information from the execution condition management table (Figure 12).
[0187] Next, the execution information acquisition unit 133 obtains the current time "October 31, 2024, 8:15 PM" from a clock (not shown). Next, the execution information acquisition unit 133 obtains "$day = last day" and "$time = 8:15 PM" from the current time and constructs the execution condition "monthly.last day.8:15 PM". Next, the execution information acquisition unit 133 adds the execution condition "monthly.last day.8:15 PM" to the execution condition management table (Figure 12) in conjunction with the query.
[0188] Based on the accumulation of the above queries and execution conditions, even after November 2024, the query with "ID=1" will be executed at 8:15 PM on the last day of the month, and the execution result will be notified to the user identified by the user identifier "U01".
[0189] As described above, according to this embodiment, queries that allow for easy manipulation of the database can be obtained by querying natural language sentences.
[0190] Furthermore, according to this embodiment, the database can be easily and automatically manipulated using queries obtained from natural language statements.
[0191] Furthermore, according to this embodiment, it is possible to obtain a query based on a natural language query, as well as information regarding the automatic execution of that query.
[0192] The processing in this embodiment may be implemented in software. This software may be distributed by software download or the like. Alternatively, this software may be recorded on a recording medium such as a CD-ROM and distributed. This also applies to other embodiments in this specification. The software that implements information system A in this embodiment is the following program. In other words, this program is a program that causes a computer that can access a schema management unit where schema information that identifies the structure of the database is stored to function as a query reception unit that receives queries in natural language sentences, a query that corresponds to the query and is a query for operating the database, a query acquisition unit that provides the schema information and the query to a generating AI and obtains it from the generating AI, and a query output unit that outputs the query obtained by the query acquisition unit.
[0193] Figure 17 is a block diagram of a computer system 300 that executes the program described herein to realize the DB processing device 1 and other devices of the various embodiments described above.
[0194] In Figure 17, the computer system 300 includes a computer 301 with a CD-ROM drive, a keyboard 302, a mouse 303, and a monitor 304.
[0195] In Figure 17, the computer 301 includes, in addition to the CD-ROM drive 3012, an MPU 3013, a bus 3014 connected to the CD-ROM drive 3012, a ROM 3015 for storing programs such as boot-up programs, a RAM 3016 connected to the MPU 3013 for temporarily storing instructions for application programs and providing temporary storage space, and a hard disk 3017 for storing application programs, system programs, and data. Although not shown here, the computer 301 may further include a network card for providing connectivity to a LAN.
[0196] The program that causes the computer system 300 to execute the functions of the DB processing device 1, etc., as described above, may be stored on the CD-ROM 3101, inserted into the CD-ROM drive 3012, and then transferred to the hard disk 3017. Alternatively, the program may be transmitted to the computer 301 via a network (not shown) and stored on the hard disk 3017. The program is loaded into the RAM 3016 during execution. The program may also be loaded directly from the CD-ROM 3101 or the network.
[0197] The program does not necessarily have to include an operating system (OS) or third-party program that causes the computer 301 to execute functions such as the DB processing device 1 of the above-described embodiment. The program only needs to include the instruction portion that calls appropriate functions (modules) in a controlled manner and obtains the desired result. How the computer system 300 operates is well known, so a detailed explanation is omitted.
[0198] In the above program, steps such as sending information and receiving information do not include hardware-based processing, such as processing performed by a modem or interface card in the transmission step (processing that can only be performed by hardware).
[0199] Furthermore, the computer running the above program may be a single computer or multiple computers. In other words, it may perform centralized processing or distributed processing.
[0200] Furthermore, it goes without saying that in each of the above embodiments, two or more communication means present in a single device may be physically implemented in a single medium.
[0201] Furthermore, in each of the above embodiments, each process may be implemented by centralized processing by a single device, or by distributed processing by multiple devices.
[0202] It goes without saying that the present invention is not limited to the embodiments described above, and various modifications are possible, all of which are also included within the scope of the present invention. [Industrial applicability]
[0203] As described above, the DB processing device 1 according to the present invention has the effect of allowing easy manipulation of the database through queries using natural language sentences, and is useful as a database server, etc. [Explanation of Symbols]
[0204] A Information Systems 1 DB Processing Unit 2 Terminal devices 3 Generation AI device 11 Storage Unit 12 Reception Department 13 Processing Unit 14 Output section 21 Terminal storage section 22 Terminal Reception Section 23 Terminal Processing Unit 24 Terminal transmission unit 25 Receiving part of the terminal 26 Terminal output section 111 Template Management Department 112 Schema Management Department 113 Query Management Department 121 Inquiry Reception Department 131 Schema Determination Unit 132 Query Retrieval Section 133 Execution Information Acquisition Unit 134 Judgment Department 135 Execution Department 141 Query Output Section 142 Result Output Section
Claims
1. A schema management unit that stores schema information that identifies the structure of the database, The inquiry reception department accepts inquiries in natural language sentences, A query retrieval unit that provides the schema information and the query to a generating AI, and retrieves a query corresponding to the aforementioned inquiry, for manipulating the database, from the generating AI. A DB processing device comprising: a query output unit that outputs the query acquired by the query acquisition unit.
2. An execution unit that executes the query obtained by the query acquisition unit and obtains the execution result, The DB processing apparatus according to claim 1, further comprising a result output unit that outputs the execution result acquired by the execution unit.
3. A query management unit that stores queries that are automatically executed when the execution conditions are met, The system further comprises a determination unit that determines whether or not the aforementioned execution conditions are met, The execution unit is, The DB processing apparatus according to claim 2, wherein when the determination unit determines that the execution conditions are met, it executes the query of the query management unit and obtains the execution result.
4. The system further comprises an execution information acquisition unit that acquires execution information, which is information relating to the automatic execution of a query, based on the aforementioned query in natural language. The aforementioned query output unit is: The DB processing apparatus according to claim 3, wherein the query is associated with the execution information acquired by the execution information acquisition unit and stored in the query management unit.
5. The schema management unit includes: Two or more schema information entries are stored, each corresponding to a different user identifier. The aforementioned inquiry reception department, Upon receiving the aforementioned query associated with the user identifier, The aforementioned query retrieval unit, The DB processing device according to any one of claims 1 to 4, which obtains schema information from the schema management unit that corresponds to the user identifier associated with the inquiry received by the inquiry receiving unit, provides the schema information and the inquiry to the generating AI, and obtains the query from the generating AI.
6. The schema management unit stores two or more schema information entries. The system further comprises a schema determination unit that determines schema information corresponding to the query of the natural language sentence received by the inquiry reception unit, The aforementioned query retrieval unit, The DB processing apparatus according to any one of claims 1 to 4, wherein the schema determination unit obtains the schema information determined by the schema management unit from the schema management unit, provides the schema information and the query to the generating AI, and obtains the query from the generating AI.
7. The system further comprises a template management unit that stores prompt templates which form the basis for the prompts given to the generating AI, The aforementioned query retrieval unit, The DB processing device according to claim 1, wherein the schema information and the query are placed in the variable section of the prompt template to constitute a prompt, the prompt is provided to a generating AI, and the query is obtained from the generating AI.
8. The DB processing apparatus according to claim 1, wherein the query is an SQL statement.
9. A query production method implemented by a schema management unit that stores schema information identifying the structure of the database, a query reception unit, a query retrieval unit, and a query output unit, The aforementioned inquiry reception department has an inquiry reception step that receives inquiries in natural language sentences, The query acquisition unit provides the schema information and the query to the generating AI, and obtains the query corresponding to the query, which is a query for operating the database, from the generating AI in the query acquisition step. A query production method comprising: a query output step in which the query output unit outputs the query acquired by the query acquisition unit.
10. A computer that can access the schema management unit, which stores schema information that identifies the structure of the database, The inquiry reception department accepts inquiries in natural language sentences, A query retrieval unit that provides the schema information and the query to a generating AI, and retrieves a query corresponding to the aforementioned inquiry, for manipulating the database, from the generating AI. A program to function as a query output unit that outputs the query acquired by the query acquisition unit.