Category:SMEQL: Difference between revisions

From Rosetta Code
Content added Content deleted
No edit summary
No edit summary
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{language|SMEQL}}{{stub}}
{{language|SMEQL
|site=http://www.c2.com/cgi/wiki?TqlRoadmap
|LCT=no
}}


SMEQL is a draft query language that is meant to solve the shortcomings and annoyances of [[SQL]]. SMEQL stands for "structured meta-enabled query language" (pronounced "smeegle").
SMEQL is a draft query language that is meant to solve the shortcomings and annoyances of [[SQL]]. SMEQL stands for "structured meta-enabled query language" (pronounced "smeegle").


It is influenced by IBM's "Business-System 12" (BS-12) relational query language. BS-12 predated SQL, but was rejected over SQL because IBM felt it was too "mathy", harming sales. However, it's math-like nature is also what makes it more powerful than SQL. (It uses "functional programming" to be more specific.)
It is influenced by IBM's "Business-System 12" (BS-12) relational query language. BS-12 predated SQL, but was rejected over SQL because IBM felt it was too "mathy", potentially harming sales. However, it's math-like nature is also what makes it more powerful than SQL. It's designed to please nerds, not managers. (It uses "functional programming" to be more specific.)


The general syntax of an element is:
The general syntax of an element is:
Line 14: Line 17:
t2 = bar(t1, zog)
t2 = bar(t1, zog)


to get this:
Into:


t2 = bar(foo(blah), zog)
t2 = bar(foo(blah), zog)
Line 26: Line 29:
Here is a sample to whet your appitite:
Here is a sample to whet your appitite:


srt = orderBy(Employees, (dept, salary), order)
srt = orderBy(Employees, [dept, salary], order)
top = group(srt, [(dept) dept2, max(order) order])
top = group(srt, [(dept) dept2, max(order) order])
join(srt, top, a.dept=b.dept2 and b.order - a.order < 6)
join(srt, top, a.dept=b.dept2 and b.order - a.order < 6)
Line 33: Line 36:
this table schema:
this table schema:


Employees table
table: Employees
----------------
----------------
empID
empID
Line 42: Line 45:
Here's a brief summary of common SMEQL operators:
Here's a brief summary of common SMEQL operators:


* calc(table, columnTable) // similar to SELECT clause in SQL
* '''calc'''(table, columnTable) // ''similar to SELECT clause in SQL''
* filter(table, expression) // similar to WHERE clause in SQL
* '''filter'''(table, expression) // ''similar to WHERE clause in SQL''
* group(table, columnTable) // roughly similar to GROUP BY in SQL
* '''group'''(table, columnTable) // ''roughly similar to GROUP BY in SQL''
* join(table_1, table_2, expression)
* '''join'''(table_1, table_2, expression)
* leftJoin(table_1, table_2, expression)
* '''leftJoin'''(table_1, table_2, expression)
* orderBy(table, columnTable, [sequenceColumn]) // sorts or produces sequence numbers
* '''orderBy'''(table, columnTable, [sequenceColumn]) // ''sorts or produces sequence numbers''
* union(table_1, table_2)
* '''union'''(table_1, table_2)


A "column table" is merely a way to represent or store column information in tabular form. SMEQL provides a shortcut syntax that is similar to an SQL "WHERE" clause. Any place above where a column-table is required, one can use the shortcut syntax within square brackets "[...]". Column tables potentially allow you to "calculate" column lists instead of having to type them in manually.
A "column table" is merely a way to represent or store column information in tabular form. SMEQL provides a shortcut syntax that is similar to an SQL "WHERE" clause. Any place above where a column-table is required, one can use the shortcut syntax within square brackets "[...]" (not to be confused with "optional" syntax indicators). Column tables potentially allow you to "calculate" column lists instead of having to type them in manually.


More info can be found at: http://www.c2.com/cgi/wiki?TqlRoadmap
More info can be found at: http://www.c2.com/cgi/wiki?TqlRoadmap

Latest revision as of 03:01, 12 December 2011

Language
SMEQL
This programming language may be used to instruct a computer to perform a task.
Official website
See Also:


Listed below are all of the tasks on Rosetta Code which have been solved using SMEQL.

SMEQL is a draft query language that is meant to solve the shortcomings and annoyances of SQL. SMEQL stands for "structured meta-enabled query language" (pronounced "smeegle").

It is influenced by IBM's "Business-System 12" (BS-12) relational query language. BS-12 predated SQL, but was rejected over SQL because IBM felt it was too "mathy", potentially harming sales. However, it's math-like nature is also what makes it more powerful than SQL. It's designed to please nerds, not managers. (It uses "functional programming" to be more specific.)

The general syntax of an element is:

 resultTable = operation(parameters.....)

One can optionally nest these:

 t1 = foo(blah)
 t2 = bar(t1, zog)

to get this:

 t2 = bar(foo(blah), zog)

The final result set name is not needed. Thus, one could type:

 bar(foo(blah), zog)

However, examples here will not use the nested form. The intermediate tables should be considered virtual tables. They are not assumed to be "saved" unless explicitly requested by other operations. They are merely a way to linguistically reference query "chunks". (SQL provides views and/or nested SELECT's for a similar purpose, but these are often awkward or require DBA's.)

Here is a sample to whet your appitite:

 srt = orderBy(Employees, [dept, salary], order)
 top = group(srt, [(dept) dept2, max(order) order])
 join(srt, top, a.dept=b.dept2 and b.order - a.order < 6)

This example returns the top 6 earners in each department based on this table schema:

 table: Employees 
 ----------------
 empID
 dept
 empName
 salary 

Here's a brief summary of common SMEQL operators:

  • calc(table, columnTable) // similar to SELECT clause in SQL
  • filter(table, expression) // similar to WHERE clause in SQL
  • group(table, columnTable) // roughly similar to GROUP BY in SQL
  • join(table_1, table_2, expression)
  • leftJoin(table_1, table_2, expression)
  • orderBy(table, columnTable, [sequenceColumn]) // sorts or produces sequence numbers
  • union(table_1, table_2)

A "column table" is merely a way to represent or store column information in tabular form. SMEQL provides a shortcut syntax that is similar to an SQL "WHERE" clause. Any place above where a column-table is required, one can use the shortcut syntax within square brackets "[...]" (not to be confused with "optional" syntax indicators). Column tables potentially allow you to "calculate" column lists instead of having to type them in manually.

More info can be found at: http://www.c2.com/cgi/wiki?TqlRoadmap

Subcategories

This category has the following 3 subcategories, out of 3 total.

Pages in category "SMEQL"

This category contains only the following page.