example Joinless
typeside Ty = literal {
external_types
String -> "java.lang.String"
external_parsers
String -> "x => x"
}
schema Schools = literal : Ty {
entities
Person
School
Dept
foreign_keys
instituteOf : Person -> School
deptOf : Person -> Dept
biggestDept : School -> Dept
attributes
lastName : Person -> String
schoolName : School -> String
deptName : Dept -> String
}
instance BostonSchools = literal : Schools {
generators
ryan david adam greg gregory jason : Person
harvard mit : School
math cs : Dept
multi_equations
lastName -> {ryan Wisnesky, david Spivak, adam Chlipala, greg Morrisett, gregory Malecha, jason Gross}
schoolName -> {harvard Harvard, mit MIT}
deptName -> {math Mathematics, cs CompSci}
instituteOf -> {ryan harvard, david mit, adam mit, greg harvard, gregory harvard, jason mit}
deptOf -> {ryan math, david math, adam cs, greg cs, gregory cs, jason cs}
biggestDept -> {harvard math, mit cs}
}
schema Person = literal : Ty {
entities
Person
attributes
lastName : Person -> String
schoolName : Person -> String
}
#Find all the people whose school's biggest department is Mathematics
query BiggestDeptIsMathQuery = literal : Schools -> Person {
entity
Person -> {from p:Person
where p.instituteOf.biggestDept.deptName = Mathematics
attributes lastName -> p.lastName
schoolName -> p.instituteOf.schoolName}
}
#simpler, dynamic version of the above query
query BiggestDeptIsMathQuery_simple = simple : Schools {
from p:Person
where p.instituteOf.biggestDept.deptName = Mathematics
attributes lastName -> p.lastName
schoolName -> p.instituteOf.schoolName
}
instance BiggestDeptIsMathInBoston = eval BiggestDeptIsMathQuery BostonSchools
Keywords:
instance_literal
typeside_literal
schema_literal
query_literal
simple
eval
Options:
instance BostonSchools
Dept| ID | deptName |
|---|
| 0 | Mathematics |
| 1 | CompSci |
Person| ID | lastName | deptOf | instituteOf |
|---|
| 2 | Wisnesky | 0 | 8 |
| 3 | Spivak | 0 | 9 |
| 4 | Chlipala | 1 | 9 |
| 5 | Morrisett | 1 | 8 |
| 6 | Malecha | 1 | 8 |
| 7 | Gross | 1 | 9 |
School| ID | schoolName | biggestDept |
|---|
| 8 | Harvard | 0 |
| 9 | MIT | 1 |
instance BiggestDeptIsMathInBoston
Person| ID | lastName | schoolName |
|---|
| 0 | Wisnesky | Harvard |
| 1 | Morrisett | Harvard |
| 2 | Malecha | Harvard |