Created
March 17, 2017 01:11
-
-
Save jonaspm/43056b34413f882fa052e03b1de2bc97 to your computer and use it in GitHub Desktop.
TAREA 1 MONGODB para la clase DRAW
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* TAREA DE MONGODB | |
1) Baja el archivo grades.json y en la terminal ejecuta el siguiente comando... | |
COMANDO(S): | |
mongoimport /d students /c grades C:\Users\jonaspm\Downloads\grades.json | |
RESPUESTA: | |
2017-03-16T17:16:12.150-0700 connected to: localhost | |
2017-03-16T17:16:12.339-0700 imported 800 documents | |
2) ¿Cuantos registros arrojo el comando count? | |
COMANDO(S): | |
use students; | |
db.grades.count(); | |
RESPUESTA: | |
800 | |
3) Encuentra todas las calificaciones del estudiante con el id numero 4 | |
COMANDO(S): | |
db.getCollection("grades").find({student_id: 4}); | |
RESPUESTA: | |
{ "_id" : ObjectId("50906d7fa3c412bb040eb587"), "student_id" : 4, "type" : "exam", "score" : 87.89071881934647 } | |
{ "_id" : ObjectId("50906d7fa3c412bb040eb588"), "student_id" : 4, "type" : "quiz", "score" : 27.29006335059361 } | |
{ "_id" : ObjectId("50906d7fa3c412bb040eb589"), "student_id" : 4, "type" : "homework", "score" : 5.244452510818443 } | |
{ "_id" : ObjectId("50906d7fa3c412bb040eb58a"), "student_id" : 4, "type" : "homework", "score" : 28.656451042441 } | |
4) ¿Cuantos registros hay de tipo exam? | |
COMANDO(S): | |
db.getCollection("grades").find({type:'exam'}).count(); | |
RESPUESTA: | |
200 | |
5) ¿Cuantos registros hay de tipo homework? | |
COMANDO(S): | |
db.getCollection("grades").find({type:'homework'}).count(); | |
RESPUESTA: | |
400 | |
6) ¿Cuantos registros hay de tipo quiz? | |
COMANDO(S): | |
db.getCollection("grades").find({type:'quiz'}).count(); | |
RESPUESTA: | |
200 | |
7) Elimina todas las calificaciones del estudiante con el id numero 3 | |
COMANDO(S): | |
db.grades.remove({student_id: 999999}); | |
RESPUESTA: | |
WriteResult({ "nRemoved" : 4 }) | |
8) ¿Que estudiantes obtuvieron 75.29561445722392 en una tarea? | |
COMANDO(S): | |
db.getCollection("grades").aggregate({$match:{score: 75.29561445722392}}, {$group: {_id: '$student_id'}}) | |
RESPUESTA: | |
{"_id" : 9} | |
9) Actualiza las calificaciones del registro con el uuid 50906d7fa3c412bb040eb591 por 100 | |
COMANDO(S): | |
db.grades.update({_id: ObjectId("50906d7fa3c412bb040eb591")}, {$set: {"score": 100 }}); | |
RESPUESTA: | |
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) | |
10) A que estudiante pertenece esta calificación. | |
COMANDO(S): | |
db.grades.find({score: 100}, {student_id: 1}); | |
RESPUESTA: | |
{ "_id" : ObjectId("50906d7fa3c412bb040eb591"), "student_id" : 6 } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment