HOW TO RUN (more details in HW7): STEP 1: download AsterixDB https://www.apache.org/dyn/closer.lua/asterixdb/asterixdb-0.9.9/asterix-server-0.9.9-binary-assembly.zip STEP 2: from the directory opt/local/bin run: start-sample-cluster.sh or start-sample-cluster.bat depending on whether you have a MacOS X or a Windows. Your java installation must be up to date. If you get errors, wait for instructions for HW7. STEP 3: in your browsers, type this URL: 127.0.0.1:19001 Notice that step 2 says incorrectly 19002, you must type 19001 STEP 4: run the queries below in the browser; make up your own. When finished: STEP 5: from the directory opt/local/bin run: stop-sample-cluster.sh or stop-sample-cluster.bat QUERIES -- an array select x from [1,2,3] as x; -- a multiset select x from {{1,2,3}} as x; -- an array of records select x.a from [ {"a": 1, "b":10}, {"a": 2, "b":20} ] as x; -- what about a where clause select x.a from [ {"a": 1, "b":10}, {"a": 2, "b":20} ] as x where b=20; -- don't confuse objects (i.e. records) with multisets select x from {{1,2,3}} as x; -- but this is an error: select x from {1,2,3} as x; -- can order the clauses in a logical way: from [1,2,3] as x select x; -- a nested bag from {{ {{1,2,3}}, {{2,4,6,8}} }} as x select x; -- flatten the nested bag from {{ {{1,2,3}}, {{2,4,6,8}} }} as x, x as y select y; -- or compute the sums of the inner bags from {{ {{1,2,3}}, {{2,4,6,8}} }} as x select array_sum(x); -- same with arrays: we can unnest it from [ [1,2,3], [2,4,6,8]] as x, x as y select y; -- or compute the inner sum from [ [1,2,3], [2,4,6,8]] as x select array_sum(x); -- an array of objects with nested arrays from [ {"a": 1, "b":[1,2,3]}, {"a": 2, "b":[2,4,6,8]} ] as x select x.b; -- what does this return? from [ {"a": 1, "b":[1,2,3]}, {"a": 2, "b":[2,4,6,8]} ] as x, x.b as y select x.a, y as b; -- conversely, we can nest a flat collection -- first, the easy way: let c = [ {"a": 1, "b":10}, {"a":2, "b":20}, {"a":1, "b":30} ] from c as x select x.a, (from c as y where x.a=y.a select y.b); -- see the small problem? Try this: let c = [ {"a": 1, "b":10}, {"a":2, "b":20}, {"a":1, "b":30} ] from c as x select distinct x.a, (from c as y where x.a=y.a select y.b); -- there is also a hard way, with group by and group as -- lets first examine what group by and group as do: let c = [ {"a": 1, "b":10}, {"a":2, "b":20}, {"a":1, "b":30} ] from c as x group by x.a group as g select x.a, g; -- so we still need a nested subquery: let c = [ {"a": 1, "b":10}, {"a":2, "b":20}, {"a":1, "b":30} ] from c as x group by x.a group as g select x.a, (from g as y select y.x.b);