AWS上でStardogとAmazon Bedrock AgentCoreを用いたエージェントAI向けセマンティックレイヤーの構築方法
AWS と Stardog の連携により、ETL を不要としたセマンティックレイヤー上で Amazon Bedrock AgentCore が自律的に複数データソースを横断する分析を実現し、エンタープライズ AI アジェンティクスへの道筋を示した。
キーポイント
ETL なしの統合セマンティックレイヤーの実現
Amazon Aurora, Redshift, S3 など分散するデータソースを Stardog Semantic AI を介して統合し、データ変換(ETL)工程を経ずに AI エージェントが直接クエリ実行可能な環境を構築した。
Agentic Analytics による自律的分析の進化
従来のダッシュボードや BI から一歩進み、生成 AI エージェントが計画・推論・反復を行い、生データに対して即座に信頼性の高い回答を導き出す「アジェンティクス分析」のパラダイムシフトを示した。
データ不整合とコンテキストの解決
CRM と請求システムなどで定義が異なる「顧客」や「収益」などの概念をセマンティックレイヤーで統一し、AI エージェントが矛盾する回答を出すリスクを排除し、信頼性を確保した。
AWS 環境での多様な実行基盤の統合
Amazon Bedrock AgentCore を基盤としつつ、EKS, ECS, Lambda など AWS の各種コンピューティングリソース上で同様の Stardog デプロイメントを動作させる柔軟性を実証した。
影響分析・編集コメントを表示
影響分析
この記事は、生成 AI が単なる情報検索から自律的な意思決定・分析へと進化するための決定的な課題である「データの断片化と不整合」に対する具体的な解決策を提示しています。特に ETL プロセスを排除し、生データ上で即座に推論可能な環境を提供することで、AI エージェントの導入コストとリスクを大幅に下げ、実務レベルでの「Agentic Analytics」普及への強力な後押しとなります。
編集コメント
「モデルの性能」から「データの信頼性」へ焦点が移った重要な転換点を示す記事です。ETL の重労働を解消しつつ、複雑な企業データ環境で AI が正しく推論できる基盤としてセマンティックレイヤーの重要性が再確認されました。
本稿では、Amazon Aurora と Amazon Redshift を活用して Stardog の Semantic AI Application で AWS 上にセマンティックレイヤーを構築する方法と、ETL(抽出・変換・ロード)を行わずに両方のデータソースにわたる顧客 360 度ビューに関する質問に回答するために、Amazon Bedrock AgentCore 上で Strands Agents エージェントを実行する方法について解説します。同じ Stardog デプロイメントは、AWS の計算リソース(Amazon Elastic Kubernetes Service (Amazon EKS)、Amazon Elastic Container Service (Amazon ECS)、および AWS Lambda)の背後でも機能します。ここでは AgentCore を使用していますが、これはインバウンド認証、ホスティング、ツール資格情報を一つのマネージドサービスに統合しているためです。
エンタープライズ分析は過去 20 年にわたり、同じ目標を追求し続けてきました:ビジネス上の質問から信頼できる回答に至るまでの時間を短縮することです。スケジュールされたレポートがダッシュボードに置き換わり、さらにダッシュボードがセルフサービス ビジネスインテリジェンス (BI) に取って代わりました。しかし、セルフサービスでさえも、適切な質問に対してデータエンジニアが事前に正しいモデルを構築していることに依存しており、準備されたデータセット以外のすべての作業において人間の分析担当者がボトルネックとなっていました。生成 AI エージェントは次のステップです。データを可視化するのではなく、それらに対して推論を行います。計画を立て、クエリを作成し、結果を検証し、会社のライブデータに対して即時に改善と反復を繰り返します。この変化を指す用語が「アジェンティック分析」です:各ビジネスユーザーのすぐそばに自律的なエージェントが存在し、リクエストキューでの待機なしに分析担当者の業務を遂行するのです。
もはや難所は基盤モデル(FM)ではありません。Amazon Bedrock で利用可能な基盤モデルは、すでに多段階ワークフローの計画、スキーマに関する推論、そしてジュニアアナリストが行うような十分な精度での SQL 生成が可能です。真の難所はその下層に存在します。つまり、モデルが推論を行う対象となるデータです。エンタープライズデータの多くは、同じものを異なる定義で記述するシステム間に散在しています。顧客関係管理(CRM)システムにおける「顧客」レコードと、請求システムにおける「顧客」レコードは同一ではありません。北米チームが計算した「収益」と、欧州チームが算出する数値も一致しません。この断片化されたデータに直接アクセスできる AI エージェントは、技術的には有効なクエリを記述しますが、誤りや矛盾、あるいは説明不能な回答を返すことになります。同じ質問に対して 2 つのエージェントが異なる数値を返した瞬間、信頼性は失われます。
AWS 上では、データは馴染み深い組み合わせの中に分散して存在しています。運用記録は Amazon Aurora やその他の Amazon Relational Database Service (Amazon RDS) エンジンに保存されています。分析履歴は Amazon Redshift にあります。非構造化データは Amazon Simple Storage Service (Amazon S3) に保存され、Amazon Athena を通じて照会されますが、近年では Amazon S3 Tables(これは Amazon S3 の機能であり、Athena、Amazon EMR、および Amazon Redshift がすべて読み取り可能)上の Apache Iceberg などのオープンテーブル形式にも格納されるようになっています。各レイヤーは保存するデータに特化して設計されており、多くの企業はこの構造を維持し続けます。課題は、シニアの人間アナリストが同じ質問に対して示すような流暢さで、AI エージェントがこれらすべてのデータを同時に推論できるように支援することです。
基盤モデルは言語を提供し、AWS データアプリケーションは事実を提供します。今日、これらを接続する一般的な方法は Retrieval Augmented Generation (RAG) です:ポリシー文書、マニュアル、サポートチケットを Amazon Bedrock Knowledge Bases にインデックス付けし、クエリ実行時に一致する記述をモデルのコンテキストに引き出します。答えが検索で見つけられるテキストの中に存在する場合、RAG はよく機能します。しかし、システム間で生データを結合し、ビジネスルールを一貫して適用し、行レベルまたは列レベルのアクセスポリシーを尊重することが必要な分析質問に対しては、その効果は低下します。
言語と事実の間にあり、分析的な質問に対して通常欠けているのは、*ビジネスコンテキストとビジネス指標*です。典型的な小売りの例を考えてみましょう:*顧客*とは何かという共通定義、*注文*がどのようにそれに関連するか、*大規模な支出者*や*高リスクアカウント*として何がカウントされるか、どのシステムがどの事実を所有しているか、そして企業が報告する数値がどのように計算されるかです。同じギャップは、他のドメイン(保険における請求とポリシー、医療における患者と診察、サプライチェーンにおける部品と出荷)でも異なる名称で現れます。セマンティックレイヤーはそのコンテキストを一度捉え、すべてのエージェントやツールがそれを再利用できるようにします。これにより、AI エージェントは多くのソースから回答を組み立て、返す数値の根拠を示すことができます。セマンティックレイヤーは RAG を置き換えるものではありません。それを補完するものです。ほとんどの本番システムでは両方が必要であり、同じエージェントを通じてアクセス可能です。
セマンティックレイヤーは、エンタープライズデータに対するオントロジー駆動型のビューです。オントロジーは、ビジネスにとって重要な概念、関係性、属性、ルールを捉えます。マッピングは、これらの概念が各生データのソースの各行からどのようにマッピングされるかを宣言します。エージェントがこのレイヤーを照会します。レイヤーは実行時に各クエリを基盤システムに対する SQL に変換します。データはその場所に留まり、意味は一度捕捉されて再利用されます。
このセマンティック層を Stardog が実装する形(オントロジー、すべてのエンティティに対する安定した識別子、新しい事実を導出するルール、およびデータをオントロジーに対して検証する制約)で構築された場合、その結果は*知識グラフ*となります。データはテーブル内の行ではなく、ビジネスエンティティのグラフとして接続され、各エンティティには IRI と呼ばれる安定した URL 形式の一意な識別子が付与されます。また、クエリは W3C で定義された標準ベースの問い合わせ言語である SPARQL を用いて、これらの接続をたどって実行されます。
残りの記事全体で繰り返し登場する用語がもう 2 つあります:
- ネームドグラフ(named graph)とは、ラベル付けされたグラフのサブセットであり、独自の IRI で識別されます。Stardog ではネームドグラフをアクセス制御の単位として使用します。同じクエリでも、各ロールが読み取りを許可されているネームドグラフの違いによって、異なる結果を返す場合があります。
- バーチャルグラフ(virtual graph)とは、その内容が Stardog 内に全く保存されていないネームドグラフです。これらは外部システム(Aurora, Amazon Redshift, Athena)に存在し、Stardog はマッピングを用いて必要な行をオンデマンドで取得します。本記事におけるフェデレーション(federation)は、ソースごとに 1 つずつのバーチャルグラフのセットとして実装されています。
これらの用語の詳細は Stardog ギャラリー で定義されており、Stardog 入門シリーズ ではそれらの文脈が説明されています。
この記事を読み終える頃には、以下のことを理解していることになります:
- セマンティックレイヤーは RAG とどのように併存し、それぞれをいつ選択すべきか。
- Stardog を Amazon Aurora および Amazon Redshift 間でフェデレーションする方法と、Amazon Athena やその他の AWS データソースへの拡張に関する注記。
- 本番環境でエージェントを実行するために、AgentCore Runtime、Gateway、Identity を推奨する理由。
- エージェントから Stardog へ至る 2 つの統合パス:直接 SPARQL ツールを使用する方法と、Stardog Cloud Model Context Protocol (MCP) サーバーを Gateway ツールのターゲットとして使用する方法。
- ガバナンス、デプロイメントに関するトレードオフ、および今日時点で一般提供(GA)されているものとベータ版の違い。
エージェントに必要な 3 つのレイヤー
信頼性が高く、ビジネスコンテキストを意識した回答を提供する AI エージェントは、以下の 3 つが連携して機能することに依存しています。それぞれが他では解決できない課題を扱います。
- モデル層。計画立案と文章作成が可能なファウンデーションモデルです。Amazon Bedrock は複数のモデルファミリーに単一の API を提供します。ここでは Anthropic Claude Sonnet 4.6 を使用しています。このモデルは言語を理解していますが、あなたのビジネスについては知りません。
- 意味層。ビジネス上の質問の背後にあるデータへの信頼性があり、管理されたアクセスをモデルに提供するセマンティックレイヤーです。オントロジーは概念と、それらから新しい事実を導き出すルールを宣言し、連合機能はクエリ実行時に各ソースから生データを取得します。この層が処理を担当します:どのデータが関連するかを特定し、SPARQL クエリを各ソース用の SQL に書き換え、共通の識別子に基づいて行を結合します。モデルの役割はより限定的です。ユーザーの質問を読み取り、データが必要な際に層を呼び出し、平易な英語で回答を記述します。Big_Spender ルールを連合されたソース全体に適用するなど、データに対する実際の推論はプロンプト内ではなく Stardog 内に留まります。これには Aurora と Amazon Redshift を対象とした Stardog の連合型知識グラフを使用しています。
- エージェント実行時層。エージェントをホストし、着信リクエストを終了し、ツールの認証情報を管理し、セキュリティとガバナンスのための運用インターフェースを提供する計算リソースです。AWS では選択肢の幅があります:一端には Amazon Bedrock AgentCore などのマネージド型実行環境があり、他端には Amazon ECS、Amazon EKS、または AWS Lambda などのセルフマネージド型オプションがあります。適切な選択は、エージェント運営のどの部分を自社で管理したいかによって異なります。本稿では Amazon Bedrock AgentCore を使用しています。これは AWS 上のプロダクション向けエージェントに対して最も包括的な選択肢であるためです。
3 つの層のうち、意味層(semantic layer)がこの投稿で扱うギャップであり、残りのウォークスルーはこれを構築するものです。エージェントランタイム層(agent runtime layer)は多くのチームが過小評価している部分です:エージェントはどのように呼び出され、どのように認証され、その意味層への資格情報はどこに保存され、どのようにスケールするのか。AgentCore はこれらの問いに対する答えを 1 つの管理サービスにパッケージ化しており、そのためここではそれを使用しています。
使用例:Aurora と Amazon Redshift にまたがる顧客 360 エージェント
このウォークスルーの後半では、AI エージェントが実際の分析作業を開始した瞬間に直面するすべてのギャップを浮き彫りにし、意味層が数百行のマッピングとルールでそれぞれをどのように埋めるかを示せるため、顧客 360(C360)を選びました。典型的な小売環境では、顧客プロファイル、住所、クレジットカード情報、リワード情報は運用データベースに保存されています。一方、注文、製品、カテゴリ、ベンダーは分析用のデータウェアハウスに存在します。それぞれの側は自らの役割に対して十分に最適化されていますが、どちらか片方だけでは「顧客全体」に関する質問には答えられません。「最も価値のある顧客は誰で、彼らは何を買っているのか」という問いに答えるエージェントは、2 つのデータベース、2 つのスキーマ、2 つの「顧客」の定義、そして誰ものカラムに存在しない派生概念(「最も価値がある」)を統合する必要があります。C360 はこれらのギャップを具体的な形にします。
C360 エージェントは分析チームのために稼働しています。営業担当者、マーケティング担当、あるいは不正検出アナリストから平易な英語の質問を受け付けます。エージェントはクエリを記述し、社内のデータ全体で実行して、短い説明文とそれを裏付ける数値を組み合わせた回答を返します。ユーザーが SQL や SPARQL を目にするわけではなく、またエージェントも許可されていないデータを閲覧することはありません。
ユーザーが C360 エージェントに平易な英語で質問します:「ウィスコンシン州での上位支出者は誰ですか?」顧客プロファイルと住所は Aurora に保存されており、注文合計額は Amazon Redshift に格納されています。エージェントは安定した顧客識別子を用いてこれらを結合する必要がありますが、この結合処理こそがセマンティックレイヤー(意味層)が提供する 3 つの機能の一つです。
- 共有された意味を通じたシステム間の結合。セマンティックレイヤーは、共通のビジネスキーを用いて Aurora と Amazon Redshift の双方から顧客レコードを同一の顧客アイデンティティにマッピングします。これにより、結合処理を物理的な統合パイプラインではなく、セマンティックモデルを通じて表現できるようになります。これを備えていない場合、その結合には通常、データの第 3 コピーをマテリアライズ(実体化)し、いずれかのソースが変更されるたびに同期を維持する必要のある、管理が必要なパイプラインが要求されます。
- 導出事実をルールとして扱う。 「高額支出者」のような定義は、オントロジー内でルールの形式で保持し、すべてのクエリで再表現する必要はありません。これにより、その用語を含むすべてのクエリが同じ回答を得られます。これを怠ると、その定義がダッシュボード、ノートブック、レポート間で重複することになります。閾値を変更した際、これらのコピーは互いに乖離し、同じ質問に対して異なる回答が返されるようになります。
- グラフレベルでのアクセス制御。 名前付きグラフのセキュリティ制御により、グラフ単位でアクセスを管理できるため、異なるロールを持つユーザーはエンタープライズ知識グラフの異なるサブセットのみを表示できます。より細粒度な保護が必要な場合は、:ssn や :cardNumber といった機微なプロパティを保護対象のプロパティとして指定できます。権限を持つユーザーには実際の値が表示されますが、それ以外のユーザーにはデフォルトでマスクされた値が表示されます。このアプローチにより、異なるロールのユーザーが同じクエリを実行しても、知識グラフはそれをアクセスするすべてのアプリケーションで一貫したセキュリティポリシーを強制します。
Stardog の C360 Knowledge Kit を使用しました。これはもともとローカルの CSV ファイルを読み込むものですが、Aurora PostgreSQL(顧客側)と Amazon Redshift(購入側)にまたがる連合処理に対応するように改造しました。このキットにはオントロジー、サンプルデータ、および既製のクエリが含まれており、ご自身の作業のスタート地点として活用できます。
エージェントが見るデータモデル
エージェントの下層では、C360 データは 2 つの AWS データベースに分割されています。Aurora は運用上の顧客向けテーブルを保持し、Amazon Redshift は分析用のファクトテーブルと製品次元テーブルを保持しています。
Aurora PostgreSQL(運用)
テーブル
主要カラム
customer
cid, first_name, last_name, email, ssn, phone, location
address
id, city, state, zip, street_name
credit_card
id, cid, card_num, card_type
rewards_account
id, cid, account_id, create_date
Amazon Redshift(分析)
テーブル
主要カラム
purchase
id, cid, pid, date, quantity, price, card
product
id, name, brand, price, dept
category
id, dept_name, parent
vendor
id, vendor_name, industry
両データベース間で共有される識別子は整数の cid です。これは Aurora の customer テーブルでは主キーとして、Amazon Redshift の purchase テーブルでは外部キーではないカラムとして出現します。これらをリンクする SQL 制約は存在しません。存在し得ないからです:異なるエンジン上に存在するためです。顧客と注文を結合して回答を得るには、ETL を行わずに、クエリ実行時に毎回その整数値を照合する必要があります。
これがセマンティックレイヤーが吸収するものです。オントロジーは一つの概念「:Customer」と、それに対する安定したアイデンティティを宣言します。その形式は urn:stardog:demos:c360:customer:{cid} となる IRI です。Aurora の顧客マッピングと Amazon Redshift の購入マッピングの両方が、それぞれの cid 値から同じ IRI を生成します。エージェントは、プロフィール、住所、カード、リワードアカウント、注文を備えた一つの顧客エンティティとして認識します。一方、データウェアハウス側では、それぞれの行がそのまま変更されることなく保持されます。マッピングは、両方のデータベース内の cid から同一の顧客 IRI を生成します。Stardog はこの共有アイデンティティを利用して、基盤となるデータベース同士がお互いの存在を知る必要なく、連合された結果を結合します。
リファレンスアーキテクチャ

*図 1. 重要なポイント:データは Aurora と Amazon Redshift のまま。セマンティックレイヤーを流れるのはクエリのみです。
これが推奨される本番環境のアーキテクチャです。この記事で提示された概念実証(POC)では、エージェントをスタンドアロンスクリプトとして実行するパス A が使用されました。
図には二つのフローが示されています。
インバウンド。 クライアント(アプリケーション、他のエージェント、または Stardog Studio)が AgentCore Gateway を通じてエージェントを呼び出します。Gateway はインバウンドの JSON Web Token (JWT) を検証し、Strands エージェントをホストする AgentCore Runtime へ呼び出しをルーティングします。エージェントは、計画策定と回答の構成のために Amazon Bedrock 上の Claude Sonnet 4.6 を呼び出します。
セマンティックレイヤーへのアウトバウンド。 2 つのパスが表示されています。
- パス A(今日、オレンジ色の破線):Strands エージェントが Stardog に直接接続する query_kg SPARQL ツールを呼び出します。Voicebox API アクセス権限がまだない場合(本記事の後半で説明あり)に使用してください。
- パス B(Stardog Cloud MCP、API 利用可能時、青色):AgentCore Gateway には Stardog Cloud MCP サーバーが MCP ターゲットとして登録されています。Gateway は AgentCore Identity から Stardog トークンを取得し、呼び出しを転送します。エージェントは認証情報を直接扱いません。
Stardog 自体は、Java Database Connectivity (JDBC) を介してクエリ実行時にデータウェアハウスへフェデレーションを行います。SPARQL クエリはソースごとに SQL に書き換えられ、結果は共有 IRIs(国際化識別子)上で Stardog 内で結合されます。ETL ジョブもデータの第 3 コピーも不要です。
セマンティックレイヤーの構築
フェデレーションを機能させるには 3 つの要素が必要です。オントロジーは概念(:Customer、:Order、:Product)およびそれらの間の関係を宣言します。マッピングは各データストア内の各行がどのようにしてこれらの概念のインスタンスとなるかを定義します。推論ルールは、既にスコープ内にあるデータから新しい事実を導き出します。これら 3 つすべてに対する作成インターフェースとして Stardog Designer が利用されます。
オントロジー

