未知のグラフスキーマを5分で探索する
使うタイミング: ドキュメントなしのグラフDBを渡された場合。有用なクエリを書く前に、まずメンタルモデルを構築する必要があるとき。
前提条件
- Neo4jのBolt URL + ユーザー名/パスワード —
NEO4J_URI=bolt://host:7687,NEO4J_USERNAME,NEO4J_PASSWORD - 探索には読み取り専用ユーザーを推奨 —
CREATE USER claude SET PASSWORD '...' SET ROLES reader
フロー
-
スキーマの概要を取得Call get_neo4j_schema. Summarize node labels, relationship types, and the most common (label)-[rel]->(label) patterns.✓ コピーしました→ サンプルトリプル付きのスキーマサマリー
-
代表的なノードをサンプリングFor the 3 most common labels, MATCH (n:Label) RETURN n LIMIT 3 each. Describe what each label seems to represent.✓ コピーしました→ ラベルの意味的な説明
-
想定されるERモデルを描くBased on schema + samples, describe in prose the 'entity' story of this graph. What's the main object, what connects to it, what's peripheral?✓ コピーしました→ 明確なドメインモデルの説明
結果: 元の作成者に確認できる1ページのドメインモデル。
注意点
- 小さなグラフのサンプリングは誤ったパターンを示す可能性がある —
MATCH (n)-[r]->() RETURN type(r), count(*)も実行して、どのリレーションシップが支配的かを確認する