Recently I am reading the book “SQL The Complete Reference” to refresh the SQL language of the RDMS. I find that the SQL syntax diagram, sometimes also called SQL railroad, helps a lot in understanding the structure of the SQL statements. It shows which part is optional, which part can be repeated, and which part is required, etc. Although the SQL language has been standardized, most of the RDMS dialect have their own specific SQL syntax. So it will be helpful, if I can create the SQL railroad of myself, eliminating trivial parts and leaving only the standardized or important parts, when I take the SQL language of MariaDB for reference.
After searching using google, I finally find a website for creating customized SQL railroad as below:
For example, if I input the below W3C syntax statement,
create_database ::= ‘CREATE’ ( ‘DATABASE’ | ‘SCHEMA’ ) ‘IF NOT EXISTS’? db_name
I will get the below SQL railroad:
It will be more intuitive for a person to get the overall structure of a SQL statement using the SQL railroad than using the BCNF, if the SQL statement is more complex, for example, the ‘create table’ statement. I will not show it here. You can try it by yourself.
In fact, there are some other websites or standalone applications that can be used to generated SQL railroad. However, I find the railroad generated by this site is more prettier than using others. If you find another one that is better than this one, please gently let me know, so that I can switch to yours. In fact, it would be better if there were arrows in the SQL railroad generated by the above website to indicate the flow direction.