Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active December 20, 2019 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenwebb/7a418a07fdac01c0f8519f232765a9e7 to your computer and use it in GitHub Desktop.
Save kenwebb/7a418a07fdac01c0f8519f232765a9e7 to your computer and use it in GitHub Desktop.
Database stuff
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Fri Dec 20 2019 09:21:05 GMT-0500 (Eastern Standard Time)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: Database stuff
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: 7a418a07fdac01c0f8519f232765a9e7
Keywords:
My Notes
--------
December 20, 2019
References
----------
SQL parsers and tools
---------------------
() https://www.npmjs.com/package/js-sql-parser
parse / stringify sql (select grammar) in js.
note that it only handles SELECT statements
() https://github.com/kripken/sql.js
SQLite compiled to JavaScript through Emscripten
sql.js is a port of SQLite to Webassembly, by compiling the SQLite C code with Emscripten. It uses a virtual database file stored in memory, and thus doesn't persist the changes made to the database. However, it allows you to import any existing sqlite file, and to export the created database as a JavaScript typed array.
There are no C bindings or node-gyp compilation here, sql.js is a simple JavaScript file, that can be used like any traditional JavaScript library. If you are building a native application in JavaScript (using Electron for instance), or are working in node.js, you will likely prefer to use a native binding of SQLite to JavaScript.
SQLite is public domain, sql.js is MIT licensed.
Sql.js predates WebAssembly, and thus started as an asm.js project. It still supports asm.js for backwards compatibility.
() https://github.com/ondras/wwwsqldesigner
WWW SQL Designer, your online SQL diagramming tool
WWW SQL Designer allows users to create database designs, which can be saved/loaded and exported to SQL scripts. Various databases and languages are supported. Ability to import existing database design.
() https://github.com/brianc/node-sql
SQL generation for node.js
() https://github.com/sequelize/sequelize
An easy-to-use multi SQL dialect ORM for Node.js
() https://sequelize.org
Sequelize is a promise-based Node.js ORM for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. It features solid transaction support, relations, eager and lazy loading, read replication and more.
() https://github.com/forward/sql-parser
A SQL parser written in pure JS
SQL Parser is a lexer, grammar and parser for SQL written in JS. Currently it is only capable of parsing fairly basic SELECT queries but full SQL support will hopefully come in time. See the specs for examples of currently supported queries.
latest is 4 years old
() https://github.com/knex/knex
A query builder for PostgreSQL, MySQL and SQLite3, designed to be flexible, portable, and fun to use.
() https://github.com/Vincit/objection.js
An SQL-friendly ORM for Node.js
Objection.js is an ORM for Node.js that aims to stay out of your way and make it as easy as possible to use the full power of SQL and the underlying database engine while still making the common stuff easy and enjoyable.
Even though ORM is the best commonly known acronym to describe objection, a more accurate description is to call it a relational query builder. You get all the benefits of an SQL query builder but also a powerful set of tools for working with relations.
Objection.js is built on an SQL query builder called knex. All databases supported by knex are supported by objection.js. SQLite3, Postgres and MySQL are thoroughly tested.
() https://github.com/Vincit/objection-graphql
GraphQL schema generator for objection.j
() https://github.com/google/lovefield
Lovefield is a relational database for web apps. Written in JavaScript, works cross-browser. Provides SQL-like APIs that are fast, safe, and easy to use.
() https://github.com/balderdashy/waterline
An adapter-based ORM for Node.js with support for mysql, mongo, postgres, mssql (SQL Server), and more
() http://waterlinejs.org
() https://github.com/fibo/SQL92-JSON
can stringify a JSON into an SQL and viceversa parse an SQL and serialize it into a JSON
supports SELECT, CREATE TABLE
KSW I might be able to edit this, including adding support for INSERT
() https://github.com/yoo2001818/yasqlp
Yet another SQL Parser for Javascript
uses a Nearly parser
includes select, insert, delete, update
() https://nearley.js.org/
Parsers turn strings of characters into meaningful data structures (like a JSON object!). nearley is a fast, feature-rich, and modern parser toolkit for JavaScript.
()
The Third Manifesto, D, Tutorial D, Rel, M36, etc.
--------------------------------------------------
() https://en.wikipedia.org/wiki/Relational_model
The relational model (RM) for database management is an approach to managing data using a structure and language consistent with first-order predicate logic, first described in 1969 by English computer scientist Edgar F. Codd,[1][2] where all data is represented in terms of tuples, grouped into relations. A database organized in terms of the relational model is a relational database.
The purpose of the relational model is to provide a declarative method for specifying data and queries: users directly state what information the database contains and what information they want from it, and let the database management system software take care of describing data structures for storing the data and retrieval procedures for answering queries.
Most relational databases use the SQL data definition and query language; these systems implement what can be regarded as an engineering approximation to the relational model. A table in an SQL database schema corresponds to a predicate variable; the contents of a table to a relation; key constraints, other constraints, and SQL queries correspond to predicates. However, SQL databases deviate from the relational model in many details, and Codd fiercely argued against deviations that compromise the original principles.
() https://en.wikipedia.org/wiki/Relational_algebra
Relational algebra, first created by Edgar F. Codd while at IBM, is a family of algebras with a well-founded semantics used for modelling the data stored in relational databases, and defining queries on it.
The main application of relational algebra is providing a theoretical foundation for relational databases, particularly query languages for such databases, chief among which is SQL.
() https://en.wikipedia.org/wiki/The_Third_Manifesto
The Third Manifesto (1995) is Christopher J. Date's and Hugh Darwen's proposal for future database management systems, a response to two earlier Manifestos with the same purpose. The theme of the manifestos is how to avoid the "object-relational impedance mismatch" between object-oriented programming languages and relational database management systems. The Third Manifesto proposes to maintain the relational model for databases and to support objects as user-defined types.
A major theme of the manifesto is to explain how the inadequacies of existing relational database management systems are not shortcomings of the relational database model per se, but rather, of implementation decisions in those systems, and of the SQL query language that most of these systems use.
The manifesto describes an alternative to SQL, named D. D is a specification of desirable characteristics of a database language, rather than a specific syntax or grammar. As such, it describes a family of languages rather than any particular language. However, as an example, a particular member of the hypothetical D "family" called Tutorial D is described in detail, including significant portions of its grammar.
() https://en.wikipedia.org/wiki/D_(data_language_specification)
D is a set of prescriptions for what Christopher J. Date and Hugh Darwen believe a relational database management system ought to be like. It is proposed in their paper The Third Manifesto, first published in 1994 and elaborated on in several books since then.
D by itself is an abstract language specification. It does not specify language syntax. Instead, it specifies desirable and undesirable language characteristics in terms of prescriptions and proscriptions. Thus, D is not a language but a family of both implemented and future languages. A "valid D" must have a certain set of features, and exclude a different set of features which Date and Darwen consider unwise and contrary to the relational model proposed by E. F. Codd in 1970. A valid D may have additional features which are outside the scope of relational databases.
Tutorial D
Tutorial D is a specific D which is defined and used for illustration in The Third Manifesto. Implementations of D need not have the same syntax as Tutorial D. The purpose of Tutorial D is both educational and to show what a D might be like. Rel is an implementation of Tutorial D.
() https://reldb.org
Rel is a free, open-source, cross-platform, true relational database management system with an advanced query language called Tutorial D.
Tutorial D was designed by noted database researchers and authors C J Date and Hugh Darwen.
() https://github.com/DaveVoorhis/Rel
() http://thethirdmanifesto.com/
() https://player.oreilly.com/videos/9781491908778
An Introduction to Set Theory, Chris Date
()
]]></Notes>
<_-.XholonClass>
<!-- domain objects -->
<PhysicalSystem/>
<Block/>
<Brick/>
<!-- quantities -->
<Height superClass="Quantity"/>
</_-.XholonClass>
<xholonClassDetails>
<Block>
<port name="height" connector="Height"/>
</Block>
</xholonClassDetails>
<PhysicalSystem>
<Block>
<Height>0.1 m</Height>
</Block>
<Brick multiplicity="2"/>
</PhysicalSystem>
<Blockbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var a = 123;
var b = 456;
var c = a * b;
if (console) {
console.log(c);
}
//# sourceURL=Blockbehavior.js
]]></Blockbehavior>
<Heightbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var myHeight, testing;
var beh = {
postConfigure: function() {
testing = Math.floor(Math.random() * 10);
myHeight = this.cnode.parent();
},
act: function() {
myHeight.println(this.toString());
},
toString: function() {
return "testing:" + testing;
}
}
//# sourceURL=Heightbehavior.js
]]></Heightbehavior>
<Brickbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
$wnd.xh.Brickbehavior = function Brickbehavior() {}
$wnd.xh.Brickbehavior.prototype.postConfigure = function() {
this.brick = this.cnode.parent();
this.iam = " red brick";
};
$wnd.xh.Brickbehavior.prototype.act = function() {
this.brick.println("I am a" + this.iam);
};
//# sourceURL=Brickbehavior.js
]]></Brickbehavior>
<Brickbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
console.log("I'm another brick behavior");
]]></Brickbehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Block</title>
<rect id="PhysicalSystem/Block" fill="#98FB98" height="50" width="50" x="25" y="0"/>
<g>
<title>Height</title>
<rect id="PhysicalSystem/Block/Height" fill="#6AB06A" height="50" width="10" x="80" y="0"/>
</g>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment