Show HN: Convert JSON Schema to SQL DDL
a year ago
- #SQL
- #JSON Schema
- #Database
- The library 'json-schema-to-sql' converts JSON schemas into SQL DDL (create table) statements.
- It maps JSON Schema features to database features, such as type + format to column type, required to non-nullable columns, enum to CHECK constraints, and default to default column values.
- The library extends JSON Schema with 'x-' syntax for features like primary keys ('x-primaryKey').
- It supports PostgreSQL and MySQL, with PostgreSQL as the default.
- Nested structures (objects, arrays of objects, arrays of primitives) are normalized into separate tables with foreign keys to parent tables.
- The library performs three validation steps: syntax, structural, and semantic validation.
- Arrays nested in arrays are not supported due to lack of proper relational database representation.
- The project is open to contributions via GitHub pull requests.