Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Table of Contents

Example: SQL from ontology

---
to: db/{{ table }}.sql
rdf:
  - "graphs/domain.ttl"
sparql:
  matrix:
    query: |
      PREFIX nk: <https://neako.app/onto#>
      SELECT ?table ?col ?dtype WHERE {
        ?c a nk:Class ; nk:sqlName ?table .
        ?c nk:property [ nk:sqlName ?col ; nk:sqlType ?dtype ] .
      } ORDER BY ?table ?col
    bind: { table: "?table", col: "?col", dtype: "?dtype" }
determinism: { seed: schema-1, sort: table }
---
CREATE TABLE {{ table }} (
  {{ col }} {{ dtype }}
);

Run:

ggen gen db schema