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)...
Write the following SQL queries based on hbsoe database from Mode: Select all the employee information...
Write the following SQL queries based on hbsoe database from Mode: Select all the employee information and list them for first 100 only. Select all the order information from country Germany. How many distinct orders are made from each country? List the names of employees who made orders from country Germany. List the names of companies which supplies chai or tofu
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"},
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...
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...
Given the following two related tables, write the SQL SELECT statement to solve the following queries...
Given the following two related tables, write the SQL SELECT statement to solve the following queries about developers (Dev) and programs (Prog). The id column in Dev and Prog is the relation between the two tables. Dev(id, name, dept, salary) Prog(id, title, language, lines, size); 1. List name of Devs who have written more than 1000 line programs 2. List title of all programs written in C++ language 3. List name of all developers who have written C++ programs
1. Write a SELECT statement to count SKUs for each department, i.e., a table of two...
1. Write a SELECT statement to count SKUs for each department, i.e., a table of two columns, departments and their SKU counts. use cape_codd; select department, count(*) from sku_data group by department ; 2. List buyers who is responsible for at least two SKUs, in three columns, department, buyer, sku count. Sort buyers by their department names in ascending order. select department, buyer, count(sku) from sku_data group by buyer ; 3. Write a SQL statement which returns all the orders....
SELECT vendor_name, TO_CHAR(INVOICE_TOTAL - (PAYMENT_TOTAL + CREDIT_TOTAL),'$999,999.90') AS "AMTDUE" 2 FROM AP.VENDORS 3 JOIN AP.INVOICES 4...
SELECT vendor_name, TO_CHAR(INVOICE_TOTAL - (PAYMENT_TOTAL + CREDIT_TOTAL),'$999,999.90') AS "AMTDUE" 2 FROM AP.VENDORS 3 JOIN AP.INVOICES 4 ON vendors.vendor_id = invoices.vendor_id 5 GROUP BY vendor_name 6 WHERE (INVOICE_TOTAL - (PAYMENT_TOTAL + CREDIT_TOTAL)) > 0; WHERE (INVOICE_TOTAL - (PAYMENT_TOTAL + CREDIT_TOTAL)) > 0 * ERROR at line 6: ORA-00933: SQL command not properly ended
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...