icetindil | e8fd4cc | 2014-08-05 20:25:16 -0700 | [diff] [blame] | 1 | drop dataverse TinySocial if exists; |
| 2 | create dataverse TinySocial; |
| 3 | use dataverse TinySocial; |
| 4 | |
| 5 | |
| 6 | create type EmploymentType as open { |
| 7 | organization-name: string, |
| 8 | start-date: date, |
| 9 | end-date: date? |
| 10 | } |
| 11 | |
| 12 | create type FacebookUserType as closed { |
| 13 | id: int32, |
| 14 | alias: string, |
| 15 | name: string, |
| 16 | user-since: datetime, |
| 17 | friend-ids: {{ int32 }}, |
| 18 | employment: [EmploymentType] |
| 19 | } |
| 20 | |
| 21 | create dataset FacebookUsers(FacebookUserType) |
| 22 | primary key id; |
| 23 | |
| 24 | |
| 25 | let $lonelyusers := for $d in dataset FacebookUsers where count($d.friend-ids) < 2 return $d |
| 26 | let $lonelyusers2 := for $d in dataset FacebookUsers where count($d.friend-ids) < 2 return $d |
| 27 | for $l1 in $lonelyusers |
| 28 | for $l2 in $lonelyusers2 |
| 29 | where $l1.id < $l2.id |
| 30 | order by $l1.id, $l2.id |
| 31 | return { "user1": { "id": $l1.id, "name": $l1.name }, "user2": { "id": $l2.id, "name": $l2.name } }; |