// CSE 414 Unit 2 -- Relational Data Model // Souffle demo // run using souffle [filename] // here we declare an EDB called ParentChild .decl ParentChild(p: number, c: number) ParentChild(1,2). // person 1 is the parent of person 2 ParentChild(2,3). ParentChild(1,4). .decl Descendents(p: number, c: number) .output Descendents(IO=stdout) Descendents(x,y) :- ParentChild(x,y). Descendents(x,z) :- Descendents(x,y), ParentChild(y,z). // group descendents by parent's name .decl Grouped(p: number, c: number) .output Grouped(IO=stdout) Grouped(p,c) :- Descendents(p, _), c = count: { Descendents(p,_) }. // final output: count descendents of person 1 .decl Q(p: number, c:number) .output Q(IO=stdout) Q(p,c) :- Grouped(p, c), p=1.