Analyze a relational database schema into a conceptual model (OWL-capable) with mapping back to the source schema.
Project description
relational-schema-analyzer
Analyze a relational database schema and produce a canonical conceptual model (entities / relationships / properties), a conceptual → physical mapping back to the source relational schema, and metadata (confidence, fingerprints, patterns). Optional exports include OWL (Turtle / JSON-LD) for ontology pipelines.
This library is the relational analogue of
arangodb-schema-analyzer and
emits the same tool-contract bundle shape so that downstream consumers
(arango-ontoextract, transpilers, and ETL tools such as r2g) can treat relational and
ArangoDB sources interchangeably.
PostgreSQL / MySQL / SQL Server / Snowflake / CSV
│
▼ introspect (live catalog views, not DDL parsing)
Physical Schema (tables, columns, PKs, FKs, types)
│
▼ infer (deterministic baseline + optional LLM refinement)
{ conceptualSchema, physicalMapping, metadata } ← canonical JSON bundle
│
├──► OWL Turtle / JSON-LD (arango-ontoextract, ontology tooling)
├──► relational physical view (SQL-native query tooling, future)
└──► consumed by r2g (drives ArangoDB MappingConfig generation)
Status
Early development. Phases 0–3 implemented: the physical core (connectors, types,
FK inference) is extracted from r2g; the deterministic conceptual baseline emits a
contract-valid {conceptualSchema, physicalMapping, metadata} bundle with no LLM; and
OWL (Turtle / JSON-LD) exports + a CLI are in place. Next: optional LLM refinement
(Phase 4) and ecosystem integration (Phase 5). See:
docs/DESIGN.md— architecture, data model, tool contract, OWL mappingdocs/IMPLEMENTATION-PLAN.md— phased delivery plan & extraction inventory
from relational_schema_analyzer import (
create_connector, RelationalSchemaAnalyzer, export_owl_turtle,
)
physical = create_connector("postgresql", url, schema_name="public").get_schema()
analysis = RelationalSchemaAnalyzer().analyze(physical) # baseline, no LLM
bundle = analysis.to_bundle() # {conceptualSchema, physicalMapping, metadata}
ttl = export_owl_turtle(analysis)
# Optional LLM refinement (additive; falls back to baseline on any error):
refined = RelationalSchemaAnalyzer(
llm_provider="openai", # or "anthropic" / "openrouter" / a provider object
).analyze(physical) # better names + embed/n-ary hints
relational-schema-analyzer snapshot --source postgresql --url "$DSN" -o physical.json
relational-schema-analyzer analyze --from-snapshot physical.json --pretty
relational-schema-analyzer owl --from-snapshot physical.json --format turtle -o schema.ttl
Sources: postgresql, mysql, sqlserver, snowflake, duckdb, databricks, csv.
MCP server (optional, pip install 'relational-schema-analyzer[mcp]') exposes the same
snapshot / analyze / owl operations over the v1 tool contract:
relational-schema-analyzer-mcp # stdio (local IDE)
relational-schema-analyzer-mcp --transport sse --host 0.0.0.0 --port 8000 # remote (set RSA_MCP_TOKEN)
Why this exists
Most of the relational introspection layer already exists and is battle-tested inside
the r2g (relational-to-graph) project, but it is welded to ArangoDB ETL and cannot be
reused elsewhere. This repo extracts that core into a paradigm-neutral library and adds the
conceptual / OWL layer that r2g never had, conforming to the contract the ArangoDB
analyzer already publishes.
License
Apache-2.0 — matching the surrounding Arango ecosystem libraries
(arangodb-schema-analyzer, r2g). See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file relational_schema_analyzer-0.1.0.tar.gz.
File metadata
- Download URL: relational_schema_analyzer-0.1.0.tar.gz
- Upload date:
- Size: 134.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7522d1e91d68455afeeb3320a674abfd95af23152f54d06e4a86fd4fb28e667d
|
|
| MD5 |
17a574c8725c3f0795d68f5d98f90894
|
|
| BLAKE2b-256 |
816ba444a7739143dfdb2bd6384ed8e650693a0768cdf83bb4e62cb9af4e59ec
|
File details
Details for the file relational_schema_analyzer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: relational_schema_analyzer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 101.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aac150a79b2ab0fc4d64f6f43f86e27474c82fddf2f5693ab063a4f8ef8e4d1
|
|
| MD5 |
b32c10eb9c1aca5562219a9f7ee956b1
|
|
| BLAKE2b-256 |
b169e2748941e0ca9404a10d0480301340995bf1f6606df87a00ad234972f1f1
|