程序代写代做代考 database flex Hive Part 1:

Part 1:

Introduction of project:
The project is about posting questions and answers. A user can post any questions about the given topics or give the appropriate answers to the questions. The post consists of many tags like which question belongs to which tags. Post also consist of creation date that in which date the post is created by the user it may be questions or the answer of the appropriate question. It also maintains the number of answers given by the user for the particular topic it also maintains the Favorite count of that question that how much of the user’s like that question which is posted and also maintains the comments section that how many comments occur in the particular post.
This project maintains the details description of the users that in which date the user is created, Location of the user, Total views of the user, also maintains the reputation of the user. It also consists of the up votes and down votes of the user which he receives from the different users based on the questions and answers.
This project also maintains the votes section. It assigns the vote types to the particular post it may be consists of (Accepted by Originator, Up Mod, Down Mod, Offensive, Favorite, Close, Reopen, Bounty Start etc.).
This project also maintains the tags section in which It provides the detailed description of the tag and track the tags that how many times this tag appears in the post.

Part Two and Three:
Mongo DB query workload: {SQ1, SQ2, AQ1, AQ2, AQ3}
SQ1:

db.user.aggregate([
{
$lookup:{
from:”post”,
localField:”id”,
foreignField:”OwnerUserId”,
as:”user”
}
},
{
$match:{
“user.PostTypeId”: 1
}
},
{
$project:{

“DisplayName”:”$DisplayName”,
“CreationDate”:”$CreationDate”,
“UpVotes”:”$UpVotes”,
“DownVotes”:”$DownVotes”,

}

}
])

SQ2

db.post.aggregate([

{
$sort:{

“ViewCount”:-1
}
},
{
“$limit”:1
},
{
$project:{
“Tag”:”$Tags”,
“MaxView”:”$ViewCount”

}
}
])

AQ1

db.post.aggregate([
{
$lookup:{

from:”post”,
localField:”Id”,
foreignField:”ParentId”,
as : “answers”
}
},

{
$match:{
“PostTypeId”:1
}
},
{
$match:{
“answers.PostTypeId”:2
}

},
{
$project:{
“Id”:”$Id”,
“Title”:”$Title”,
“QuestionCreationDate”:”$CreationDate”,
“MinAnswerTime”:{“$cmp”: [“$CreationDate” , “$answers.CreationDate” ]}

}
}
])

AQ2:

db.post.aggregate([
{
$match:{

“PostTypeId”:1
}
},
{
$group:{

_id:”$Tags”,
count:{$sum:1},
}

},
{
$sort:{

“count”:-1

}
},
{
“$limit”:5
}

])

AQ3:

AQ3

db.post.aggregate([
{
$lookup:{

from:”post”,
localField:”Id”,
foreignField:”ParentId”,
as : “answers”
}
},
{
$match:{

“PostTypeId”:1

}
},
{
$project:{

“Id”:”$Id”,
“Title”:”$Title”

}

}
])

Schema of Post:

Schema Of User:

Schema of Tags:

Schema of Votes:

Query Design And Execution:
Before Using Indexes

As you see this take 0.114s to retrieve the data of post.
So we use the indexes for fast retrieval of the data.
Code of applying indexes:
db.post.ensureIndex({“PostTypeId”:1})
db.post.ensureIndex({“AcceptedAnswerId”:1})
db.post.ensureIndex({“CreationDate”:1})
db.post.ensureIndex({“ViewCount”:1})
db.post.ensureIndex({“OwnerUserId”:1})
db.post.ensureIndex({“Title”:1})
db.post.ensureIndex({“Tags”:1})
Applying indexes on the columns of post

After Applying the indexes

After applying the indexes it take the time of 0.098 to retrieve the records of post.
Part 4:
Comparison of Mongo DB and Neo4J
-Chart database like Neo4J consent ACID structure with finish fine-grained atomicity of the exchanges

– Mongo DB gives adaptability, high versatility in a dispersed domain. Along these lines it requires possible consistency of the database than moment ACID consistence

– Neo4J empowers route through the diagrams as a tree, where MongoDB can’t give perception of the report stores as charts.

– MongoDB has aggregate framework, and Neo4J does not have aggregate framework

– MongoDB provides flexibility, high scalability in a distributed environment. Therefore it requires eventual consistency of the database than instant ACID compliance

– MongoDB does not make connections between the database models, as every datum set put away in the archive store of the database is disaggregated and autonomous. A diagram framework requires taking care of the mind boggling relationship of the database, while NoSQL database does not require taking care of the intricate relationship between the information models

Part 5:
SQ1:

Parameter:
{
$match:{
“user.PostTypeId”: 1
}
}$lookup command use for get the data between two documents.
Also use the joining to get data between user and post.

SQ2:

$sort is used to get the max view count and $limit is used to get the first row with max viewcount.

AQ1:

The parameters which is used in this query are:
{
$match:{
“PostTypeId”:1
}
},
{
$match:{
“answers.PostTypeId”:2
}

}

Parameters
{
$match:{
“PostTypeId”:1
} }
AQ3:

Parameter
{
$match:{

“PostTypeId”:1

}
}