JP5488792B2 - Database operation device, database operation method, and program - Google Patents
Database operation device, database operation method, and program Download PDFInfo
- Publication number
- JP5488792B2 JP5488792B2 JP2009206742A JP2009206742A JP5488792B2 JP 5488792 B2 JP5488792 B2 JP 5488792B2 JP 2009206742 A JP2009206742 A JP 2009206742A JP 2009206742 A JP2009206742 A JP 2009206742A JP 5488792 B2 JP5488792 B2 JP 5488792B2
- Authority
- JP
- Japan
- Prior art keywords
- entity object
- database
- result
- sql
- statement
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims description 22
- 238000012545 processing Methods 0.000 claims description 22
- 238000006243 chemical reaction Methods 0.000 claims description 7
- 238000011017 operating method Methods 0.000 claims description 4
- 239000000284 extract Substances 0.000 claims description 3
- 238000004590 computer program Methods 0.000 claims 2
- 238000000605 extraction Methods 0.000 claims 1
- 238000010586 diagram Methods 0.000 description 12
- 230000006870 function Effects 0.000 description 3
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 238000013075 data extraction Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002688 persistence Effects 0.000 description 1
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Description
本発明は、データベースを操作するためのデータベース操作装置、データベース操作方法、及びプログラムに関する。 The present invention relates to a database operating device, a database operating method, and a program for operating a database.
近年、データベースの殆どは、リレーショナルデータベースであり、この操作には、一般に、SQL(Structured Query Language)と呼ばれるデータベース専用の言語が用いられている。SQLによれば、利用者側では、特にデータベースを構成している記憶装置を意識することなく、データの取り出し、書き込み、変更、削除、及び検索といった操作を実行することが可能となる。 In recent years, most databases are relational databases, and a database-dedicated language called SQL (Structured Query Language) is generally used for this operation. According to SQL, on the user side, operations such as data extraction, writing, modification, deletion, and search can be executed without being aware of the storage devices that constitute the database.
また、リレーショナルデータベースでは、データは、テーブルによって管理されており、リーレーションナルデータベース内には、複数のテーブルが構築されている。そして、互いに関連するテーブルは、互いに関連付けられた状態で管理されている。更に、関連付けられた各テーブルに対してアクセスが行われる場合は、SQLによって関連テーブルの結合が行われる。 In the relational database, data is managed by tables, and a plurality of tables are constructed in the relational database. The tables associated with each other are managed in a state associated with each other. Further, when accessing each associated table, the related tables are joined by SQL.
ところで、このようなSQLを用いた操作によれば、利用者は、データベースを構成する記憶装置を意識する必要がないが、SQLを利用するために、SQLを学習し、これを理解しておく必要がある。SQLを用いたデータベースの操作は、誰もが簡単に行えるわけではない。 By the way, according to such an operation using SQL, the user does not need to be aware of the storage device constituting the database, but in order to use SQL, the user learns and understands SQL. There is a need. Database operations using SQL are not easy for everyone.
このため、例えば、特許文献1は、利用者が入力した操作条件に基づいて、SQL文を自動的に生成するアプリケーションプログラム(以下、単に「アプリケーション」という。)を開示している。特許文献1に開示されたアプリケーションによれば、利用者は、SQLについての知識を有していなくても、データベースを操作することができる。
For this reason, for example,
また、近年においては、JAVA(登録商標)アプリケーションからリレーショナルデータベースを操作する手法も提案されている。具体的には、SQL文を発行するJDBC(Java Data Base Connectivity)を用いた手法が知られている。また、JPA(Java Persistence API)、Hibernate等のO/Rマッピングを用いた手法も提案されている。これらの手法によっても、利用者は、SQLの知識を有することなく、データベースを操作することができる。 In recent years, a method of operating a relational database from a JAVA (registered trademark) application has also been proposed. Specifically, a technique using JDBC (Java Data Base Connectivity) that issues an SQL statement is known. In addition, methods using O / R mapping such as JPA (Java Persistence API) and Hibernate have been proposed. Even with these methods, the user can operate the database without having knowledge of SQL.
しかしながら、特許文献1に開示されたアプリケーションには、単一のテーブルにアクセスする場合には対応できるが、関連する複数のテーブルにアクセスする際には対応できないという問題がある。また、特許文献1に開示されたアプリケーションでは、SQL文を自動生成する度に、テーブル名、検索カラム情報等が登録された管理情報テーブルを作成する必要がある。よって、処理が複雑となり、アクセス性能が低下するという問題も発生する。
However, the application disclosed in
一方、JAVA(登録商標)アプリケーションからリレーショナルデータベースにアクセスする手法は、複数のテーブルが関連しているリレーショナルデータベースにも適用できる。しかしながら、この手法をリレーショナルデータベースに適用した場合は、パフォーマンスや可読性が低下する。即ち、この場合も、アクセス性能が低下するという問題が発生する。 On the other hand, the method of accessing a relational database from a JAVA (registered trademark) application can also be applied to a relational database in which a plurality of tables are related. However, when this method is applied to a relational database, performance and readability deteriorate. That is, also in this case, there arises a problem that the access performance is deteriorated.
本発明の目的は、上記問題を解消し、関連する2以上のテーブルを操作対象とした場合において、利用者側にSQLの記述を求めることなく操作を実行し得、且つ、その際のアクセス性能の低下を抑制し得る、データベース操作装置、データベース操作方法、及びプログラムを提供することにある。 An object of the present invention is to solve the above-mentioned problem, and in the case where two or more related tables are set as the operation target, the operation can be executed without requiring the description of SQL on the user side, and the access performance at that time It is to provide a database operation device, a database operation method, and a program capable of suppressing a decrease in the above.
上記目的を達成するため、本発明におけるデータベース操作装置は、
データベースを構成しているテーブル毎に作成されたエンティティオブジェクトと、前記データベースを操作するためのSQL文を生成するSQL生成部とを備え、
前記エンティティオブジェクトは、対応するテーブルを特定する情報及び操作条件を含み、加えて、前記対応するテーブルに関連するテーブルが存在する場合は、前記関連するテーブルを特定する情報を更に含み、
前記SQL生成部は、前記エンティティオブジェクトが対応する前記テーブルを特定し、前記操作条件に応じて、特定した前記テーブルに対する操作を実行するためのSQL文を作成し、そして、
前記エンティオブジェクトが、前記関連するテーブルを特定する情報を含んでいるかどうかを判定し、含んでいる場合は、前記関連するテーブルに対する操作を実行するためのSQL文を更に生成する、ことを特徴とする。
In order to achieve the above object, a database operating device according to the present invention includes:
An entity object created for each table constituting the database, and an SQL generator for generating an SQL statement for operating the database,
The entity object includes information for specifying a corresponding table and operation conditions. In addition, if there is a table related to the corresponding table, the entity object further includes information for specifying the related table,
The SQL generation unit specifies the table corresponding to the entity object, creates an SQL statement for executing an operation on the specified table according to the operation condition, and
It is determined whether or not the entity object includes information specifying the related table, and if included, an SQL statement for executing an operation on the related table is further generated. To do.
また、上記目的を達成するため、本発明におけるデータベース操作方法は、
(a)データベースを構成しているテーブル毎に作成され、且つ、対応するテーブルを特定する情報及び操作条件を含む、エンティティオブジェクトから、前記エンティティオブジェクトが対応する前記テーブルを特定する、ステップと、
(b)前記操作条件に応じて、前記(a)のステップで特定された前記テーブルに対する操作を実行するためのSQL文を生成する、ステップと、
(c)前記エンティティオブジェクトが、前記(a)のステップで特定されたテーブルに関連するテーブルを特定する情報を更に含んでいるかどうかを判定するステップと、
(d)前記(c)のステップで、含んでいると判定された場合に、前記関連するテーブルに対する操作を実行するためのSQL文を更に生成する、ステップと、
を有することを特徴とする。
In order to achieve the above object, the database operation method according to the present invention includes:
(A) identifying the table to which the entity object corresponds from an entity object created for each table constituting the database and including information and operation conditions for identifying the corresponding table;
(B) generating an SQL statement for executing an operation on the table specified in the step (a) according to the operation condition;
(C) determining whether the entity object further includes information identifying a table related to the table identified in the step (a);
(D) when it is determined in step (c) that it contains, an SQL statement for executing an operation on the related table is further generated;
It is characterized by having.
更に、上記目的を達成するため、本発明におけるプログラムは、コンピュータによってデータベースの操作を実行させるためのプログラムであって、
前記コンピュータに、
(a)前記データベースを構成しているテーブル毎に作成され、且つ、対応するテーブルを特定する情報及び操作条件を含む、エンティティオブジェクトから、前記エンティティオブジェクトが対応する前記テーブルを特定する、ステップと、
(b)前記操作条件に応じて、前記(a)のステップで特定された前記テーブルに対する操作を実行するためのSQL文を生成する、ステップと、
(c)前記エンティティオブジェクトが、前記(a)のステップで特定されたテーブルに関連するテーブルを特定する情報を更に含んでいるかどうかを判定するステップと、
(d)前記(c)のステップで、含んでいると判定された場合に、前記関連するテーブルに対する操作を実行するためのSQL文を更に生成する、ステップと、
を実行させることを特徴とする。
Furthermore, in order to achieve the above object, a program according to the present invention is a program for causing a computer to execute a database operation,
In the computer,
(A) identifying the table to which the entity object corresponds from an entity object created for each table constituting the database and including information and operation conditions for identifying the corresponding table;
(B) generating an SQL statement for executing an operation on the table specified in the step (a) according to the operation condition;
(C) determining whether the entity object further includes information identifying a table related to the table identified in the step (a);
(D) when it is determined in step (c) that it contains, an SQL statement for executing an operation on the related table is further generated;
Is executed.
以上のように、本発明におけるデータベース操作装置、データベース操作方法、及びプログラムによれば、関連する2以上のテーブルを操作対象とした場合において、利用者側にSQLの記述を求めることなく操作を実行できる。更に、関連する2以上のテーブルを操作した際のアクセス性能の低下も抑制される。 As described above, according to the database operation device, the database operation method, and the program according to the present invention, when two or more related tables are set as the operation target, the operation is executed without requiring the user to describe the SQL. it can. Furthermore, a decrease in access performance when operating two or more related tables is also suppressed.
(実施の形態1)
以下、本発明の実施の形態1におけるデータベース操作装置、データベース操作方法、及びプログラムについて、図1〜図6を参照しながら説明する。最初に、本実施の形態1におけるデータベース操作装置の構成を図1に基づいて説明する。図1は、本発明の実施の形態1におけるデータベース操作装置の構成を示すブロック図である。
(Embodiment 1)
Hereinafter, a database operation device, a database operation method, and a program according to
図1に示す本実施の形態1におけるデータベース操作装置1は、データベース3に対して、データの取り出し、書き込み、更新、削除、検索等の操作を実行する装置である。データベース3は、リレーショナルデータベースであり、操作が記述されたSQL文を受け取ると、それに応じて処理を実行する。また、図1に示すように、データベース3は、n個のテーブル17−1〜17−nを備えている。nは任意の自然数である。以下において、特定のテーブルを指定していない場合は、単に「テーブル17」とする。
The
図1に示すように、データベース操作装置1は、テーブル17毎に作成されたエンティティオブジェクト12−1〜12−nと、データベース3を操作するためのSQL文を生成するSQL生成部14とを備えている。また、以下において、特定のエンティティオブジェクトを指定していない場合は、単に「エンティティオブジェクト12」とする。
As shown in FIG. 1, the
また、図1には例示していないが、各エンティティオブジェクト12は、対応するテーブル17を特定する情報、及び操作条件を含んでいる。操作条件は、データベース3に対して実行される操作の条件であり、利用者によって予め指定されている。更に、各エンティティオブジェクト12は、対応するテーブルに関連するテーブルが存在する場合は、関連するテーブルを特定する情報も含んでいる。
Although not illustrated in FIG. 1, each
SQL生成部14は、先ず、エンティティオブジェクト12が対応しているテーブル17を特定し、更に、操作条件に応じて、特定したテーブル17に対する操作を実行するためのSQL文を生成する。また、SQL生成部14は、エンティオブジェクト12が、関連するテーブルを特定する情報を含んでいるかどうかを判定し、判定の結果、含んでいる場合は、関連するテーブルに対する操作を実行するためのSQL文も生成する。
The
このように、データベース操作装置1では、関連するテーブルの関係が予めエンティティオブジェクト12によって特定されており、更に、このエンティティオブジェクト12に基づいてSQL文が作成される。よって、データベース操作装置1によれば、操作対象が関連する2以上のテーブルであっても、利用者側(利用者が直接操作を行うアプリケーション側)でのSQLの記述を求めることなくデータベースの操作の実行が可能となる。また、データベース操作装置1での処理は、複雑でないため、関連する2以上のテーブルを操作した際のアクセス性能の低下も抑制される。
As described above, in the
ここで、本実施の形態1におけるデータベース操作装置の構成を図2及び図3を用いて更に具体的に説明する。図2は、本発明の実施の形態1で操作対象となるテーブルの一例を示す図である。図3は、図2に示したテーブルに対応するエンティティオブジェクトの一例を示す図である。 Here, the configuration of the database operation device according to the first embodiment will be described more specifically with reference to FIGS. FIG. 2 is a diagram showing an example of a table to be operated in the first embodiment of the present invention. FIG. 3 is a diagram illustrating an example of an entity object corresponding to the table illustrated in FIG.
図1に示すように、本実施の形態1では、データベース操作装置1は、後述する本実施の形態1におけるプログラムをコンピュータ2上で実行することによって構築されている。また、データベース操作装置1は、更に、SQL処理部16を備えている。SQL処理部16は、SQL生成部14が生成したSQL文に記述された操作を、データベース3に対して実行し、操作の結果をデータベース3の各テーブル17から取得する。
As shown in FIG. 1, in the first embodiment, the
また、本実施の形態1では、上記プログラムは、JAVA(登録商標)アプリケーションである。このため、図1に示すように、データベース操作装置1は、データアクセスオブジェクト(DAO:Data Access Object)13を備えている。データアクセスオブジェクト13は、エンティティオブジェクト17とデータベース3との間でのデータのやり取りを実行するプログラムによって構築されている。
In the first embodiment, the program is a JAVA (registered trademark) application. For this reason, as shown in FIG. 1, the
本実施の形態1においては、SQL生成部14及びSQL処理部16は、データアクセスオブジェクト13によって構築されている。データアクセスオブジェクト13は、エンティティオブジェクト17の内容からSQL文を自動生成し、データベース3に対して、生成したSQLの処理を行い、データを取得する。
In the first embodiment, the
また、エンティティオブジェクト12は、複数のフィールドを備えており、対応するテーブルを特定する情報、対応するテーブルに関連するテーブルを特定する情報(関連の定義)、及び操作条件を、各フィールドに格納する。
The
ここで、具体例を挙げて説明する。図2に示すように、データベース3において、テーブル17−lとテーブル17−mとが関連しているとする。そして、図3に示すように、テーブル17−lに対応してエンティオブジェクト12−lが作成されており、テーブル17−mに対応してエンティティオブジェクト12−mが作成されているとする。なお、l及びmは共にn以下の自然数である。
Here, a specific example will be described. As shown in FIG. 2, in the
図2及び図3に示すように、テーブル17とエンティティオブジェクト12との対応付けは、例えば、テーブル17のカラム(column)と、エンティティオブジェクト12のフィールドとを対応づけることによって行うことができる。この場合、図3に示すように、エンティティオブジェクト12の一のフィールドには、対応するテーブル17を特定する
情報として、対応するテーブルのカラムに登録された情報が格納される。
As shown in FIGS. 2 and 3, the association between the table 17 and the
また、本実施の形態では、上述したように、テーブル17−lがテーブル17−mに関連付けられている。そして、関連するテーブルを特定するため、例えば、テーブル17−lの外部キーに対応しているエンティティオブジェクト12−lのフィールドの型が、関連先のテーブル17−mに対応しているエンティティオブジェクト12−mのクラスに設定される。
In the present embodiment, as described above, the table 17-l is associated with the table 17-m. In order to specify a related table, for example, the type of the field of the entity object 12-l corresponding to the foreign key of the table 17-l is the
つまり、図3に示すように、エンティティオブジェクト12−lにおいて、テーブル17−lのカラムの情報が格納されたフィールドの型Xは、エンティティオブジェクト12−mのクラスYに設定されている。図3の例では、フィールドの型Xが、関連するテーブルを特定する情報として機能している。 That is, as shown in FIG. 3, in the entity object 12-l, the type X of the field storing the column information of the table 17-l is set to the class Y of the entity object 12-m. In the example of FIG. 3, the field type X functions as information for specifying the related table.
更に、図3の例では、エンティティオブジェクト12−lのフィールドに、操作条件が格納されている場合は、エンティティオブジェクト12−mのフィールドにも、同様の操作条件が格納される。例えば、操作条件が、テーブル17−lを検索対象とする検索条件であるとする。テーブル17−lはテーブル17−mと関連しているため、検索は、テーブル17−lとテーブル17−mとにまたがって行う必要がある。よって、エンティティオブジェクト12−lのフィールドと、エンティティオブジェクト12−mのフィールドとに、操作条件として、同一の検索条件が格納される。 Further, in the example of FIG. 3, when the operation condition is stored in the field of the entity object 12-l, the same operation condition is also stored in the field of the entity object 12-m. For example, it is assumed that the operation condition is a search condition for searching the table 17-l. Since the table 17-l is related to the table 17-m, the search needs to be performed across the table 17-l and the table 17-m. Therefore, the same search condition is stored as the operation condition in the field of the entity object 12-l and the field of the entity object 12-m.
また、操作条件が、上述したテーブル17−l及び17−mを検索対象とする検索条件である場合は、SQL生成部14は、先ず、SELECT文及びFROMを生成する。そして、SQL生成部14は、エンティティオブジェクト12−lのフィールドを走査して、エンティオブジェクト12−lが関連するテーブル17−mを特定する情報を含んでいるかどうかを判定する。
When the operation condition is a search condition for searching the above-described tables 17-l and 17-m, the
具体的には、SQL生成部14は、エンティオブジェクト12−lのいずれかのフィールドの型が、別のエンティティオブジェクト12−mのクラスに設定されているかどうかを判定する。そして、図3の例では、エンティオブジェクト12−lのフィールドの型Xがエンティティオブジェクト12−mのクラスYに設定されているので、SQL生成部14は、JOIN文を生成する。その後、SQL生成部14は、エンティティオブジェクト12−mに基づいて、更に、SQL文を生成する。
Specifically, the
次に、本発明の実施の形態1におけるデータベース操作装置1の動作について図4を用いて説明する。図4は、本発明の実施の形態1におけるデータベース操作装置の動作を示すフロー図である。また、本実施の形態1では、データベース操作装置1を動作させることによって、データベース操作方法が実施される。よって、本実施の形態1におけるデータベース操作方法の説明は、以下のデータベース操作装置1の動作の説明に代える。なお、適宜図1〜図3を参酌する。
Next, operation | movement of the
また、図4の例は、コンピュータ2(図1参照)が、情報の検索を行う業務システムを構成している場合を示しており、エンティティオブジェクト12のフィールドに格納される操作条件は、検索条件である。更に、各エンティティオブジェクト12は、テーブル17に合わせて予め作成されている。また、利用者は、コンピュータ2を介して、予め、検索条件を指定し、指定した検索条件を、指定したエンティオブジェクト12のフィールドに格納させている。
The example of FIG. 4 shows a case where the computer 2 (see FIG. 1) constitutes a business system that searches for information. The operation condition stored in the field of the
図4に示すように、先ず、SQL生成部14は、SELECT文を作成し、予め指定されたエンティオブジェクト12の検索条件を読み出し、そして、対応するテーブル17に
登録されているデータのうち取得すべきデータを特定する(ステップA1)。
As shown in FIG. 4, first, the
次に、SQL生成部14は、予め指定されたエンティティオブジェクトから、それが対応しているテーブルを特定する(ステップA2)。そして、SQL生成部14は、ステップA2で特定されたテーブルに基づき、FROM文を生成する(ステップA3)。その後、SQL生成部14は、予め指定されたエンティティオブジェクト内のフィールドの走査を実行する(ステップA4)。
Next, the
次に、SQL生成部14は、走査中のフィールドの内容が空であるかどうか、即ち、当該フィールドにデータが格納されているかどうかを判定する(ステップA5)。判定の結果、空である場合は、再度、ステップS4を実行する。これにより、次の別のフィールドの走査が実行される。一方、判定の結果、空でない場合は、SQL生成部14は、ステップA6を実行する。
Next, the
ステップA6では、SQL生成部14は、走査中のフィールドの型が、他のエンティティオブジェク12のクラスに設定されているかどうかを判定する。ステップA6の判定の結果、走査中のフィールドの型が、他のエンティティオブジェク12のクラスに設定されている場合は、SQL生成部14は、他のエンティティオブジェクト12に対して、ステップA2〜A6を再帰的に実行する。但し、この場合のステップA3では、SQL生成部14は、FROM文を生成する代わりに、JOIN文を生成し、これを既に生成しているSQL文に追加する。
In step A <b> 6, the
一方、ステップA6の判定の結果、走査中のフィールドの型が、他のエンティティオブジェク12のクラスに設定されていない場合は、SQL生成部14は、走査中のフィールドに格納されているデータに基づいて、WHERE文を生成する(ステップA7)。また、ステップA7では、SQL生成部4は、ステップA2〜A6が再帰的に実行され、JOIN文によってSQL文が結合されている場合は、ON文を生成する。
On the other hand, if the result of determination in step A6 is that the type of the field being scanned is not set to the class of another
次に、SQL生成部14は、指定されたエンティティオブジェクト12(又はステップA6で判定された他のエンティティオブジェクト12)の全てのフィールドを走査したかどうか判定する(ステップA8)。
Next, the
ステップA8での判定の結果、エンティティオブジェクト12の全てのフィールドを走査していない場合は、SQL生成部14は、当該エンティティオブジェクト12の次のフィールドを走査するため、再度、ステップS4を実行する。一方、ステップA8の判定の結果、エンティティオブジェクト12の全てのフィールドを走査している場合は、SQL生成部14における処理は終了する。
As a result of the determination in step A8, if not all the fields of the
その後、SQL処理部16は、生成されたSQL文をデータベース3に渡し(ステップA9)、そして、データベース3から操作の結果を受け取る(ステップA10)。ステップA10が実行されると、データベース操作装置1での処理は終了する。
Thereafter, the
また、指定されたエンティティオブジェクト12が図3に示す例であり、対応しているテーブルが図2に示す例であった場合、SQL文の具体例は図5に示す通りとなる。図5は、本発明の実施の形態1において作成されたSQL文の一例を示す図である。図5に示すように、SQL文には、SELECT文、FROM文、JOIN文、ON文が含まれている。
Further, when the specified
更に、上記の場合において、エンティティオブジェクト12及びデータアクセスオブジェクト13における、定義と検索時の実装例とは、図6に示す通りとなる。図6は、本発
明の実施の形態1におけるエンティティオブジェクト及びデータアクセスオブジェクトの定義と実装例とを示す図である。なお、図6において、定義と検索時の実装例とは、Javaのソースコードをベースにして作成されている。
Further, in the above case, the definition and implementation example at the time of retrieval in the
以上のように、本実施の形態1によれば、上述したように、操作対象が関連する2以上のテーブル17であったとしても、利用者側(利用者が直接操作を行うアプリケーション側)でのSQLの記述が求められることはない。この結果、利用者は、直接SQL文を作成しなくても、例えば、複数のテーブルにまたがる検索を実行できる。また、データベース操作装置1では、複数のテーブルにまたがる検索の実行時において、複雑な処理は要求されないため、関連する2以上のテーブルを操作した際のアクセス性能の低下は抑制される。
As described above, according to the first embodiment, as described above, even if there are two or more tables 17 related to the operation target, on the user side (the application side on which the user directly operates). The description of the SQL is not required. As a result, the user can execute a search across a plurality of tables, for example, without directly creating an SQL sentence. Further, in the
本実施の形態1におけるプログラムは、コンピュータ2(図1参照)に、図4に示すステップA1〜A10を実行させるプログラムであれば良い。このプログラムをコンピュータ2にインストールし、実行することによって、本実施の形態1におけるデータベース操作装置1とデータベース操作方法とを実現することができる。この場合、コンピュータ2のCPU(Central Processing Unit)は、データアクセスオブジェクト13として機能し、処理を行なう。また、コンピュータ2のCPUは、メモリやハードディスク等の記憶装置の記憶領域に、エンティティオブジェクト12を構築する。
The program in the first embodiment may be a program that causes the computer 2 (see FIG. 1) to execute steps A1 to A10 shown in FIG. By installing and executing this program on the
(実施の形態2)
次に、本発明の実施の形態2におけるデータベース操作装置、データベース操作方法、及びプログラムについて、図7及び図8を参照しながら説明する。最初に、本実施の形態2におけるデータベース操作装置の構成を図7に基づいて説明する。図7は、本発明の実施の形態2におけるデータベース操作装置の構成を示すブロック図である。
(Embodiment 2)
Next, a database operation device, a database operation method, and a program according to
図7に示すように、本実施の形態2におけるデータベース操作装置4は、図1に示した実施の形態1におけるデータベース操作装置1の構成に加えて、更に、入力受付部10、結果出力部11、及び結果変換部15を備えている。なお、これらを備えている以外は、データベース操作装置4は、実施の形態1におけるデータベース操作装置1と同様に構成されている。以下、相違点について説明する。
As shown in FIG. 7, in addition to the configuration of the
入力受付部10は、外部から利用者によって入力された操作条件を受け付ける。更に、入力受付部10は、受け付けた操作条件に対応するエンティティオブジェクト12を特定し、特定したエンティティオブジェクト12に、受け付けた操作条件を格納させる。
The
また、本実施の形態2では、入力受付部10は、コンピュータ2に接続された表示装置6に、操作条件の入力画面を表示させることができる。例えば、操作条件が検索条件である場合は、入力画面には、AND又はORでつながれる複数のフィールドが表示される。利用者は、入力画面上で、キーボードやマウスといった入力装置を用いて、各フィールドにキーワードを入力することによって、検索条件を設定することができる。
In the second embodiment, the
結果変換部15は、SQL処理部16によってデータベース3から取得された操作の結果を、エンティティオブジェクト12で登録可能なデータ形式に変換する。更に、結果変換部15は、変換した結果を、取得元のテーブル17に対応しているエンティティオブジェクト12に登録する。
The
結果出力部11は、結果変換部15によって変換された結果が登録されたエンティティオブジェクト12から、登録された結果を取り出し、取り出した結果を外部に出力する。本実施の形態2では、結果出力部11は、表示装置6に、結果を示す結果画面を表示させ
ることができる。この場合、利用者は、結果を容易に把握することができる。
The result output unit 11 extracts the registered result from the
次に、本発明の実施の形態2におけるデータベース操作装置4の動作について図8を用いて説明する。図8は、本発明の実施の形態2におけるデータベース操作装置の動作を示すフロー図である。また、本実施の形態2においても、データベース操作装置4を動作させることによって、データベース操作方法が実施される。よって、本実施の形態におけるデータベース操作方法の説明は、以下のデータベース操作装置4の動作の説明に代える。なお、適宜図7を参酌する。
Next, operation | movement of the
また、図8の例も、実施の形態1において図4に示した例と同様に、コンピュータ2(図1参照)が、情報の検索を行う業務システムを構成している場合を示している。図8の例において、エンティティオブジェクト12のフィールドに格納される操作条件は、検索条件である。なお、各エンティティオブジェクト12は、テーブル17に合わせて予め作成されているが、操作条件は設定されていない状態にある。
Also, the example of FIG. 8 shows a case where the computer 2 (see FIG. 1) constitutes a business system that searches for information, similarly to the example shown in FIG. 4 in the first embodiment. In the example of FIG. 8, the operation condition stored in the field of the
図8に示すように、先ず、入力受付部10は、入力画面上で入力された検索条件を取得し、これを受け付ける(ステップB1)。次に、入力受付部10は、受け付けた検索条件に対応するエンティティオブジェクト12を特定し、特定したエンティティオブジェクト12のフィールドに検索条件を格納させる(ステップB2)。
As shown in FIG. 8, first, the
次に、SQL生成部14は、エンティティオブジェクト12に基づいてSQL文を生成する(ステップB3)。本実施の形態2において、ステップB3は、実施の形態1において図4に示したステップA1〜A8を全て含んでいる。ステップB3で生成されたSQL文は、SQL処理部16に入力される。
Next, the
次に、SQL処理部16は、生成されたSQL文をデータベース3に渡し(ステップB4)、そして、データベース3から検索の結果を受け取る(ステップB5)。続いて、結果変換部15は、ステップB5で取得された検索の結果を、エンティティオブジェクト12で登録可能なデータ形式に変換し、変換した結果を、取得元のテーブル17に対応しているエンティティオブジェクト12に登録する(ステップB6)。
Next, the
その後、結果出力部11は、ステップB6で検索の結果が登録されたエンティティオブジェクト12から、登録された検索の結果を取り出し、取り出した検索の結果を表示装置6に出力する(ステップB7)。これにより、検索の結果が、表示装置6の表示画面に表示され、利用者は、検索の結果を容易に把握することができる。ステップB7が実行されると、データベース操作装置4での処理は終了する。
After that, the result output unit 11 extracts the registered search result from the
以上のように、本実施の形態2によれば、利用者は、入力画面上で、直接、検索条件を入力することができる。また、入力された検索条件がエンティティオブジェクト12に設定されるので、本実施の形態2を用いた場合も、実施の形態1を用いた場合と同様に、利用者側でSQLを記述することなく、複数のテーブルにまたがる検索の実行が可能となる。更に、データベース操作装置4においても、複数のテーブルにまたがる検索の実行時において、複雑な処理は要求されず、アクセス性能の低下は抑制される。
As described above, according to the second embodiment, the user can input the search condition directly on the input screen. In addition, since the input search condition is set in the
また、本実施の形態2におけるプログラムは、コンピュータ2(図1参照)に、図8に示すステップB1〜A7を実行させるプログラムであれば良い。このプログラムをコンピュータ2にインストールし、実行することによって、本実施の形態2におけるデータベース操作装置4とデータベース操作方法とを実現することができる。この場合、コンピュータ2のCPU(Central Processing Unit)は、データアクセスオブジェクト13として機能し、処理を行なう。また、コンピュータ2のCPUは、メモリやハードディスク等の
記憶装置の記憶領域に、エンティティオブジェクト12を構築する。
Moreover, the program in this
以上説明した実施の形態1及び2では、SQL生成部14が最初にSELECT文を生成する例が、挙げられている(図4参照)。但し、本発明は、この例に限定されるものではない。本発明では、SQL生成部は、エンティティオブジェクトに設定されている操作条件に基づいて、UPDATE文や、DELETE文を生成することもできる。この場合、データベースに対しては、更新処理や、削除処理が行われる。
In
本発明によれば、互いに関連するテーブルが存在している場合であっても、利用者側でSQL文を記述することなく、データベースを操作できる。本発明は、リレーショナルデータベースを利用した業務システム、特には、アプリケーションプログラムによってSQLが作成され、このSQLによってデータベースが操作されるシステムに有用である。 According to the present invention, even if there are tables related to each other, the database can be operated without describing the SQL statement on the user side. The present invention is useful for a business system using a relational database, particularly a system in which SQL is created by an application program and the database is operated by this SQL.
1 データベース操作装置(実施の形態1)
2 コンピュータ
3 データベース
4 データベース操作装置(実施の形態2)
5 入力装置
6 表示装置
10 入力受付部
11 結果出力部
12−1〜12−n エンティティオブジェクト
13 データアクセスオブジェクト
14 SQL生成部
15 結果変換部
16 SQL処理部
17−1〜17−n テーブル
1 Database operation device (Embodiment 1)
2
DESCRIPTION OF
Claims (15)
前記エンティティオブジェクトは、複数のフィールドを備え、前記複数のフィールドのうち一のフィールドに、対応するテーブルを特定する情報として、前記対応するテーブルのいずれかのカラムに登録された情報を格納し、他のフィールドに操作条件を格納し、加えて、前記対応するテーブルに関連するテーブルが存在する場合は、前記一のフィールドにおいて、その型が、前記関連するテーブルに対応している別のエンティティオブジェクトのクラスに設定されており、
前記SQL生成部は、
前記エンティティオブジェクトが対応する前記テーブルを特定し、
前記操作条件に応じて、特定した前記テーブルに対する操作を実行するためのSQL文を作成し、そして、
前記エンティオブジェクトにおいて、前記一のフィールドにおいて、その型が、前記関連するテーブルに対応している別のエンティティオブジェクトのクラスに設定されているかどうかを判定し、設定されている場合は、前記関連するテーブルに対する操作を実行するためのSQL文を更に生成する、
ことを特徴とする、データベース操作装置。 An entity object created for each table constituting the database, and an SQL generator for generating an SQL statement for operating the database,
The entity object includes a plurality of fields, and stores information registered in one of the columns of the corresponding table as information for specifying the corresponding table in one of the plurality of fields. field stores the operating conditions of, in addition, if the table associated with the corresponding table exists, the in one of the field, its type, another which corresponds to the associated table of entity objects Set to class,
The SQL generation unit
Identify the table to which the entity object corresponds;
Create an SQL statement for executing an operation on the identified table according to the operation condition, and
In the entity object, in the one field, its type, the associated determined whether it is set to the class of another entity object corresponding to the table, if it is set, the associated Further generating an SQL statement for performing an operation on the table;
A database operating device.
前記SQL生成部が、先ず、SELECT文及びFROMを生成し、そして、
前記複数のフィールドを走査して、前記エンティオブジェクトが前記関連するテーブルを特定する情報を含んでいるかどうかを判定し、含んでいる場合は、JOIN文を生成する、請求項1に記載のデータベース操作装置。 When the operation condition included in the entity object is a search condition for searching the corresponding table,
The SQL generator first generates a SELECT statement and FROM, and
The database operation according to claim 1 , wherein the plurality of fields are scanned to determine whether the entity object includes information specifying the related table, and if so, a JOIN statement is generated. apparatus.
前記結果が登録されたエンティティオブジェクトから、登録された前記結果を取り出し、取り出した前記結果を外部に出力する、結果出力部とを、更に備えている、請求項4に記載のデータベース操作装置。 Result conversion for converting the result of the operation acquired from the database into a data format that can be registered in the entity object, and registering the converted result in the entity object corresponding to the table of the acquisition source And
The database operation device according to claim 4 , further comprising: a result output unit that extracts the registered result from the registered entity object and outputs the extracted result to the outside.
(b)前記操作条件に応じて、前記(a)のステップで特定された前記テーブルに対する操作を実行するためのSQL文を生成する、ステップと、
(c)前記エンティティオブジェクトにおいて、前記一のフィールドにおいて、その型が、前記関連するテーブルに対応している別のエンティティオブジェクトのクラスに設定されているかどうかを判定するステップと、
(d)前記(c)のステップで、設定されていると判定された場合に、前記関連するテーブルに対する操作を実行するためのSQL文を更に生成する、ステップと、
を有することを特徴とする、データベース操作方法。 (A) Information created in any column of the corresponding table is stored in one field as information for identifying the corresponding table, created for each table constituting the database, and others The operation condition is stored in the field, and the table corresponding to the entity object is specified from the entity object; and
(B) generating an SQL statement for executing an operation on the table specified in the step (a) according to the operation condition;
(C) determining whether the type of the entity object is set to a class of another entity object corresponding to the related table in the one field ;
(D) If it is determined in the step (c) that it is set, a SQL statement for further executing an operation on the related table is generated; and
A database operating method characterized by comprising:
前記(b)のステップにおいて、SELECT文及びFROMを生成し、
前記(c)のステップにおいて、前記複数のフィールドを走査して、前記エンティオブジェクトが前記関連するテーブルを特定する情報を含んでいるかどうかを判定し、
前記(d)のステップにおいて、JOIN文を生成する、請求項6に記載のデータベース操作方法。 When the operation condition included in the entity object is a search condition for searching the corresponding table,
In the step (b), a SELECT statement and FROM are generated,
In step (c), scanning the plurality of fields to determine whether the entity object contains information identifying the associated table;
The database operation method according to claim 6 , wherein a JOIN statement is generated in the step (d).
(h)前記結果が登録されたエンティティオブジェクトから、登録された前記結果を取り出し、取り出した前記結果を外部に出力する、ステップとを、更に有する、請求項9に記載のデータベース操作方法。 (G) The operation result acquired in the step (f) is converted into a data format that can be registered in the entity object, and the converted result is converted into the entity corresponding to the acquisition source table. Registering with objects, steps,
The database operation method according to claim 9 , further comprising: (h) extracting the registered result from an entity object in which the result is registered, and outputting the extracted result to the outside.
前記コンピュータに、
(a)前記データベースを構成しているテーブル毎に作成され、且つ、一のフィールドに、対応するテーブルを特定する情報として、前記対応するテーブルのいずれかのカラムに登録された情報を格納し、他のフィールドに操作条件を格納する、エンティティオブジェクトから、前記エンティティオブジェクトが対応する前記テーブルを特定する、ステップと、
(b)前記操作条件に応じて、前記(a)のステップで特定された前記テーブルに対する操作を実行するためのSQL文を生成する、ステップと、
(c)前記エンティティオブジェクトにおいて、前記一のフィールドにおいて、その型が、前記関連するテーブルに対応している別のエンティティオブジェクトのクラスに設定されているかどうかを判定するステップと、
(d)前記(c)のステップで、設定されていると判定された場合に、前記関連するテーブルに対する操作を実行するためのSQL文を更に生成する、ステップと、
を実行させることを特徴とする、プログラム。 A program for causing a computer to execute database operations,
In the computer,
(A) Information created in any column of the corresponding table is stored in one field as information specifying the corresponding table, created for each table constituting the database , Identifying the table to which the entity object corresponds from the entity object, storing operation conditions in other fields ;
(B) generating an SQL statement for executing an operation on the table specified in the step (a) according to the operation condition;
(C) determining whether the type of the entity object is set to a class of another entity object corresponding to the related table in the one field ;
(D) If it is determined in the step (c) that it is set, a SQL statement for further executing an operation on the related table is generated; and
A program characterized by having executed.
前記(b)のステップにおいて、SELECT文及びFROMを生成し、
前記(c)のステップにおいて、前記複数のフィールドを走査して、前記エンティオブジェクトが前記関連するテーブルを特定する情報を含んでいるかどうかを判定し、
前記(d)のステップにおいて、JOIN文を生成する、請求項11に記載のプログラム。 When the operation condition included in the entity object is a search condition for searching the corresponding table,
In the step (b), a SELECT statement and FROM are generated,
In step (c), scanning the plurality of fields to determine whether the entity object contains information identifying the associated table;
The program according to claim 11 , wherein in the step (d), a JOIN statement is generated.
(h)前記結果が登録されたエンティティオブジェクトから、登録された前記結果を取り出し、取り出した前記結果を外部に出力する、ステップとを、更に前記コンピュータに実行させる、請求項14に記載のプログラム。 (G) The operation result acquired in the step (f) is converted into a data format that can be registered in the entity object, and the converted result is converted into the entity corresponding to the acquisition source table. Registering with objects, steps,
(H) from the entity object that the result is registered, is taken out the result of the registered outputs the result of extraction to the outside, and a step to execute further the computer program as claimed in claim 1 4 .
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009206742A JP5488792B2 (en) | 2009-09-08 | 2009-09-08 | Database operation device, database operation method, and program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2009206742A JP5488792B2 (en) | 2009-09-08 | 2009-09-08 | Database operation device, database operation method, and program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2011059845A JP2011059845A (en) | 2011-03-24 |
JP5488792B2 true JP5488792B2 (en) | 2014-05-14 |
Family
ID=43947419
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2009206742A Expired - Fee Related JP5488792B2 (en) | 2009-09-08 | 2009-09-08 | Database operation device, database operation method, and program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5488792B2 (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5542857B2 (en) * | 2012-03-22 | 2014-07-09 | 株式会社東芝 | Query issuing device, query issuing program, query issuing method |
JP6415877B2 (en) * | 2014-07-08 | 2018-10-31 | 株式会社東芝 | Data processing apparatus and data processing method |
KR101806449B1 (en) | 2016-05-30 | 2017-12-07 | 주식회사 인브레인 | Ansi query statement generation system using graphical user interface and method thereof |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6625613B2 (en) * | 2001-02-26 | 2003-09-23 | Motorola, Inc. | Automatic generation of SQL for frame completion |
JP2003337726A (en) * | 2002-05-20 | 2003-11-28 | Hitachi Software Eng Co Ltd | Database access program forming method |
JP2004164363A (en) * | 2002-11-14 | 2004-06-10 | Nobuhiko Nagamori | Method for displaying relational database structure in tree diagram |
JP2006251979A (en) * | 2005-03-09 | 2006-09-21 | Matsushita Electric Ind Co Ltd | Variable item retrieval system |
KR100558952B1 (en) * | 2005-05-12 | 2006-03-10 | 김길웅 | Method for automation of software manufacturing process based on graphic user interface design, and computer readable medium having thereon computer executable instruction for performing the same |
-
2009
- 2009-09-08 JP JP2009206742A patent/JP5488792B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JP2011059845A (en) | 2011-03-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4947245B2 (en) | Information retrieval apparatus, information retrieval method, computer program, and data structure | |
US8732127B1 (en) | Method and system for managing versioned structured documents in a database | |
US9164738B2 (en) | Database mapping of models for reporting tools in model driven development | |
US20080147707A1 (en) | Method and apparatus for using set based structured query language (sql) to implement extract, transform, and load (etl) splitter operation | |
JP2007066017A (en) | System and method for controlling access to database | |
JP4207438B2 (en) | XML document storage / retrieval apparatus, XML document storage / retrieval method used therefor, and program thereof | |
JP5844824B2 (en) | SPARQL query optimization method | |
JP5488792B2 (en) | Database operation device, database operation method, and program | |
US20110270862A1 (en) | Information processing apparatus and information processing method | |
JP3163141B2 (en) | Relational database processing device and processing method | |
US8639709B2 (en) | Comparing very large XML data | |
JP2010272006A (en) | Relation extraction apparatus, relation extraction method and program | |
US20100153438A1 (en) | Method and apparatus for searching for hierarchical structure document | |
US9542502B2 (en) | System and method for XML subdocument selection | |
JP6287506B2 (en) | Database access control program, database access control method, and information processing apparatus | |
JP2018060379A (en) | Searching means selecting program, searching means selecting method and searching means selecting device | |
US8898122B1 (en) | Method and system for managing versioned structured documents in a database | |
JP6589317B2 (en) | Rewriting device, processing method and program thereof, and information processing device | |
JP2000181697A (en) | Method and device for conversion to open type system of mainframe cobol property and recording medium | |
US20240028328A1 (en) | Storage medium, information processing method, and information processing device | |
JP5596517B2 (en) | Internationalized screen generation system and program | |
JP5190899B2 (en) | Information processing apparatus, setting file generation method, and setting file generation program | |
JP4693807B2 (en) | Program development support system, method and program | |
JP5483166B2 (en) | Document search apparatus, document search method, and program | |
JP4983397B2 (en) | Document search apparatus, document search method, and computer program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20120801 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20130904 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20130911 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20131107 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20140129 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20140211 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 5488792 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
LAPS | Cancellation because of no payment of annual fees |