Htsql
Encyclopedia
Hyper Text Structured Query Language (HTSQL) is a schema-driven URI-to-SQL query language that takes a request over HTTP, converts it to a SQL
SQL
SQL is a programming language designed for managing data in relational database management systems ....

 query, executes the query against a database, and returns the results in a format best suited for the user agent (CSV, HTML, etc.) The HTSQL language is implemented on "HTSQL servers," which use HTSQL to convert web requests into equivalent SQL, executes requests on a server-side database, and returns results in XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

, HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

, CSV
CSV
CSV may refer to:* Clerics of Saint Viator* Common Stored Value Ticket* Confederación Sudamericana de Voleibol* Character Strengths and Virtues* Christian Social People's Party* Community Service Volunteers...

, JSON
JSON
JSON , or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects...

, or YAML
YAML
YAML is a human-readable data serialization format that takes concepts from programming languages such as C, Perl, and Python, and ideas from XML and the data format of electronic mail . YAML was first proposed by Clark Evans in 2001, who designed it together with Ingy döt Net and Oren Ben-Kiki...

 formats. The current implementation as of April 2010 uses Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

 and works with PostgreSQL
PostgreSQL
PostgreSQL, often simply Postgres, is an object-relational database management system available for many platforms including Linux, FreeBSD, Solaris, MS Windows and Mac OS X. It is released under the PostgreSQL License, which is an MIT-style license, and is thus free and open source software...

, MySQL
MySQL
MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...

, SQLite
SQLite
SQLite is an ACID-compliant embedded relational database management system contained in a relatively small C programming library. The source code for SQLite is in the public domain and implements most of the SQL standard...

, Oracle
Oracle database
The Oracle Database is an object-relational database management system produced and marketed by Oracle Corporation....

, and Microsoft SQL Server
Microsoft SQL Server
Microsoft SQL Server is a relational database server, developed by Microsoft: It is a software product whose primary function is to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network...

 databases.

HTSQL was prototyped and developed by Clark Evans (who proposed YAML
YAML
YAML is a human-readable data serialization format that takes concepts from programming languages such as C, Perl, and Python, and ideas from XML and the data format of electronic mail . YAML was first proposed by Clark Evans in 2001, who designed it together with Ingy döt Net and Oren Ben-Kiki...

 in 2001) and implemented by Kirill Simonov, both of Prometheus Research.

Scope

HTSQL's intended audience is business users who are not SQL programmers. It seeks to simplify non-intuitive relational queries, such as aggregates and projections. The goal is not completeness in replicating SQL, but simplicity and intuitiveness. HTSQL allows users who are familiar with the data, but not SQL syntax, to directly access the database without going through an application.

Syntax

HTSQL uses a URI-based query syntax. Queries typically begin with a single table, optionally prefixed by a schema and followed by a filter expression to limit the number of rows that are returned.

Examples

Joins can be made across tables by referencing the column name preceded by the table name. This example requests the title of a degree program from the program table and the school name from the school table:


/program{school.name, title}


The result of this query from the HTSQL command-line system is:


program
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
school.name | title
--------------------------+-----------------------------------
School of Art and Design | Post Baccalaureate in Art History
School of Art and Design | Bachelor of Arts in Art History
School of Art and Design | Bachelor of Arts in Studio Art
School of Business | Graduate Certificate in Accounting
...


Aggregate expressions can be used when there are many-to-one relationships in the database.

/school{name, count(program), count(department)}


The result shows the count (number) of programs and departments in each school:


school
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
name | count(program) | count(department)
-------------------------+----------------+------------------
School of Art and Design | 3 | 2
School of Business | 5 | 3
College of Education | 7 | 2
School of Engineering | 8 | 4

Applications

HTSQL can be used for ad-hoc database queries. Its developers consider it to be more concise and intuitive and therefore less error-prone than SQL for non-technical users.

HTSQL can also be used by "accidental programmers", such as data analysts and UI developers. Besides more readable, HTTP-based queries, HTSQL's developers claim it helps avoid common SQL mistakes like accidental joins.

Versions and licensing

HTSQL follows a dual license model. The software may be used free of charge with open source relational databases, including MySQL
MySQL
MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...

 and PostgreSQL
PostgreSQL
PostgreSQL, often simply Postgres, is an object-relational database management system available for many platforms including Linux, FreeBSD, Solaris, MS Windows and Mac OS X. It is released under the PostgreSQL License, which is an MIT-style license, and is thus free and open source software...

. Source code is available on the bitbucket
Bitbucket
Bitbucket is a web-based hosting service for projects that use either the Mercurial or Git revision control systems. Bitbucket offers both commercial plans and free accounts...

 site.

A commercial version of HTSQL, compatible with commercial databases like Oracle
Oracle database
The Oracle Database is an object-relational database management system produced and marketed by Oracle Corporation....

 and Microsoft SQL Server
Microsoft SQL Server
Microsoft SQL Server is a relational database server, developed by Microsoft: It is a software product whose primary function is to store and retrieve data as requested by other software applications, be it those on the same computer or those running on another computer across a network...

, is also available.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK