10

リレーショナル データベース言語と clojuresqlなどのロジック プログラミング言語との間の基本的な概念と実装に関して、類似点と相違点は何ですか? 2つは交換可能ですか?prologcore.logic

4

3 に答える 3

6

類似点は、Datalogクエリ言語によってキャプチャされます。これが、ロジックとデータベース間の接続の動機とより良い説明です。この抜粋はあなたの質問に対処する必要があります:

Nevertheless, coupling Prolog and relational databases show some dissonances. Facts and rules in Prolog are organized in a total order and the semantics of a Prolog program depends on this order. In contrast, relations in a database are considered as unordered sets of tuples and the result of a query is independent from any physical order. The processing of Prolog programs is tuple oriented while relational databases are set oriented. Prolog offers procedural features like the cut predicate to allow the programmer to control the inference process. The order of evaluation of a Prolog program is pre-determined, whereas expressions in relational calculus are purely declarative and the actual evaluation is left to a query processor which may rearrange the query for optimization purposes. Optimization of queries was crucial for the success of relational databases. The procedural nature of the Prolog engine leaves the burden of optimization with the programmer.

于 2012-06-29T20:44:19.413 に答える
5

重要な違いの 1 つは、SQL はチューリング完全であり、ANSI SQL 99 までは不可能だった非常にクレイジーなトリックを備えていることです。Prolog はチューリング完全であるため、汎用プログラミング言語です。

于 2012-06-29T12:44:46.037 に答える
4

SQL と Prolog はどちらも一階論理の概念を示していますが、どちらも述語計算の完全な実装ではありません。

Prolog やその他のロジック プログラミング言語は、データ構造の定義と述語の両方で、再帰に大きく依存しています。

SQL 自体は再帰を許可しておらず、ストアド プロシージャの導入は、そのような呼び出しのネストの深さに制限付きで行われています。例えば。SQL Server 2000 ~ 2012では、最大 32 個のネストされた呼び出しが許可されます。

リレーショナル データベースでは、「リレーション」はテーブル (より柔軟にはビュー) として具体化されます。Prolog の最も類似した側面は、動的ファクトベースです。一部の実装 (SWI、Amzi) では、パフォーマンスのためにインデックスを作成できます。これは、SQL でパフォーマンスのためにリレーショナル テーブルのインデックスを作成するのと非常によく似ています。

SQL RDBMS は、Prolog の実装が通常必要とするよりもはるかに大きなデータ セットを効率的に処理するように設計されていますが、少なくとも Prolog は、システム設計のデータベースとプロセスの両方の側面をプロトタイプ化するために使用できます。

Prolog 推論を使用してリレーショナル データベースを拡張することを検討している 2005 年の論文については、こちらを参照してください。

于 2012-07-01T05:31:08.480 に答える