Skip to content
Snippets Groups Projects
Commit a96adb40 authored by Claude Brisson's avatar Claude Brisson
Browse files

Improve syntax, comment example

parent 42a534ac
No related branches found
No related tags found
No related merge requests found
Pipeline #446 failed
.gradle
.idea
build
......@@ -9,10 +9,12 @@ grammar KDDL {
schema = 'schema' NAME ( '{' ( table | link )* '}' )? ;
table = 'table' NAME ( ':' parent )? ( '{' field* '}' )? ;
parent = NAME ;
field = primary_key? NAME ( ':' type optional? | arrow NAME direction? ) ;
field = primary_key? NAME ( ':' type optional? default? | arrow NAME direction? ) ;
type = 'boolean' | 'integer' | 'float' | 'double' | 'varchar' '(' INTEGER ')' | 'text' ;
primary_key = '*' ;
optional = '?' ;
default = '=' expression ;
expression = NULL | BOOLEAN | NUMBER | STRING ;
link = NAME '*'? arrow (NAME '.')? NAME direction? ;
arrow = ( '-' | '.' )+ '>' ;
direction = '(' ( 'up' | 'down' | 'left' | 'right' ) ')' ;
......@@ -22,5 +24,6 @@ grammar KDDL {
INTEGER = "[0-9]+" ;
NUMBER = "[0-9]+([.][0-9]+)?" ;
STRING = "'(?:\\?.)*?'" ;
NULL = 'null' ;
}
database easytarif {
// Definition for database geo
// a database contains schemas
database geo {
// a schema contains tables and links
schema infra {
// a table contains fields, either given a type or a destination table
table zone {
*code : varchar(10)
name : varchar(50)
description : text?
*code : varchar(10) // '*' stands for 'part of pk', otherwise pk is generated as needed
name : varchar(50) // not null by default
description : text? // '?' stands for nullable field
active : boolean = false // default value
}
table department : zone
table department : zone // inherit a table from another (for engines which support table inheritance like PostgresQL)
table city : zone
table link {
distance : integer
src_id --> zone
dst_id --> zone
distance : integer // standard field
src_id --> zone // mandatory foreign key field
dst_id --> zone // idem
hub_id ..> zone // nullable foreign key field
}
city *--> department (up)
}
schema carrier {
schema client {
table hub { tension : float }
table location { address : text? }
hub *--> infra.zone
location *..> infra.zone // foreign key referencing a table in another schema
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment