A comparison of experimental query languages. The example numbering is based on QueryLanguageComparison.
Motivation for this topic is covered in ExperimentalQueryLanguageDiscussion.
Experimental Query Languages:
- SMEQL - TqlRoadmap, Structured Meta-Enabled Query Language
Example 1: Retrieve all columns/attributes and rows/tuples from a table/RelVar
SMEQL (TqlRoadmap):
calc(myThings, [])
// or
filter(myThings, 1=1)
Example 2: Restriction
SMEQL:
filter(myThings, name='blah')
Example 3: Restriction and projection with unique result
SMEQL:
T1 = filter(myThings, name='blah')
T2 = calc(T1, [A, B, C])
unique(T2)
//
// nested style
//
unique(calc(filter(myThings, name='blah'), [A, B, C]))
Example 3b: Restriction and projection without required uniqueness
SMEQL:
T1 = filter(myThings, name='blah')
calc(T1, [A, B, C])
//
// nested style
//
calc(filter(myThings, name='blah'), [A, B, C])
Example 4: Aggregation
SMEQL:
group(sp, [snumber, count() p_count])
Example 5: Insertion
SMEQL:
insert(myThings, [(1)a,(2)b,(3)c,('glub')name])
insert(myThings, [(4)a,(5)b,(6)c,('glob')name])
- Note how the value listing uses the same syntax as "Calc" (roughly a SELECT statement equivalent.)
Example 6: Table/relvar creation
create("myThings", dataDictionaryTable)
- Note: SmeQl does not pre-define table features, such as column types, in order to facilitate domain independence and improve compatibility with existing RDBMS vendors.
Example 7: Transitive closure or recursion - "all paths" of a digraph
Example 8: Natural equi-join
SMEQL:
(No current natural join. Predefined "join dictionary" recommended instead. See TqlChainedJoin.)
Example 9: Equi-join
SMEQL:
J = join(red, blue, a.x = b.y)
Calc(J, [foo, bar])
- Where do 'a' and 'b' come from?
- See TqlPrefix. Basically "a" is the left table and "b" the right table.
Example 10: Equi-join with same-named key
SMEQL
J = join(red, blue, a.x = b.x)
Calc(J, [foo, bar])
Example 11: Top 3 largest planets, use name if tie
SMEQL
sized = orderBy(planets, [desc(diameter), name], sequence)
filter(sized, sequence <= 3)
See also ConceptualQueryExampleOfAdvantages
CategoryQueryLanguage, CategorySpeculative