Grammar - HighKingOfGondor/Relational_Database_Management_System GitHub Wiki

This is the root node.
program ::= { ( query | command ) }

This is the command branch.
command ::= ( open-cmd | close-cmd | write-cmd | exit-cmd | show-cmd | create-cmd | update-cmd | insert-cmd | delete-cmd ) ;

Command types as defined.
open-cmd ::= OPEN relation-name
close-cmd ::= CLOSE relation-name
write-cmd ::= WRITE relation-name
exit-cmd ::= EXIT
show-cmd ::= SHOW atomic-expr
create-cmd ::= CREATE TABLE relation-name ( typed-attribute- list ) PRIMARY KEY ( attribute-list )
update-cmd ::= UPDATE relation-name SET attribute-name = literal { , attribute-name = literal } WHERE condition
insert-cmd ::= INSERT INTO relation-name VALUES FROM ( literal {, literal } )| INSERT INTO relation-name VALUES FROM RELATION expr
delete-cmd ::= DELETE FROM relation-name WHERE condition typed-attribute-list ::= attribute-name type { , attribute-name type }

type ::= VARCHAR ( integer ) | INTEGER integer ::= digit { digit }

This is the query branch
query ::= relation-name <- expr ;
relation-name ::= identifier
identifier ::= alpha { ( alpha | digit ) }
alpha ::=a|...|z|A|...|Z|_
digit ::=0|...|9

These are the query types defined.
expr ::= atomic-expr
| selection
| projection
| renaming
| union
| difference
| product
| natural-join

Meaning behind the syntax
atomic-expr ::= relation-name | ( expr )
condition ::= conjunction { || conjunction }
conjunction ::= comparison { && comparison } comparison ::= operand op operand | ( condition )
op ::===|!=|<|>|<=|>=
operand ::= attribute-name | literal
attribute-name ::= identifier
attribute-list ::= attribute-name { , attribute-name }
literal ::= intentionally left unspecified

These are the query command definitions
selection ::= select ( condition ) atomic-expr
projection ::= project ( attribute-list ) atomic-expr
renaming ::= rename ( attribute-list ) atomic-expr
union ::= atomic-expr + atomic-expr
difference ::= atomic-expr - atomic-expr
product ::= atomic-expr * atomic-expr
natural-join ::= atomic-expr & atomic-expr

⚠️ **GitHub.com Fallback** ⚠️