covert to MongoDB NoSQL a. In 1990, in what games and what Seattle players had interceptions in...

Free

80.2K

Verified Solution

Question

Programming

covert to MongoDB NoSQL

a. In 1990, in what games and what Seattle players hadinterceptions in a game?

Select games.game_number, profiles.name from games, profileswhere games.defense_interceptions <>0 and games.team=”SEA”and games.year=”1990” and games.player_id = profiles.player_id;

b. For each year played, list a count of games in which JohnDavid Crow played.

select year, count(*) from profiles natural join games wherename=”John David Crow” group by year;

Answer & Explanation Solved by verified expert
3.6 Ratings (428 Votes)

a.

db.games,profiles .find({

   \"$and\": [{
       \"games.defense_interceptions <\":{ \"$gt\" : 0 }
   },{
   \"$and\": [{
       \"$where\": \"this. games.team == this.”SEA” \"
   },{
   \"$and\": [{
       \" games.year\" : ”1990”
   },{   \"$where\": \"this. games.player_id == this. profiles.player_id\"
   }]
   }]
   }]
},{
   \"games.game_number\": 1,
   \"profiles.name\": 1
}
);

b.

db.profilesnatural join games .group({

\"key\":{
\"year\": true
},
\"initial\": {
\"countstar\":0
},
\"reduce\": function( obj , prev ){

if (true != null ) if ( true instanceof Array)prev.countstar += true.length;
else prev.countstar++;

},
\"finalize\": function( prev ){

},
\"cond\": {
   \"$where\": \"this.name == this.”John David Crow” \"
}

});


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students