The Basics

SequelSphere is a Relational Database written in JavaScript that runs in any browser and on any platform. It’s ‘Relational’, meaning that it handles SQL and stores data in tables. This enables JavaScript programmers to store and retrieve data using standard relational database methods, without worrying about browser or platform specifics. Querying the database is as easy as:

var arr = db.query("SELECT name, age, dept_id FROM empl");

…or like this:

var sql = "SELECT average(e.age) avg_age" +
          "  FROM empl e, dept d" +
          " WHERE e.dept_id = d.dept_id" +
          "   AND d.name = 'I/T'";
var average_age = db.query(sql);

Initially creating and populating a table is as simple as the following:

db.catalog.createTable({
    tableName: "EMPL",
    columns: [ "EMPL_ID", "NAME", "AGE", "DEPT_ID" ],
    primaryKey: [ "EMPL_ID" ],
    data: [
        [0,"Bob",32,0],
        [1,"John",37,2],
        [2,"Fred",28,1],
        [3,"Sue",26,3],
        [4,"Beth",22,99],
        [5,"Mary",27,3],
        [6,"Adrian",24,1]
    ]
});