Simple DB schema for ChaiSQL¶
- (backlog): Features supported in Python
chai_sql
- parser for the database format
- evaluation
To support basic schema operations, we provide a simple syntax for describing DB relations.
Included features¶
This schema is purposefully simplified and allows to specify only the very basic information about the relations.
Only the checked features below are supported:
- Table names
- Column names
- Column value types
- Keys
- Constraints
- Dependencies
- Indexes
- Comments
Example¶
Example schema definition in ChaiSQL schema syntax
types: { Number, String, Boolean }
relation Cat: {
id: Number,
name: String,
}
relation Person: {
id: Number,
name: String,
age: Number,
}
Syntax¶
Below is the defintion of the abstract syntax of the schema file:
Approximate syntax definition for ChaiSQL schemas
-- Collection of declared type names
(
types: { (<Type>,)* }
)?
-- Listing of all relations
(
relation <Name>: { (<Key>: <Type>,)+ }
)*
Semantic correctness¶
The following properties should be respected for a schema to be semantically correct.
- All custom defined types should be declared with
types: [...]
- Relation attribute types are be available in
types: [...]
- The
types
collection can only be declared once - The
types
collection contains no duplicate types - Relation names should be unique
- Each relation should have at least one attribute
- Attribute names within each relation should be unique