Question

What would be the Mongodb equivalent of the 2 following SQL queries? SELECT A.Lname FROM Assistant...

What would be the Mongodb equivalent of the 2 following SQL queries?

SELECT A.Lname FROM Assistant A INNER JOIN Manager Ma ON A.RefNum = Ma.RefNum

GROUP BY A.Lname HAVING COUNT(DISTINCT Ma.Manager) > 1;

SELECT G.Cname, R.Snum FROM Game G

INNER JOIN Role R ON G.Cnum = R.Cnum

WHERE G.level>200;

Homework Answers

Answer #1

Dear Student,

Here are the MongoDB equivalents of the 2 SQL statements,

db..group({

   "key":{
         "A.Lname ": true
   },
   "initial": {

   },
   "reduce": function( obj , prev ){


   },
   "finalize": function( prev ){

   },
   "cond": {
        "$where": "this.CT A.Lname FROM Assistant A INNER JOIN Manager Ma ON A.RefNum  == this. Ma.RefNum  "
   }

});
db.GameG INNER JOIN Role R ON G.Cnum = R.Cnum .find({
        "G.level":{ "$gt" : 200 }
},{
        "G.Cname": 1,
        "R.Snum": 1
}
);
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Translating MongoDB Queries to SQL - WILL UPVOTE!! 1. Write the equivalent sql queries for all...
Translating MongoDB Queries to SQL - WILL UPVOTE!! 1. Write the equivalent sql queries for all mongoDB queries. The following is an example of what you are asked to do. Assume the collection name is the table name in an sql database. Example: MongoDB Query: db.zips.aggregate([ {$match: {state: "MO"}}, {$group: {_id: "$city", totalPop: {$sum: "$pop"}}}, {$sort: {totalPop: -1}}, {$limit: 10} ]) SQL Result: Select city, SUM(pop) AS "totalPop" From zips Where state = "MO" Group By city Order By SUM(pop)...
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table....
Lab 5 Queries with Multiple Tables In this lab, we do queries more than one table. SQL provides two different techniques for querying data from multiple tables: • The SQL subquery • The SQL join As you will learn, although both work with multiple tables, they are used for slightly different purposes. We used WMCRM database which is what we created in Lab 4. Here is the summary of the database schema (where schema is used in its meaning of...
If you need to store the following data in a relational database and MongoDB, how would...
If you need to store the following data in a relational database and MongoDB, how would you implement in each of them. List the design and commands to store these records in relational database (SQL query) and MongoDB separately. {no:1,name:"ST",salary:2000,role:"OB"} {no:2,name:"MSD",salary:1500,role:"WK"} {no:3,name:"YS",salary:1000,role:"ALR"},
Assignment 2 Instructions You need to access to the database and write SQL queries on the...
Assignment 2 Instructions You need to access to the database and write SQL queries on the following site: https://www.w3schools.com/sql/trysql.asp?filename=trysql_op_in 1. Use INNER JOIN to create a report. In this report, list each customer’s CustomerID, CustomerName, and their each OrderID and each order’s OrderDate, if the customer has ever placed an order. You should use the Customers table and the Orders table in the database to complete this query.   2. Use INNER JOIN to create a report. In this report, list...
Run the following queries from an SQL database containing the following normalized entities: STORE(SID(pk), SName, SCity,...
Run the following queries from an SQL database containing the following normalized entities: STORE(SID(pk), SName, SCity, SState, SSqFeet) ITEM(ISerialNum(pk), IName, IType, IPrice) SELLS(SID, ISerialNum) (concatenated pk and both fk) 1. Show all the items with name, type, and price and the store that sold them, order by most expensive item first. 2. Show all stores that sold a specific type of an item. For example: show all stores that sold cooking items. 3. Show all stores that have a square...
Write the following questions as queries in SQL. Use only the operators discussed in class (in...
Write the following questions as queries in SQL. Use only the operators discussed in class (in particular, no outer joins or windows). Type your answers. Before starting, make sure you understand the schema of the database. If you are in doubt about it, please ask the instructor. Assume a database with schema ACTOR(name,age,address,nationality) MOVIE(title,year,genre,budget,director-name,studio) APPEARS(name,title,salary) 1. Find the title, director and studio of the most expensive movie of 2010 (note: there can be ties!). 2. Find the title, director and...
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the...
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the below Relational Database. • Regarding the SQL queries: • Do not use SELECT * in any query. • Do not use any SQL features (including Nullif) that were not covered in this course. • Do not use subqueries IF joins can be used to answer a question. However, some questions may require the use of subqueries. The Movie Database Notes: TheaterNum, MovieNum, and ActorNum...
Customers ID Name Street City Zip email 1 Emily 101 Anza St San Francisco 94118 2...
Customers ID Name Street City Zip email 1 Emily 101 Anza St San Francisco 94118 2 Amy 1 Houston Ave New York 12111 3 John 29 Sunset Blvd Los Angeles 45643 4 Pam 800 Market St San Francisco 94080 5 Sue 400 Muir Ave Redwood City 94598 6 Chris 987 A Ave New York 13111 7 Todd 788 Harrison St San Francisco 94117 Products ID Product_name Price Quantity 1 Metal pen 5.99 20 2 Surge protector 25.99 0 3 pencil...
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno,...
Use the following tables to answer Q5 and Q6. Tourist (tno, Name, phone, age,loc) Vehicle (Vno, model, mileage, owner_name, owner_ph)) Rented (tno, Vno) 5. (i)Write an SQL query, to create the table vehicle with following constraints: Vno should begin with second letter ‘v’; Models are one among Thar, X3. Mileage should be above 18 and below 25. No two records can have same phone (ii) Write an SQL query to retrieve the name of the owner who does owns X3...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode)...
The relational schema for the Academics database is as follows: DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) Some notes on the Academics database: An academic department belongs to one institution (instname) and often has many academics. An academic only works for one department. Research papers (PAPER) are often authored by several academics, and of course an academic often writes several papers (AUTHOR). A research field...