Hi,
This is mainly for Josh/Kuppitz/Mallette, but others might find it interesting.
// a map-reference demonstrating how various RDBMS table features are captured
via key/value ?patterns and reference instructions.
// created a new concept called self* which is just a pointer to the current
reference (like "this" in java).
// you can see that an instruction pattern match on some of these hardcore
operations simply returns self
// and thus, are just no-ops. however, these noops tell you the nature of the
table definition.
{ name:?string, age:?int . | // table columns and
their datatypes
[count]:20, // table size
[order,age,desc,name,asc]:self*, // table rows have a
sort order
[dedup,[[valueMap,name,age]]]:self*, // name and age are the
primary key
[has,name,eq,?string]:{name:?string,age:?int}*, // table has an index
on name
[identity]:self* }* // just showing how
identity is a no-op
CREATE TABLE people (
name varchar(255),
age int,
PRIMARY KEY (name,age)
)
CREATE INDEX people_name_idx ON people (name)
*** If the formatting sucks:
https://gist.github.com/okram/41d2d40214a9411b0e69cc972ad9cb61
<https://gist.github.com/okram/41d2d40214a9411b0e69cc972ad9cb61>
I don’t know how to force a sort on a table, so the [order] instruction isn’t
being used in the CREATE TABLE. However, in general, this is how RDBMS tables
and TP4 map-references are related.
Neat?,
Marko.
http://rredux.com <http://rredux.com/>