practice1n4j
SLIP 1
Society – HCL
NODES
Person
create(p:Person{Name:"Tushar",Age:24}) return p;
create(p:Person{Name:"Ganesh",Age:45}) return p;
create(p:Person{Name:"Amar",Age:26}) return p;
create(p:Person{Name:"Lata",Age:77}) return p;
create(p:Person{Name:"Shanti",Age:80}) return p;
Project
create(p:Project{Name:"Finance Project"}) return p;
create(p:Project{Name:"Sales Project"}) return p;
create(p:Project{Name:"Marketing Project"}) return p;
Sister
create(s:Sister{Name:"Sanskruti"}) return s;
Brother
create(b:Brother{Name:"Vinay"}) return b;
Children
create(c:Children{Name:"Amit"}) return c;
Location
create(l:Location{Name:"Pune"}) return l;
create(l:Location{Name:"Mumbai"}) return l;
create(l:Location{Name:"Kolhapur"}) return l;
RELATIONSHIPS
Works_in
match(p:Person),(p1:Project) where p.Name="Tushar" and
p1.Name="Finance Project" create (p)-[:Works_in]->(p1) return p,p1;
match(p:Person),(p1:Project) where p.Name="Ganesh" and
p1.Name="Finance Project" create (p)-[:Works_in]->(p1) return p,p1;
match(p:Person),(p1:Project) where p.Name="Amar" and
p1.Name="Sales Project" create (p)-[:Works_in]->(p1) return p,p1;
Friend_of
match(p:Person),(p1:Person) where p.Name="Tushar" and
p1.Name="Ganesh" create (p)-[:Friend_of]->(p1) return p,p1;
match(p:Person),(p1:Person) where p.Name="Ganesh" and
p1.Name="Amar" create (p)-[:Friend_of]->(p1) return p,p1;
Brother_of
match(p:Person),(b:Brother) where p.Name="Ganesh" and
b.Name="Vinay" create (p)-[:Brother_of]->(b) return p,b;
Parent_of
match(p:Person),(c:Children) where p.Name="Ganesh" and
c.Name="Amit" create (p)-[:Parent_of]->(c) return p,c;
Grandmother_of
match(p:Person),(c:Children) where p.Name="Lata" and
c.Name="Amit" create (p)-[:Grandmother_of]->(c) return p,c;
Stays_in
match(p:Person),(l:Location) where p.Name="Ganesh" and
l.Name="Pune" create (p)-[:Stays_in]->(l) return p,l;
match(p:Person),(l:Location) where p.Name="Tushar" and
l.Name="Mumbai" create (p)-[:Stays_in]->(l) return p,l;
match(p:Person),(l:Location) where p.Name="Amar" and
l.Name="Mumbai" create (p)-[:Stays_in]->(l) return p,l;
QUERIES
3.a
match(p:Person),(l:Children)where(p)-[:Parent_of]->(l) return p.Name;
Output:
Parent
"Ganesh"
3.b
match(p:Person),(l:Projectn)where l.Name="Finance Project" and (p)-[:Works_in]->(l) return p.Name;
Output:
p.Name
"Tushar"
"Ganesh"
3.c
match(n:Person)-[r4:Friend_of]->(m:Person) return max(n)
Output :
Ganesh
3.d
match(p:Person)-[:Grandmother_of]->(l) return p.Name;
Output :
p.Name
"Lata"
"Shanti"
SLIP 2
Dairy Brand
NODES
Brand
create(b:Brand{Name:"Gokul",Popularity:"95%"}) return b;
create(b:Brand{Name:"Britannia",Popularity:"45%"}) return b;
create(b:Brand{Name:"Amul",Popularity:"75%"}) return b;
Product
create(p:Product{Name:"Cheese"}) return p;
create(p:Product{Name:"Curd"}) return p;
create(p:Product{Name:"Milk"}) return p;
create(p:Product{Name:"Butter"}) return p;
Category
create(c:Category{Name:"Low Fat"}) return c;
create(c:Category{Name:"Medium Fat"}) return c;
create(c:Category{Name:"Medium Fat"}) return c;
create(c:Category{Name:"High Fat"}) return c;
Region
create(r:Region {Name:"Maharashtra"}) return r;
create(r:Region {Name:"Gujarat"}) return r;
create(r:Region {Name:"UP"}) return r;
RELATIONSHIPS
Has_Product
match(b:Brand),(p:Product) where b.Name="Amul" and
p.Name="Cheese" create (b)-[:Has_Product]->(p) return b,p;
match(b:Brand),(p:Product) where b.Name="Gokul" and
p.Name="Milk" create (b)-[:Has_Product]->(p) return b,p;
match(b:Brand),(p:Product) where b.Name="Britannia" and
p.Name="Cheese" create (b)-[:Has_Product]->(p) return b,p;
match(b:Brand),(p:Product) where b.Name="Gokul" and
p.Name="Cheese" create (b)-[:Has_Product]->(p) return b,p
Has_Category
match(p:Product),(c:Category) where p.Name="Curd" and
c.Name="Medium Fat" create (p)-[:Has_Category]->(c) return p,c;
match(p:Product),(c:Category) where p.Name="Milk" and
c.Name="Low Fat" create (p)-[:Has_Category]->(c) return p,c;
match(p:Product),(c:Category) where p.Name="Cheese" and
c.Name="High Fat" create (p)-[:Has_Category]->(c) return p,c;
Popular_In
match(b:Brand),(r:Region) where b.Name="Amul" and
r.Name="Maharashtra" create (b)-[:Popular_In {Popularity:45}]->(r) return b,r;
match(b:Brand),(r:Region) where b.Name="Gokul" and
r.Name="Maharashtra" create (b)-[:Popular_In {Popularity:79}]->(r) return b,r;
match(b:Brand),(r:Region) where b.Name="Amul" and
r.Name="UP" create (b)-[t:Popular_In {Popularity:90}]->(r) return b,r;
match(b:Brand),(r:Region) where b.Name="Britannia" and
r.Name="Maharashtra" create (b)-[:Popular_In {Popularity:34}]->(r) return b,r;
match(b:Brand),(r:Region) where b.Name="Britannia" and
r.Name="Gujarat" create (b)-[:Popular_In {Popularity:89}]->(r) return b,r;
match(b:Brand),(r:Region) where b.Name="Gokul" and
r.Name="Gujarat" create (b)-[:Popular_In {Popularity:61}]->(r) return b,r;
QUERIES
3.a
MATCH (b:Brand) return b.Name as Brand_Names
Output :
Brand_Names
"Gokul"
"Britannia"
"Amul"
3.b
match(b:Brand)-[r:Popular_In]->(r1:Region {Name:"Maharashtra"}) WHERE r.Popularity>70 return b.Name
Output :
b.Name
"Gokul"
3.c
match(b:Brand)-[r:Has_Product]->(c:Product {Name:"Cheese"}),(b:Brand)-[p:Popular_In]->(r1:Region {Name:"Gujarat"}) WHERE p.Popularity>80 return b.Name
Output :
b.Name
"Britannia"
3.d
match(b:Brand)-[r:Has_Product]->(c:Product {Name:"Milk"}),(p2:Product)-[p:Has_Category]->(r1:Category {Name:"Low Fat"}) return b.Name
Output :
b.Name
"Gokul"
SLIP 3
Import Export
NODES
COUNTRY
create (c:Country{Name:"India"}) return c;
create (c:Country{Name:"USA"}) return c;
create (c:Country{Name:"Israil"}) return c;
create (c:Country{Name:"Arab"}) return c;
create (c:Country{Name:"Europe"}) return c;
STATES
create (s:States{Name:"Maharashtra"}) return s;
create (s:States{Name:"Punjab"}) return s;
create (s:States{Name:"California"}) return s;
create (s:States{Name:"Liverpool"}) return s;
PRODUCT
create (p:Product{Name:"Wheat",production:75}) return p;
create (p:Product{Name:"Oil",production:90}) return p;
create (p:Product{Name:"Sugar",production:50}) return p;
create (p:Product{Name:"GroundNuts",production:50}) return p;
create (p:Product{Name:"Cotton",production:50}) return p;
RELATIONSHIPS
Has_States and Produces
match (c:Country),(s:States),(p:Product) where c.Name="India" and s.Name="Maharashtra" and
p.Name="Wheat" create (c)-[:has_States]->(s)-[:Produces {Production:80}]->(p) return c,s,p;
match (c:Country),(s:States),(p:Product) where c.Name="USA" and s.Name="California" and
p.Name="Oil" create (c)-[:has_States]->(s)-[:Produces {Production:57}]->(p) return c,s,p;
match (c:Country),(s:States),(p:Product) where c.Name="India" and s.Name="Maharashtra" and
p.Name="Oil" create (c)-[:has_States]->(s)-[:Produces {Production:60}]->(p) return c,s,p;
match (c:Country),(s:States),(p:Product) where c.Name="India" and s.Name="Maharashtra" and
p.Name="GroundNuts" create (c)-[:has_States]->(s)-[:Produces {Production:45}]->(p) return c,s,p;
match (c:Country),(s:States),(p:Product) where c.Name="India" and s.Name="Punjab" and
p.Name="Sugar" create (c)-[:has_States]->(s)-[:Produces {Production:50}]->(p) return c,s,p;
match (c:Country),(s:States),(p:Product) where c.Name="India" and s.Name="Liverpool" and
p.Name="Sugar" create (c)-[:has_States]->(s)-[:Produces {Production:78}]->(p) return c,s,p;
match (c:Country),(s:States),(p:Product) where c.Name="USA" and s.Name="California" and
p.Name="Sugar" create (c)-[:has_States]->(s)-[:Produces {Production:90}]->(p) return c,s,p;
Imports
match(c:Country),(p:Product) where c.Name="USA" and
p.Name="Oil" create (c)-[:Imports]->(p) return c,p
match(c:Country),(p:Product) where c.Name="India" and
p.Name="Wheat" create (c)-[:Imports]->(p) return c,p
match(c:Country),(p:Product) where c.Name="Europe" and
p.Name="Sugar" create (c)-[:Imports]->(p) return c,p
QUERIES
3.a
match(c:Country)-[r1:has_States]->(s:States),(s:States)-[r2:Produces]->(p:Product {Name:"Oil"}) return DISTINCT c.Name
Output :
c.Name
"India"
"USA"
3.b
match(s:States {Name:"Maharashtra"})-[r:Produces]->(pr:Product) return pr.Name
Output :
pr.Name
"GroundNuts"
"Oil"
"Wheat"
3.c
match(c:Country)-[r1:has_States]->(s:States),(s:States)-[r2:Produces]->(p:Product {Name:"Sugar"})WHEREr2.Production>70return DISTINCT c.Name
Output :
c.Name
"USA"
"India"
3.d
match (c:Country) WHERE NOT (c)-[:Imports]->(:Product) return c.Name
Output :
c.Name
"Israil""Arab"
SLIP 4
Furniture Showroom
NODES
Furniture
create(f:Furniture{Name:"Sofa Set", color:"white"}) return f;
create(f:Furniture{Name:"Tea Table", color:"Black"}) return f;
create(f:Furniture{Name:"Cupboards", color:"Brown"}) return f;
create(f:Furniture{Name:"beds", color:"white"}) return f;
create(f:Furniture{Name:"Dining Table", color:"Black"}) return f;
FTypes
create(f:FTypes {Type:”Fast Moving”) return f;
create(f:FTypes {Type:"Heavy"}) return f;
create(f:FTypes {Type:"Fragile"}) return f;
create(f:FTypes {Type:"Light Weight"}) return f;
Staff
create(s:Staff{Name:"Satish"}) return s;
create(s:Staff{Name:"Suraj"}) return s;
create(s:Staff{Name:"Omkar"}) return s;
create(s:Staff{Name:"Pratik"}) return s;
Customer
create(c:Customer{Name:"Priyanshu"}) return c;
create(c:Customer{Name:"Sahil"}) return c;
create(c:Customer{Name:"Anita"}) return c;
create(c:Customer{Name:"Riya"}) return c;
RELATIONSHIPS
Handled
match(s:Staff),(f:Furniture) where s.Name="Satish" and
f.Name="Sofa Set" create (s)-[:Handled]->(f) return s,f;
match(s:Staff),(f:Furniture) where s.Name="Suraj" and
f.Name="Tea Table" create (s)-[:Handled]->(f) return s,f;
match(s:Staff),(f:Furniture) where s.Name="Omkar" and
f.Name="Cupboards" create (s)-[:Handled]->(f) return s,f;
match(s:Staff),(f:Furniture) where s.Name="Pratik" and
f.Name="beds" create (s)-[:Handled]->(f) return s,f;
Enquired_about
match(c:Customer),(f:Furniture) where c.Name="Sahil" and
f.Name="Sofa Set" create (c)-[:Enquired_about]->(f) return c,f;
match(c:Customer),(f:Furniture) where c.Name="Priyanshu" and
f.Name="Dining Table" create (c)-[:Enquired_about]->(f) return c,f;
match(c:Customer),(f:Furniture) where c.Name="Anita" and
f.Name="beds" create (c)-[:Enquired_about]->(f) return c,f;
Purchased
match(c:Customer),(f:Furniture) where c.Name="Sahil" and
f.Name="Sofa Set" create (c)-[:Purchased]->(f) return c,f;
match(c:Customer),(f:Furniture) where c.Name="Riya" and
f.Name="Tea Table" create (c)-[:Purchased]->(f) return c,f;
match(c:Customer),(f:Furniture) where c.Name="Priyanshu" and
f.Name="Dining Table" create (c)-[:Purchased]->(f) return c,f;
Have_Type
match(f:Furniture),(ft:FTypes) where f.Name="beds" and
ft.Type="Heavy" create (f)-[: Have_Type]->(ft) return f,ft;
match(f:Furniture),(ft:FTypes) where f.Name="Tea Table" and
ft.Type="Fragile" create (f)-[: Have_Type]->(ft) return f,ft;
match(f:Furniture),(ft:FTypes) where f.Name="Dining Table" and
ft.Type="Light Weight" create (f)-[: Have_Type]->(ft) return f,ft;
match(f:Furniture),(ft:FTypes) where f.Name="Dining Table" and
ft.Type="Fast Moving" create (f)-[: Have_Type]->(ft) return f,ft;
match(f:Furniture),(ft:FTypes) where f.Name="Cupboards" and
ft.Type="Fast Moving" create (f)-[: Have_Type]->(ft) return f,ft;
QUERIES
3.a
MATCH (f:Furniture) return f.Name as Furniture
Output :
Furniture
"Sofa Set"
"Tea Table"
"Cupboards"
"beds"
"Dining Table"
3.b
match(f:Furniture),(s:Staff) where s.Name="Satish" and (s)-[:Handled]->(f) return f.Name;
Output :
f.Name
"Sofa Set"
3.c
match (c:Customer) WHERE (c)-[:Enquired_about]->(:Furniture) AND NOT (c)-[:Purchased]->(:Furniture)return c.Name
Output :
c.Name
"Anita"
3.d
match (f:Furniture) WHERE (f)-[:Have_Type]->(:FTypes {Type:"Fast Moving"}) return f.Name
Output :
f.Name
"Cupboards"
"Dining Table"
SLIP 5
Clothing Brand
NODES
Section
create (s:Section {Name:"Male"}) return s;
create (s:Section {Name:"Female"}) return s;
create (s:Section {Name:"Kids"}) return s;
Brand
create (b:Brand {Name:"American Eagle"}) return b;
create (b:Brand {Name:"Gap"}) return b;
create (b:Brand {Name:"Peter England"}) return b;
create (b:Brand {Name:"Levis"}) return b;
create (b:Brand {Name:"Tommy Hilfiger"}) return b;
Apparel
create (a:Apparel {Name:"Kurta"}) return a;
create (a:Apparel {Name:"Saree"}) return a;
create (a:Apparel {Name:"T-Shirts"}) return a;
create (a:Apparel {Name:"Jackets"}) return a;
create (a:Apparel {Name:"Frock"}) return a;
create (a:Apparel {Name:"Shirt"}) return a;
create (a:Apparel {Name:"Trouser"}) return a;
Size
create (s:Size {Name:"S"}) return s;
create (s:Size {Name:"M"}) return s;
create (s:Size {Name:"L"}) return s;
create (s:Size {Name:"XL"}) return s;
create (s:Size {Name:"XXL"}) return s;
SalesStaff
create (ss:SalesStaff {Name:"Smita"}) return ss;
create (ss:SalesStaff {Name:"Geeta"}) return ss;
create (ss:SalesStaff {Name:"Seeta"}) return ss;
create (ss:SalesStaff {Name:"Raman"}) return ss;
Color
create (c:Color{Name:"Red"}) return c;
create (c:Color{Name:"Black"}) return c;
create (c:Color{Name:"Blue"}) return c;
RELATIONSHIPS
Has
match(s:Section),(a:Apparel) where s.Name="Female" and a.Name="Kurta" create (s)-[:Has]->(a) return s,a;
match(s:Section),(a:Apparel) where s.Name="Female" and a.Name="Saree" create (s)-[:Has]->(a) return s,a;
match(s:Section),(a:Apparel) where s.Name="Male" and a.Name="Jackets" create (s)-[:Has]->(a) return s,a;
match(s:Section),(a:Apparel) where s.Name="Male" and a.Name="Shirt" create (s)-[:Has]->(a) return s,a;
match(s:Section),(a:Apparel) where s.Name="Kids" and a.Name="Frock" create (s)-[:Has]->(a) return s,a;
match(s:Section),(a:Apparel) where s.Name="Male" and a.Name="Trouser" create (s)-[:Has]->(a) return s,a;
match(b:Brand),(a:Apparel) where b.Name="Levis" and a.Name="Trouser" create (b)-[:Has]->(a) return b,a;
match(b:Brand),(a:Apparel) where b.Name="Levis" and a.Name="Shirt" create (b)-[:Has]->(a) return b,a;
match(b:Brand),(a:Apparel) where b.Name="Gap" and a.Name="Frock" create (b)-[:Has]->(a) return b,a;
match(b:Brand),(a:Apparel) where b.Name="Peter England" and a.Name="Jackets" create (b)-[:Has]->(a) return b,a;
match(b:Brand),(a:Apparel) where b.Name="Peter England" and a.Name="Shirt" create (b)-[:Has]->(a) return b,a;
match(b:Brand),(a:Apparel) where b.Name="Peter England" and a.Name="Trouser" create (b)-[:Has]->(a) return b,a;
Works_in
match(ss:SalesStaff),(s:Section) where s.Name="Kids" and ss.Name="Smita" create (ss)-[:Work_in]->(s) return ss,s;
match(ss:SalesStaff),(s:Section) where s.Name="Female" and ss.Name="Geeta" create (ss)-[:Work_in]->(s) return ss,s;
match(ss:SalesStaff),(s:Section) where s.Name="Male" and ss.Name="Seeta" create (ss)-[:Work_in]->(s) return ss,s;
match(ss:SalesStaff),(s:Section) where s.Name="Kids" and ss.Name="Raman" create (ss)-[:Work_in]->(s) return ss,s;
Has_Color
match,(a:Apparel),(c:Color) where a.Name="Trouser" and c.Name="Black" create (a)-[:Has_Color]->(c) return c,a;
Available_in
match(s:Size),(a:Apparel) where a.Name="Frock" and s.Name="S" create (a)-[:Available_in]->(s) return s,a;
match(s:Size),(a:Apparel) where a.Name="Jackets" and s.Name="XXL" create (a)-[:Available_in]->(s) return s,a;
match(s:Size),(a:Apparel) where a.Name="Shirt" and s.Name="M" create (a)-[:Available_in]->(s) return s,a;
match(s:Size),(a:Apparel) where a.Name="Kurta" and s.Name="L" create (a)-[:Available_in]->(s) return s,a;
match(s:Size),(a:Apparel) where a.Name="Saree" and s.Name="XL" create (a)-[:Available_in]->(s) return s,a;
match(s:Size),(a:Apparel) where a.Name="Trouser" and s.Name="L" create (a)-[:Available_in]->(s) return s,a;
QUERIES
3.a
match(s:Section),(a:Apparel) where s.Name="Female" and (s)-[:Has]->(a) return a.Name;
Output :
a.Name
"Kurta"
"Saree"
3.b
match(ss:SalesStaff),(s:Section) where s.Name="Kids" and (ss)-[:Work_in]->(s) return ss.Name;
Output :
ss.Name
"Smita"
"Raman"
3.c
match (a:Apparel {Name:"Trouser"}),(c:Color {Name:"Black"}),(ss:Section {Name:"Male"}),(s:Size) WHERE (a)-[:Available_in]->(s) AND (a)-[:Has_Color]->(c) AND (ss)-[:Has]->(a) return s.Name,ss.Name,c.Name
Output :
s.Name ss.Name c.Name
"L" "Male" "Black"
3.d
match(p:Brand)-[:Has]->(d:Apparel)with p.Name as names, count(d.Name) as count_vt WITH collect({names:names,count_vt:count_vt}) as rows,min(count_vt) as min UNWIND [row in rows WHERE row.count_vt=min] as row RETURN row.names,row.count_vt as count_vt
Output :
row.names count_vt
"Gap" 1
SLIP 6
Hotel
NODES
Person
Create(p:Person {Name:"Seeta"}) return p
Create(p:Person {Name:"Riya"}) return p
Create(p:Person {Name:"Rohan"}) return p
Hotel
create (h:Hotel {Name:"Marriotte", location:"Camp",rating:4}) return h;
create (h:Hotel {Name:"Ritz", location:"Camp",rating:5}) return h;
create (h:Hotel {Name:"Blue Diamond", location:"KP Road",rating:3}) return h;
create (h:Hotel {Name:"Radison", location:"Kharadi",rating:5}) return h;
create (h:Hotel {Name:"Madison", location:"Koregaon Park",rating:3.5}) return h;
create (h:Hotel {Name:"Bowry", location:"Koregaon Park",rating:3.7}) return h;
Facility
create (f:Facility {Name:"Lodging"}) return f;
create (f:Facility {Name:"Restaurant"}) return f;
create (f:Facility {Name: "Lodging Restaurant"}) return f;
RELATIONSHIPS
Has
match (h:Hotel),(f:Facility) where h.Name="Blue Diamond" and f.Name="Lodging" create (h)-[:Has]->(f) return h,f;
match (h:Hotel),(f:Facility) where h.Name="Radison" and f.Name="Restaurant" create (h)-[:Has]->(f) return h,f;
match (h:Hotel),(f:Facility) where h.Name="Ritz" and f.Name="Lodging Restaurant" create (h)-[:Has]->(f) return h,f;
match (h:Hotel),(f:Facility) where h.Name="Marriotte" and f.Name="Lodging Restaurant" create (h)-[:Has]->(f) return h,f;
Recommends
match (p:Person),(h:Hotel) where h.Name="Bowry" and p.Name="Seeta" create (p)-[:Recommends]->(h) return p,h
match (p:Person),(h:Hotel) where h.Name="Madison" and p.Name="Seeta" create (p)-[:Recommends]->(h) return p,h
match (p:Person),(h:Hotel) where h.Name="Madison" and p.Name="Riya" create (p)-[:Recommends]->(h) return p,h
match (p:Person),(h:Hotel) where h.Name="Madison" and p.Name="Rohan" create (p)-[:Recommends]->(h) return p,h
QUERIES
3.a
match (h:Hotel) where h.location="Camp" return h.Name;
Output :
h.Name
"Marriotte"
"Ritz"
3.b
match (h:Hotel),(f:Facility) where f.Name="Lodging Restaurant" and (h)-[:Has]->(f) return h.Name;
Output :
h.Name
"Marriotte"
"Ritz"
3.c
match (h:Hotel) where h.rating>=4 return h.Name
Output :
h.Name
"Marriotte"
"Ritz"
"Radison"
3.d
match(p:Person)-[:Recommends]->(h:Hotel {location:"Koregaon Park"}) with h.Name as names, count(h.Name) as count_vt WITH collect({names:names,count_vt:count_vt}) as rows,max(count_vt) as max UNWIND [row in rows WHERE row.count_vt=max] as row RETURN row.names,row.count_vt as count_vt
Output :
row.names count_vt
"Madison" 3
SLIP 7
Hospital
NODES
Hospital
create (h:Hospital {Name:"Columbia Hospital"}) return h;
create (h:Hospital {Name:"Bytco Hospital"}) return h;
create (h:Hospital {Name:"Sahyadri Hospital"}) return h;
create (h:Hospital {Name:"Jehangir Hospital"}) return h;
Specialization
create(s:Specialization{Name:"Pediatric"}) return s;
create(s:Specialization{Name:"Orthopedic"}) return s;
create(s:Specialization{Name:"Gynaec"}) return s;
Person
create (p:Person {Name:"Vishal"}) return p;
create (p:Person {Name:"Radhika"}) return p;
create (p:Person {Name:"Diya"}) return p;
Doctor
create (d:Doctor {Name:"Dr.Aarohi"}) return d;
create (d:Doctor {Name:"Dr.Rohit"}) return d;
create (d:Doctor {Name:"Dr.Vikas"}) return d;
RELATIONSHIPS
Visits
match (d:Doctor),(h:Hospital) where d.Name="Dr.Vikas" and h.Name="Jehangir Hospital" create (d)-[:Visits {Day:"Monday"}]->(h) return d,h;
match (d:Doctor),(h:Hospital) where d.Name="Dr.Aarohi" and h.Name="Jehangir Hospital" create (d)-[:Visits {Day: "Monday"}]->(h) return d,h;
match (d:Doctor),(h:Hospital) where d.Name="Dr.Vikas" and h.Name="Bytco Hospital" create (d)-[:Visits {Day: "Tuesday"}]->(h) return d,h;
match (d:Doctor),(h:Hospital) where d.Name="Dr.Rohit" and h.Name="Columbia Hospital" create (d)-[:Visits {Day: "Wednesday"}]->(h) return d,h;
Rates
match (p:Person),(h:Hospital) where p.Name="Vishal" and h.Name="Jehangir Hospital" create (p)-[:Rates {Rating:4.5}]->(h) return p,h;
match (p:Person),(h:Hospital) where p.Name="Diya" and h.Name="Jehangir Hospital" create (p)-[:Rates {Rating:3}]->(h) return p,h;
match (p:Person),(h:Hospital) where p.Name="Radhika" and h.Name="Jehangir Hospital" create (p)-[:Rates {Rating:2}]->(h) return p,h;
match (p:Person),(h:Hospital) where p.Name="Diya" and h.Name="Columbia Hospital" create (p)-[:Rates {Rating:5}]->(h) return p,h;
match (p:Person),(h:Hospital) where p.Name="Vishal" and h.Name="Bytco Hospital" create (p)-[:Rates {Rating:4.2}]->(h) return p,h;
Specialized_in
match(h:Hospital),(s:Specialization) where h.Name="Columbia Hospital" and s.Name="Gynaec" create (h)-[:Specialized_in]->(s) return h,s;
match(h:Hospital),(s:Specialization) where h.Name="Sahyadri Hospital" and s.Name="Orthopedic" create (h)-[:Specialized_in]->(s) return h,s;
match(h:Hospital),(s:Specialization) where h.Name="Bytco Hospital" and s.Name="Pediatric" create (h)-[:Specialized_in]->(s) return h,s;
match(h:Hospital),(s:Specialization) where h.Name="Jehangir Hospital" and s.Name="Gynaec" create (h)-[:Specialized_in]->(s) return h,s;
Recommends
match(p:Person),(h:Hospital) where p.Name="Diya" and h.Name="Jehangir Hospital" create (p)-[:Recommends]->(h) return p,h;
match(p:Person),(h:Hospital) where p.Name="Vishal" and h.Name="Jehangir Hospital" create (p)-[:Recommends]->(h) return p,h;
match(p:Person),(h:Hospital) where p.Name="Radhika" and h.Name="Columbia Hospital" create (p)-[:Recommends]->(h) return p,h;
match(p:Person),(h:Hospital) where p.Name="Radhika" and h.Name="Bytco Hospital" create (p)-[:Recommends]->(h) return p,h;
Associated_with
match (d:Doctor),(h:Hospital) where d.Name="Dr.Rohit" and h.Name="Columbia Hospital" create (d)-[:Associated_with]->(h) return d,h;
match (d:Doctor),(h:Hospital) where d.Name="Dr.Rohit" and h.Name="Bytco Hospital" create (d)-[:Associated_with]->(h) return d,h;
match (d:Doctor),(h:Hospital) where d.Name="Dr.Aarohi" and h.Name="Columbia Hospital" create (d)-[:Associated_with]->(h) return d,h;
match (d:Doctor),(h:Hospital) where d.Name="Dr.Aarohi" and h.Name="Jehangir Hospital" create (d)-[:Associated_with]->(h) return d,h;
match (d:Doctor),(h:Hospital) where d.Name="Dr.Vikas" and h.Name="Jehangir Hospital" create (d)-[:Associated_with]->(h) return d,h;
QUERIES
3.a
match (h:Hospital),(r:Specialization) where r.Name="Pediatric" and (h)-[:Specialized_in]->(r) return h.Name
Output :
h.Name
"Bytco Hospital"
3.b
match (d:Doctor)-[:Visits {Day:"Monday"}]->(h:Hospital {Name:"Jehangir Hospital"}) return d.Name
Output :
d.Name
"Dr.Aarohi"
"Dr.Vikas"
3.c
match(p:Person)-[:Recommends]->(h:Hospital)-[s:Specialized_in]->(ss:Specialization {Name:"Gynaec"}) with h.Name as names, count(h.Name) as count_vt WITH collect({names:names,count_vt:count_vt}) as rows,max(count_vt) as max UNWIND [row in rows WHERE row.count_vt=max] as row RETURN row.names,row.count_vt as count_vt
Output :
row.names count_vt
"Jehangir Hospital" 2
3.d
match (p:Person)-[r:Rates]-(h:Hospital {Name:"Jehangir Hospital"}) where r.Rating>=3 return p.Name
Output :
p.Name
"Diya"
"Vishal"
SLIP 8
Doctor
NODES
Streams
create (s:Streams {Name:"Pediatric"}) return s;
create (s:Streams {Name:"Heart Specialist"}) return s;
create (s:Streams {Name:"Gynaec"}) return s;
create (s:Streams {Name:"Neurosurgery"}) return s;
Doctor
create (d:Doctor {Name:"Dr.Aarohi",Type:"PersonalClinic",Area:"Kothrud"}) return d;
create (d:Doctor {Name:"Dr.Rohit",Type:"VisitingDoctor",Area:"Kothrud"}) return d;
create (d:Doctor {Name:"Dr.Kulkarni",Type:"PersonalClinic",Area:"Camp"}) return d;
create (d:Doctor {Name:"Dr.Krishna",Type:"VisitingDoctor",Area:"Dehu"}) return d;
Person
create (p:Person {Name:"Vishal"}) return p;
create (p:Person {Name:"Swaraj"}) return p;
create (p:Person {Name:"Rama"}) return p;
RELATIONSHIPS
Recommends
match(p:Person),(d:Doctor) where p.Name="Vishal" and d.Name="Dr.Rohit" create(p)-[r:Recommends]->(d) return p,d
match(p:Person),(d:Doctor) where p.Name="Vishal" and d.Name="Dr.Kulkarni" create(p)-[r:Recommends]->(d) return p,d
match(p:Person),(d:Doctor) where p.Name="Rama" and d.Name="Dr.Rohit" create(p)-[r:Recommends]->(d) return p,d
match(p:Person),(d:Doctor) where p.Name="Swaraj" and d.Name="Dr.Rohit" create(p)-[r:Recommends]->(d) return p,d
match(p:Person),(d:Doctor) where p.Name="Swaraj" and d.Name="Dr.Aarohi" create(p)-[r:Recommends]->(d) return p,d
match(p:Person),(d:Doctor) where p.Name="Rama" and d.Name="Dr.Aarohi" create(p)-[r:Recommends]->(d) return p,d
Reviews
match(p:Person),(d:Doctor) where p.Name="Swaraj" and d.Name="Dr.Aarohi" create(p)-[r:Reviews {Review:"Very Attentive!"}]->(d) return p,d
match(p:Person),(d:Doctor) where p.Name="Rama" and d.Name="Dr.Kulkarni" create(p)-[r:Reviews {Review: "Very Attentive!"}]->(d) return p,d
match(p:Person),(d:Doctor) where p.Name="Vishal" and d.Name="Dr.Kulkarni" create(p)-[r:Reviews {Review: "Understanding and with great knowledge!"}]->(d) return p,d
Is_Of
match(d:Doctor),(s:Streams) where d.Name="Dr.Aarohi" and s.Name="Gynaec" create (d)-[:Is_Of]->(s) return d,s;
match(d:Doctor),(s:Streams) where d.Name="Dr.Kulkarni" and s.Name="Pediatric" create (d)-[:Is_Of]->(s) return d,s;
match(d:Doctor),(s:Streams) where d.Name="Dr.Rohit" and s.Name="Gynaec" create (d)-[:Is_Of]->(s) return d,s;
match(d:Doctor),(s:Streams) where d.Name="Dr.Krishna" and s.Name="Neurosurgery" create (d)-[:Is_Of]->(s) return d,s;
QUERIES
3.a
match(d:Doctor)-[:Is_Of]->(s:Streams {Name:"Pediatric"}) WHERE d.Area="Camp" return d.Name
Output :
d.Name
"Dr.Kulkarni"
3.b
match(d:Doctor) where d.Type="Personal Clinic" return d.Name
Output :
d.Name
"Dr.Aarohi"
"Dr.Kulkarni"
3.c
match(p:Person)-[:Recommends]->(d:Doctor {Area:"Kothrud"})-[s:Is_Of]->(ss:Streams {Name:"Gynaec"}) with d.Name as names, count(d.Name) as count_vt WITH collect({names:names,count_vt:count_vt}) as rows,max(count_vt) as max UNWIND [row in rows WHERE row.count_vt=max] as row RETURN row.names,row.count_vt as count_vt
Output :
row.names count_vt
"Dr.Rohit" 3
3.d
match(p:Person)-[r:Reviews]->(d:Doctor {Name:"Dr.Kulkarni"}) return r.Review
Output :
r.Review
"Understanding and with great knowledge!"
"Very Attentive!"
SLIP 9
Automobile
NODES
Industry
create(i:Industry{Name:"KTM"})return i;
VehicleType
create(v:VehicleType{Name:"Heavy"})return v;
create(v:VehicleType{Name:"Light"})return v;
VehicleChar
create(vv:VehicleChar{Name:"Duke",color:"Orange",wheels:"two wheeler"})return vv;
create(vv:VehicleChar{Name:"RC",color:"White",wheels:"two wheeler"})return vv;
Customer
create(c:Customer {Name:"Shivani"}) return c;
create(c:Customer {Name:"Pooja"}) return c;
create(c:Customer {Name:"Ajay"}) return c;
RELATIONSHIPS
Has
match(i:Industry),(v:VehicleType) where i.Name="KTM" and v.Name="Heavy" create(i)-[:Has]->(v) return i,v;
match(i:Industry),(v:VehicleType) where i.Name="KTM" and v.Name="Light" create(i)-[:Has]->(v) return i,v;
has_char
match(v:VehicleType),(vv:VehicleChar) where v.Name="Heavy" and vv.Name="Duke" create (v)-[:has_char]->(vv) return vv,v;
match(v:VehicleType),(vv:VehicleChar) where v.Name="Light" and vv.Name="RC" create (v)-[:has_char]->(vv) return vv,v;
Bought
match(c:Customer),(v:VehicleType) where c.Name="Shivani" and v.Name="Light" create (c)-[:Bought]->(v) return c,v;
match(c:Customer),(v:VehicleType) where c.Name="Shivani" and v.Name="Heavy" create (c)-[:Bought]->(v) return c,v;
match(c:Customer),(v:VehicleType) where c.Name="Pooja" and v.Name="Light" create (c)-[:Bought]->(v) return c,v;
Recommends
match(c:Customer),(v:VehicleType) where c.Name="Pooja" and v.Name="Light" create (c)-[: Recommends]->(v) return c,v;
match(c:Customer),(v:VehicleType) where c.Name="Shivani" and v.Name="Light" create (c)-[: Recommends]->(v) return c,v;
match(c:Customer),(v:VehicleType) where c.Name="Ajay" and v.Name="Light" create (c)-[: Recommends]->(v) return c,v;
match(c:Customer),(v:VehicleType) where c.Name="Ajay" and v.Name="Heavy" create (c)-[: Recommends]->(v) return c,v;
QUERIES
3.a
match(v:VehicleType),(vv:VehicleChar) where v.Name="Heavy" and (v)-[:has_char]->(vv) return vv.Name,vv.color,vv.wheels;
Output :
vv.Name vv.color vv.wheels
"Duke" "Orange" "two wheeler"
3.b
match(c:Customer),(v:VehicleType) where v.Name="Light " and (c)-[:Bought]->(v) return c.Name;
Output :
c.Name
"Shivani"
"Pooja"
3.c
match(p:Customer)-[b:Bought]->(v:VehicleType) with p, count(b) as cnt where cnt>1 return p.Name
Output :
p.Name
"Shivani"
3.d
match(p:Customer)-[:Recommends]->(d:VehicleType) with d.Name as names, count(d.Name) as count_vt WITH collect({names:names,count_vt:count_vt}) as rows,max(count_vt) as max UNWIND [row in rows WHERE row.count_vt=max] as row RETURN row.names,row.count_vt as count_vt
Output :
row.names count_vt
"Light " 3
SLIP 10
University
NODES
University
create(u:University{Name:"Pune University"}) return u;
Department
create(d:Department{Name:"Chemistry"}) return d;
create(d:Department{Name:"Zoology"}) return d;
create(d:Department{Name:"Computer Science"}) return d;
Course
create(c:Course{Name:"BSc"}) return c;
create(c:Course{Name:"MSc"}) return c;
create(c:Course{Name:"Diploma"}) return c;
Person
create(c:Person{Name:"Seema"}) return c;
create(c:Person{Name:"Prashant"}) return c;
create(c:Person{Name:"Mansi"}) return c;
RELATIONSHIPS
has
match (u:University),(d:Department) where d.Name="Chemistry" and u.Name="Pune University" create (u)-[:has]->(d) return u,d;
match (u:University),(d:Department) where d.Name="Zoology" and u.Name="Pune University" create (u)-[:has]->(d) return u,d;
match (u:University),(d:Department) where d.Name="Computer Science" and u.Name="Pune University" create (u)-[:has]->(d) return u,d;
conducts
match (c:Course),(d:Department) where c.Name="MSc" and d.Name="Chemistry" create (d)-[:conducts]->(c) return d,c;
match (c:Course),(d:Department) where c.Name="BSc" and d.Name="Chemistry" create (d)-[:conducts]->(c) return d,c;
match (c:Course),(d:Department) where c.Name="Diploma" and d.Name="Zoology"
create (d)-[:conducts]->(c) return d,c;
match (c:Course),(d:Department) where c.Name="Diploma" and d.Name="Chemistry"
create (d)-[:conducts]->(c) return d,c;
match (c:Course),(d:Department) where c.Name="BSc" and d.Name="Computer Science"
create (d)-[:conducts]->(c) return d,c;
match (c:Course),(d:Department) where c.Name="MSc" and d.Name="Computer Science"
create (d)-[:conducts]->(c) return d,c;
Recommends
match (c:Course),(p:Person) where c.Name="MSc" and p.Name="Mansi"
create (p)-[:Recommends]->(c) return p,c;
match (c:Course),(p:Person) where c.Name="BSc" and p.Name="Mansi"
create (p)-[:Recommends]->(c) return p,c;
match (c:Course),(p:Person) where c.Name="MSc" and p.Name="Seema"
create (p)-[:Recommends]->(c) return p,c;
match (c:Course),(p:Person) where c.Name="MSc" and p.Name="Prashant"
create (p)-[:Recommends]->(c) return p,c;
QUERIES
3.a
match (c:Course),(d:Department) where d.Name="Chemistry" and (d)-[:conducts]->(c) return c.Name;
Output :
c.Name
"BSc"
"MSc"
"Diploma"
3.b
match (u:University),(d:Department) where u.Name="Pune University" create (u)-[:has]->(d) return d.Name;
Output :
d.Name
"Chemistry"
"Zoology"
"Computer Science"
3.c
match (d1:Department {Name:"Chemistry"})-[:conducts]->(c:Course),(d2:Department {Name:"Zoology"})-[:conducts]->(c) RETURN c.Name
Output :
c.Name
"Diploma"
3.d
match(p:Person)-[:Recommends]->(d:Course)<-[s:conducts]->(ss:Department {Name:"Computer Science"}) with d.Name as names, count(d.Name) as count_vt WITH collect({names:names,count_vt:count_vt}) as rows,max(count_vt) as max UNWIND [row in rows WHERE row.count_vt=max] as row RETURN row.names,row.count_vt as count_vt
Output :
row.names count_vt
"MSc" 3