Hacker News new | past | comments | ask | show | jobs | submit login

I played a little fast and loose to convey the basic idea. To elaborate since you asked, introduce typed tuples/records as first-class entities, then "tables" are just a sequence of records declared with a particular lifetime.

Relations are functions over these sequences. The embedded relation is then a stored function over a set of nested sequences. So to add the concrete types:

    var firstQuery = select Id, Name, Payment from Foo where ...
    var compositeQuery = select Id, Name, Total from firstQuery where ...

    create table StoredQuery(id int not null primary key, query relation{Id int, Name Text, Payment decimal})
    insert into StoredQuery values (0, firstQuery)
Again eliding a few details, but hopefully you get the basic idea.



I think what you're describing is already present as of SQL 2003 in the form of multisets:

http://farrago.sourceforge.net/design/CollectionTypes.html

However, good luck finding a database engine that necessarily supports such features. Some support array types, but I haven't seen too many that support multisets.


What you're asking for is an independently evolving logical schema on top of the physical schema - this is a great idea, but performance guarantees are highly tied to the physical layout of the data.

Apache Spark is the best example I've seen of this in that you can compose schemas on the fly and it will unroll them at the end based on physical layout.


This particular use case sounds like a MATERIALIZED VIEW, and views in general for doing what you're asking for...


A materialized view would be an optimization technique used when compiling a schema containing first-class relations (essentially, memoization). First-class relations are more general though.

But first-class relations would also present some optimization challenges, so a subset of a relational system with a restricted form of first-class relations corresponding to materialized views that can be stored in table columns and used in queries would get pretty close.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: