Import Queries
Post.csv
LOAD CSV WITH HEADERS FROM “file:///E:/post.csv” AS line
create (:post {id: toInteger(line.id),posttypeid: toInteger(line.PostTypeId),acceptedanswerid: toInteger(line.AcceptedAnswerId),creationdate: line.CreationDate,score: line.Score,viewcount: line.ViewCount,owneruserid: line.OwnerUserId,title: line.Title,tags: line.Tags,answercount: line.AnswerCount,commentcount: line.CommentCount,favouritecount: line.FavoriteCount,parentid: line.ParentId,closeddate: line.ClosedDate, ownerdisplayname: line.OwnerDisplayName})
Tags.csv
LOAD CSV WITH HEADERS FROM “file:///E:/tags.csv” AS line
create (:tags {id: toInteger(line.Id),tagname: (line.TagName),count: (line.Count),excerptpostid: (line.ExcerptPostId), wikipostid: (line.WikiPostId)})
User.csv
LOAD CSV WITH HEADERS FROM “file:///E:/user.csv” AS line
create (:user {id: line.Id,reputation: line.Reputation,creationdate: line.CreationDate,displayname: line.DisplayName,lastaccessdate: line.LastAccessDate,location: line.Location,views: line.Views,upvotes :line.UpVotes,downvotes :line.DownVotes,accountid :line.AccountId})
Votes.csv
LOAD CSV WITH HEADERS FROM “file:///E:/votes.csv” AS line
create (:votes {id: toInteger(line.Id),postid: toInteger(line.PostId),votetypeid: toInteger(line.VoteTypeId),creationdate: line.CreationDate,userid: toInteger(line.UserId),bountyamount: line.BountyAmount})
SQ1
match (u:user)-[r:PostedBy]-(p:post) return p.owneruserid , u.displayname , u.upvotes , u.downvotes
SQ2
match (p:post) return max(p.viewcount)
AQ4
match (p:post) where p.tags = ‘machine-learning’ OR p.tags = ‘reinforcement-learning’ OR p.tags = ‘ai-design’and p.acceptedanswerid >=4 and p.owneruserid = 4398 return p.title , p.creationdate
AQ5
match(u:user)-[r:PostedBy]->(p:post) where p.acceptedanswerid < u.upvotes return p.id as question, p.acceptedanswerid as acceptedanswer, u.upvotes as upvotes
AQ6
match (p:post{posttypeid: 1}) return p.owneruserid , count(p.owneruserid) as numberofquestions
Relations Ship Code:
PostType With Post
create (:postedtype{id:1 , posttype:'Question'})
create (:postedtype{id:2 , posttype:'Answer'})
Match(p:post),(pt:postedtype) where p.posttypeid = 1 and pt.id = 1 create (p)-[r: PostType]->(pt) return p , pt
Match(p:post),(pt:postedtype) where p.posttypeid = 2 and pt.id = 2 create (p)-[r: PostType]->(pt) return p , pt
Vote ,VoteTypeRelationShip , Post relation ship
Code
create (:votetype{id:1, type:’AcceptedByOriginator’})
create (:votetype{id:2, type:’ UpMod’})
create (:votetype{id:2, type:’DownMod’})
create (:votetype{id:2, type:’ Offensive’})
create (:votetype{id:2, type:’Favorite’})
create (:votetype{id:2, type:’ Close’})
create (:votetype{id:2, type:’ Reopen’})
create (:votetype{id:2, type:’ BountyStart’})
create (:votetype{id:2, type:’ BountyClose’})
create (:votetype{id:2, type:’ Deletion’})
create (:votetype{id:2, type:’Un Deletion’})
create (:votetype{id:2, type:’ Spam’})
create (:votetype{id:2, type:’ InformModerator’})
Relation With Post
match(p:post),(v:vote) where p.id = 5 and v.postid = 5 create (p)-[r: Post]->(v) return p , v
match(p:post),(v:vote) where p.id = 3 and v.postid = 3 create (p)-[r: Post]->(v) return p , v
match(p:post),(v:vote) where p.id = 2 and v.postid = 2 create (p)-[r: Post]->(v) return p , v
match(p:post),(v:vote) where p.id = 1 and v.postid = 1 create (p)-[r: Post]->(v) return p , v
Relation with VoteType:
match(v:vote),(vt:votetype) where v.votetypeid = 1 and v.id = 1 create (v)-[r: VoteType]->(vt) return v , vt
match(v:vote),(vt:votetype) where v.votetypeid = 3 and v.id = 3 create (v)-[r: VoteType]->(vt) return v , vt
match(v:vote),(vt:votetype) where v.votetypeid = 5 and v.id = 5 create (v)-[r: VoteType]->(vt) return v , vt
Relation Ship Between User and Post
match(p:post),(u:user) where u.id = 8 and p.owneruserid = 8 create (p)-[r: PostedBy]->(u) return p, u
match(p:post),(u:user) where u.id = 5 and p.owneruserid = 5 create (p)-[r: PostedBy]->(u) return p, u
match(p:post),(u:user) where u.id = 3 and p.owneruserid = 3 create (p)-[r: PostedBy]->(u) return p, u