*図2。 Stardog Designer の C360 モデル。*Customer*、*Order*、*Product*、*Address* といった概念は、色付きのノードとして表示され、*purchased*、*card holder*、*has address*、*in category* などのラベル付き関係で接続されています。エッジにある薄く塗りつぶされたノード(*Big Spender*、*Large Order*、*2022 Orderer*、*Sports Category* の購入者)は、モデル内の推論ルールによって導出された派生クラスであり、ソースのどの列にも直接対応するものではありません。
C360 オントロジーは、ノーコードのビジュアルモデリングおよびマッピングツールである Stardog Designer で作成されています。モデル作成者は概念(:Customer, :Order, :Product)を作成し、それらを関係(:purchasedBy は :Order</co
原文を表示
In this post we show how to build a semantic layer on AWS using Stardog’s Semantic AI Application over Amazon Aurora and Amazon Redshift, and how to run a Strands Agents agent on Amazon Bedrock AgentCore that queries the layer to answer customer 360 questions across both sources without extract, transform, and load (ETL). The same Stardog deployment works behind AWS computes (Amazon Elastic Kubernetes Service (Amazon EKS), Amazon Elastic Container Service (Amazon ECS), and AWS Lambda). We use AgentCore here because it bundles inbound auth, hosting, and tool credentials into one managed service.
Enterprise analytics has been chasing the same goal for two decades: shrink the time between a business question and a trustworthy answer. Scheduled reports gave way to dashboards, then dashboards gave way to self-service business intelligence (BI). Even self-service depended on a data engineer having already built the right model for the right question, and the human analyst remained the bottleneck for everything outside the prepared dataset. Generative AI agents are the next step. Instead of visualizing data, they reason over it. They plan, write queries, evaluate results, refine, and iterate against the company’s live data on demand. *Agentic analytics* is the term for this shift: an autonomous agent at every business user’s elbow, doing the analyst’s work without waiting in the request queue.
The hard part is no longer the foundation model (FM). Foundation models available on Amazon Bedrock can already plan multi-step workflows, reason about schemas, and produce SQL well enough to act as a junior analyst would. The hard part sits underneath: the data the model reasons over. Enterprise data is scattered across systems that define the same things differently. The “customer” in your customer relationship management (CRM) system is not the same record as the “customer” in your billing system. “Revenue” calculated by the North American team isn’t the same number the European team would produce. An AI agent given direct access to this fragmented data will write technically valid queries that return wrong, conflicting, or unexplainable answers. Confidence erodes the first time two agents return two different numbers for the same question.
On AWS, that data sits across a familiar mix. Operational records live in Amazon Aurora and other Amazon Relational Database Service (Amazon RDS) engines. Analytics history lives in Amazon Redshift. Unstructured data lives in Amazon Simple Storage Service (Amazon S3), queried through Amazon Athena, and increasingly in open table formats such as Apache Iceberg, on Amazon S3 Tables, a capability of Amazon S3, which Athena, Amazon EMR, and Amazon Redshift can all read. Each layer is purpose-built for what it stores and most enterprises will keep that shape. The challenge is helping an AI agent reason across all of them at once with the same fluency a senior human analyst would bring to the same question.
Foundation models bring the language and the AWS data application brings the facts. The familiar way to connect them today is Retrieval Augmented Generation (RAG): index policy documents, manuals, and support tickets into Amazon Bedrock Knowledge Bases and pull matching passages into the model’s context at query time. RAG works well when the answer lives in text the search can find. It works less well for analytical questions where the answer depends on joining live records across systems, applying a business rule consistently, and honoring row- or column-level access policies.
What sits between language and facts, and is usually missing for those analytical questions, is *business context and business metrics*. Take a typical retail example: a shared definition of what a *customer* is, how an *order* links to one, what counts as a *big spender* or a *high-risk account*, which system owns which fact, and how the numbers the business reports are computed. The same gap shows up in other domains (claims and policies in insurance, patients and encounters in healthcare, parts and shipments in supply chain) under different names. A semantic layer captures that context once and lets every agent and tool reuse it. With it, an AI agent can compose answers from many sources and stand behind the numbers it returns. A semantic layer doesn’t replace RAG. It complements it. Most production systems need both, reachable through the same agent.
A semantic layer is an ontology-driven view of your enterprise data. The ontology captures the concepts, relationships, attributes and rules that matter to your business. Mappings declare how those concepts are mapped from rows in each live source. The agent queries the layer. The layer translates each query into SQL against the underlying systems at runtime. Data stays where it is. Meaning is captured once and reused.
When that semantic layer is implemented as Stardog does it (an ontology, stable identifiers for every entity, and rules that derive new facts, and constraints that validate the data against the ontology) the result is a *knowledge graph*. The data is connected as a graph of business entities rather than rows in tables, every entity has a stable URL-style unique identifier called an IRI, and queries traverse those connections in a W3C-defined, standards-based query language called SPARQL. Two more terms come up repeatedly in the rest of the post:
- A named graph is a labeled subset of the graph, identified by an IRI of its own. Stardog uses named graphs as the unit of access control. The same query produces different results for different roles depending on which named graphs each role is allowed to read.
- A virtual graph is a named graph whose contents are not stored in Stardog at all. They live in an external system (Aurora, Amazon Redshift, Athena) and Stardog fetches the rows on demand using the mappings. Federation in this post is implemented as a set of virtual graphs, one per source.
The Stardog glossary defines each of these terms, and the Stardog Getting Started series puts them in context.
By the end of this post you will know:
- How a semantic layer fits alongside RAG, and when to pick each.
- How to federate Stardog across Amazon Aurora and Amazon Redshift, with notes on extending to Amazon Athena and other AWS data sources.
- Why we recommend AgentCore Runtime, Gateway, and Identity for running the agent in production.
- Two integration paths from the agent to Stardog: a direct SPARQL tool, and the Stardog Cloud Model Context Protocol (MCP) server as a Gateway tool target.
- Tradeoffs on governance, deployment, and what is generally available (GA) versus beta today.
Three layers an agent needs
An AI agent that gives reliable, business-context-aware answers depends on three things working together. Each one solves a problem the others can’t.
- Model layer. A foundation model that can plan and write. Amazon Bedrock provides a single API to multiple model families. We use Anthropic Claude Sonnet 4.6. The model knows language, it doesn’t know your business.
- Meaning layer. A semantic layer that gives the model trustworthy, governed access to the data behind your business questions. The ontology declares the concepts and the rules that derive new facts from them, and the federation pulls live rows from each source at query time. The layer does the work: it figures out which data is relevant, rewrites the SPARQL query into SQL for each source, and joins the rows on shared identifiers. The model has a narrower job. It reads the user’s question, calls the layer when it needs data, and writes the answer in plain English. The actual reasoning over data, like applying the
Big_Spenderrule across the federated sources, stays inside Stardog rather than inside the prompt. We use Stardog’s federated knowledge graph over Aurora and Amazon Redshift for this.
- Agent runtime layer. The compute that hosts the agent, terminates inbound requests, manages tool credentials, and provides the operational surface for security and governance. On AWS you have a spectrum of choices: managed runtimes like Amazon Bedrock AgentCore at one end, and self-managed options like Amazon ECS, Amazon EKS, or AWS Lambda at the other. The right choice depends on how much of the agent operations you want to own. We use Amazon Bedrock AgentCore in this post because it is the most prescriptive of the options for production agents on AWS.
Of the three, the meaning layer is the gap this post is about, and the rest of the walkthrough builds it. The agent runtime layer is the one most teams underestimate: how does the agent get called, how does it authenticate, where does its credential to the semantic layer live, and how does it scale. AgentCore packages answers to those questions into one managed service, which is why we use it here.
Example use case: A customer 360 agent across Aurora and Amazon Redshift
We chose customer 360 (C360) for the rest of this walkthrough because it surfaces every gap an AI agent runs into the moment it tries to do real analytical work, and it lets us show how the semantic layer closes each one in a few hundred lines of mappings and rules. In a typical retail setup, customer profile, address, credit card, and rewards information sit in an operational database. Orders, products, categories, and vendors live in a data warehouse for analytics. Each side is well-tuned for what it does. Neither side, on its own, can answer a question about the customer as a whole. An agent that tries to answer “who are our most valuable customers, and what are they buying?” has to reconcile two databases, two schemas, two definitions of “customer”, and a derived idea (“most valuable”) that lives in nobody’s column. C360 makes those gaps concrete.
The C360 agent runs for the analytics team. It accepts a question in plain English from a sales lead, a marketer, or a fraud analyst. It writes the queries, runs them across the company’s data, and replies with a short narrative answer plus the supporting numbers. The user does not see SQL or SPARQL, and the agent does not see the data it is not allowed to see.
A user asks the C360 agent, in plain English: *“Who are our top spenders in Wisconsin?”* Customer profile and address live in Aurora. Order totals live in Amazon Redshift. The agent has to join them on a stable customer identifier, and that join is one of three things a semantic layer adds:
- Joins across systems through shared meaning. The semantic layer maps customer records from both Aurora and Amazon Redshift to a common customer identity using shared business keys. This lets the join be expressed through the semantic model rather than a physical integration pipeline. Without it, that join often requires a maintained pipeline that materializes a third copy of the data and must be kept in sync each time either source changes.
- Derived facts as rules, not queries. A definition like “big spender” can live in the ontology as a rule rather than being re-expressed in every query, and every query that mentions it gets the same answer. Without it, that definition gets duplicated across dashboards, notebooks, and reports. When the threshold changes, the copies drift apart and the same question starts returning different answers.
- Graph-level access control. Named graph security controls access at the graph level, so different roles see different subsets of the enterprise knowledge graph. For more fine-grained protection, you can designate sensitive properties such as
:ssnand:cardNumberas protected properties. Users with permission see the actual values, while others see masked values by default. With this approach, different roles can run the same query while the knowledge graph enforces consistent security policies across every application that accesses it.
We took Stardog’s C360 Knowledge Kit, which originally loads local CSVs, and adapted it to federate across Aurora PostgreSQL (customer side) and Amazon Redshift (purchase side). The kit ships an ontology, sample data, and ready-made queries. You can use it as the starting point for your own work.
The data model the agent does not see
Underneath the agent, the C360 data is split across two AWS databases. Aurora holds the operational, customer-facing tables. Amazon Redshift holds the analytics fact table and product dimensions.
Aurora PostgreSQL (operational)
Table
Key columns
customer
cid, first_name, last_name, email, ssn, phone, location
address
id, city, state, zip, street_name
credit_card
id, cid, card_num, card_type
rewards_account
id, cid, account_id, create_date
Amazon Redshift (analytics)
Table
Key columns
purchase
id, cid, pid, date, quantity, price, card
product
id, name, brand, price, dept
category
id, dept_name, parent
vendor
id, vendor_name, industry
The shared identifier across the two databases is the integer cid. It appears as a primary key in the customer table on Aurora and as a non-foreign-key column in the purchase table on Amazon Redshift. There’s no SQL constraint linking them. There can’t be: they live in different engines. Answers that join customers to their orders must reconcile that integer at query time, every time, without ETL.
This is what the semantic layer absorbs. The ontology declares one concept, :Customer, and one stable identity for it: an IRI of the form urn:stardog:demos:c360:customer:{cid}. Both the Aurora customer mapping and the Amazon Redshift purchase mapping mint that same IRI from their respective cid values. The agent sees one customer entity with a profile, addresses, cards, rewards accounts, and orders. The warehouses see their own rows, unchanged. The mappings mint the same customer IRI from the cid in both databases. Stardog uses that shared identity to join the federated results without requiring the underlying databases to know about one another.
Reference architecture

*Figure 1. Key point: data stays in Aurora and Amazon Redshift. Only queries flow through the semantic layer.*
This is the recommended production architecture. The proof of concept (POC) for this post used Path A with the agent running as a standalone script.
The diagram shows two flows.
Inbound. A client (an application, another agent, or Stardog Studio) calls the agent through AgentCore Gateway. Gateway validates the inbound JSON Web Token (JWT) and routes the call to AgentCore Runtime, which hosts the Strands agent. The agent invokes Claude Sonnet 4.6 on Amazon Bedrock for planning and answer composition.
Outbound to the semantic layer. Two paths are shown.
- Path A (today, orange dashed): The Strands agent calls a query_kg SPARQL tool that talks to Stardog directly. Use this when you don’t yet have Voicebox API access (described later in this post).
- Path B (Stardog Cloud MCP, when API access is available, blue): AgentCore Gateway has the Stardog Cloud MCP server registered as an MCP target. Gateway pulls the Stardog token from AgentCore Identity and forwards the call. The agent doesn’t touch the credential.
Stardog itself federates to the warehouses at query time over Java Database Connectivity (JDBC). SPARQL is rewritten to SQL per source. Results are joined inside Stardog on shared IRIs. There is no ETL job and no third copy of the data.
Build the semantic layer
Three pieces make the federation work. The ontology declares the concepts (:Customer, :Order, :Product) and the relationships between them. The mappings declare how rows in each datastore become instances of those concepts. Reasoning rules derive new facts from the data already in scope. Stardog Designer is the authoring surface for all three.
The ontology

*Figure 2. The C360 model in Stardog Designer. Concepts like* Customer*,* Order*,* Product*, and* Address *appear as colored nodes connected by labeled relationships (*purchased*,* card holder*,* has address*,* in category*). The lighter-shaded nodes around the edges (*Big Spender*,* Large Order*,* 2022 Orderer*, the* Sports Category *shopper) are derived classes inferred by reasoning rules in the model rather than columns in any source.*
The C360 ontology is authored in Stardog Designer, a no-code visual modeling and mapping tool. The modeler creates concepts (:Customer, :Order, :Product), connects them with relationships (:purchasedBy links an :Order</co
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み