JS extension only to highlight the terms in mongodb commands
- CREATE TABLE Employee fname VARCHAR(15), minit CHAR, ,lname VARCHAR(15),ssn CHAR(9), bdate DATE, address VARCHAR(30), sex CHAR, salary DECIMAL(10,2), super_ssn CHAR(9), dno INT, PRIMARY KEY (ssn), FOREIGN KEY (super_ssn) REFERENCES Employee(ssn), FOREIGN KEY (dno) REFERENCES DEPARTMENT(dnumber)
- CREATE TABLE Department dname VARCHAR(15), dnumber INT, mgr_ssn CHAR(9), mgr_start_date DATE, PRIMARY KEY (dnumber), UNIQUE (dname), FOREIGN KEY (mgr_ssn) REFERENCES Employee(ssn)
- CREATE TABLE dept_locations dnumber INT, dlocation VARCHAR(15), PRIMARY KEY (dnumber, dlocation), FOREIGN KEY (dnumber) REFERENCES Department(dnumber)
- CREATE TABLE Project pname VARCHAR(15), pnumber INT, plocation VARCHAR(15), dnum INT, PRIMARY KEY (pnumber) UNIQUE (pname), FOREIGN KEY (dnum) REFERENCES Department(dnumber)
- CREATE TABLE Dependent essn CHAR(9), dependent_name VARCHAR(15), sex CHAR, bdate DATE, relationship VARCHAR(8), PRIMARY KEY (essn, dependent_name), FOREIGN KEY (essn) REFERENCES Employee(Ssn)
- CREATE TABLE Works_on essn CHAR(9),pno INT, hours DECIMAL(10,2), FOREIGN KEY (essn) REFERENCES Employee(Ssn), FOREIGN KEY (pno) REFERENCES Project(pnumber)
- Insert 10 rows of data into each table
- Retrieve the birth date and address of the employee(s) whose name is ‘John B. Smith’.
- Retrieve the name and address of all employees who work for the ‘Research’ department. Repeat the above query using aliases.
- For every project located in ‘Stafford’, list the project number, the controlling department number, and the department manager’s last name, address, and birth date.
- For each employee, retrieve the employee’s first and last name and the first and last name of his or her immediate supervisor.
5: What is the result of the query
SELECT Ssn FROM EMPLOYEE;
6: What is the result of the querySELECT Ssn, Dname FROM EMPLOYEE, DEPARTMENT;
- Make a list of all project numbers for projects that involve an employee whose last name is ‘Smith’, either as a worker or as a manager of the department that controls the project.
- Retrieve all employees whose address is in Houston, Texas.
- Find all employees who were born during the 1950s.
- Show the resulting salaries if every employee working on the ‘ProductX’ project is given a 10 percent raise.
- Retrieve all employees in department 5 whose salary is between $30,000 and $40,000.
- Retrieve a list of employees and the projects they are working on, ordered by department and, within each department, ordered alphabetically by last name, then first name.
- Retrieve the names of all employees who do not have supervisors.
- Make a list of all project numbers for projects that involve an employee whose last name is ‘Smith’, either as a worker or as a manager of the department that controls the project using logical OR connective
- Select the Essns of all employees who work the same (project, hours) combination on some project that employee ‘John Smith’ (whose Ssn = ‘123456789’) works on.
- List the names of employees whose salary is greater than the salary of all the employees in department 5
- Retrieve the names of employees who have no dependents.
- List the names of managers who have at least one dependent.
- Retrieve the name of each employee who works on all the projects controlled by department number 5 using EXISTS and NOT EXISTS functions.
- Retrieve the Social Security numbers of all employees who work on project numbers 1, 2, or 3 with duplicate Ssns listed.
- Retrieve the Social Security numbers of all employees who work on project numbers 1, 2, or 3 without duplicate Ssns listed.
- Retrieve the name and address of all employees who work for the ‘Research’ department using JOIN... ON operation
- For every project located in ‘Stafford’, list the project number, the controlling department number, and the department manager’s last name, address, and birth date using JOIN.. ON operation
- Check if outer joins can be specified by using the comparison operators +=, =+, and +=+ for left, right, and full outer join, respectively,when specifying the join condition. For example, for each employee, retrieve the employee’s last name and the last name of his or her immediate supervisor. The above query can be solved using SELECT E.Lname, S.Lname FROM EMPLOYEE E, EMPLOYEE S WHERE E.Super_ssn += S.Ssn;
- Find the total number of employees of the ‘Research’ department and sum of the salaries of all employees of the ‘Research’ department, as well as the maximum salary, the minimum salary, and the average salary in this department.
- Count the number of distinct salary values in the database.
- Retrieve the names of all employees who have two or more dependents
- For each department, retrieve the department number, the number of employees in the department, and their average salary.
- For each project, retrieve the project number, the project name, and the number of employees who work on that project.
- For each project on which more than two employees work, retrieve the project number, the project name, and the number of employees who work on the project.
- For each project, retrieve the project number, the project name, and the number of employees from department 5 who work on the project.
- For each department that has more than five employees, retrieve the department number and the number of its employees who are making more than 40,000.
-
-
Consider the Sailor database given below. The primary keys are underlined. Assume relevant data types for attributes.
SAILORS(Sid, Sname, Rating, Age) BOATS(Bid, Bname, Colour) RESERVES(Sid, Bid, day)
-
Consider the following restaurant database with the following attributes -
Name, address –(building, street, area, pincode),id, cuisine, nearby landmarks, online delivery- yes/no, famous for(name of the dish).
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
-
-
-
Consider the Employee database given below. The primary keys are underlined. Assume relevant data types for attributes.
EMPLOYEE (Fname, Lname, SSN, Addrs, Sex, Salary, SuperSSN, Dno) DEPARTMENT (Dname, Dnumber, MgrSSN, MgrStartDate) PROJECT(Pno, Pname, Dnum) WORKS_ON (ESSN, Pno, Hours)
Create the above tables in SQL. Specify primary and foreign keys properly. Enter at least 5 tuples in each table with relevant data. Solve the following queries.
-
Consider the following restaurant table with the following attributes -
Name, address –(building, street, area, pincode), id, cuisine, nearby landmarks, online delivery- (yes/no), famous for(name of the dish)
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
-
-
- Consider the Aircraft database given below. The primary keys are underlined. Assume relevant data types for attributes.
Create the above tables in SQL. Specify primary and foreign keys properly. Enter at least 5 tuples in each table with relevant data. Solve the following queries.
AIRCRAFT (Aircraft ID, Aircraft_name, Cruising_range) CERTIFIED (Emp ID, Aircraft ID) EMPLOYEE (Emp ID, Ename, Salary)
- Consider the following restaurant table with the following attributes -
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
Name, address –(building, street, area, pincode), id, cuisine, nearby landmarks, online delivery- (yes/no), famous for(name of the dish)
- Consider the Aircraft database given below. The primary keys are underlined. Assume relevant data types for attributes.
-
- Consider the Supply-Parts database given below. The primary keys are underlined. Assume relevant data types for attributes.
Create the above tables in SQL. Specify primary and foreign keys properly. Enter at least 5 tuples in each table with relevant data. Solve the following queries.
SUPPLIER (Sid, Sname, Address) PART (PID, Pname, Color) SHIPMENT (Sid, PID, Cost)
- Consider the following Tourist places table with the following attributes -
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
Place, address – (state), id, tourist attractions,best time of the year to visit,modes of transport(include nearest airport, railway station etc), accommodation, food - what not to miss for sure.
- Consider the Supply-Parts database given below. The primary keys are underlined. Assume relevant data types for attributes.
-
- Consider the Aircraft database given below. The primary keys are underlined. Assume relevant data types for attributes.
Create the above tables in SQL. Specify primary and foreign keys properly. Enter at least 5 tuples in each table with relevant data. Solve the following queries.
AIRCRAFT (Aircraft ID, Aircraft_name, Cruising_range) CERTIFIED (Emp ID, Aircraft ID) EMPLOYEE (Emp ID, Ename, Salary)
- Consider the following Tourist places table with the following attributes -
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
Place, address –(state, id), tourist attractions,best time of the year to visit,modes of transport(include nearest airport, railway station etc), accommodation, food - what not to miss for sure.
- Consider the Aircraft database given below. The primary keys are underlined. Assume relevant data types for attributes.
-
- Consider the Employee database given below. The primary keys are underlined. Assume relevant data types for attributes.
Create the above tables in SQL. Specify primary and foreign keys properly. Enter at least 5 tuples in each table with relevant data. Solve the following queries.
EMPLOYEE (Fname, Lname, SSN, Addrs, Sex, Salary, SuperSSN, Dno) DEPARTMENT (Dname, Dnumber, MgrSSN, MgrStartDate) DEPENDENT(Dname, ESSN)
- Consider the following Tourist places table with the following attributes -
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
Place, address – (state, id), tourist attractions,best time of the year to visit,modes of transport(include nearest airport, railway station etc), accommodation, food - what not to miss for sure.
- Consider the Employee database given below. The primary keys are underlined. Assume relevant data types for attributes.
-
- Consider the following Accident Tracker Schema. The primary keys are underlined.
Create the above tables in SQL. Specify primary and foreign keys properly. Enter at least 5 tuples in each table with relevant data. Solve the following queries.
PERSON (driver – id #: String, name: string, address: string) CAR (Regno: string, model: string, year: int) ACCIDENT (report-number: int, acc_date: date, location: string) OWNS (driver-id #: string, Regno: string) PARTICIPATED (driver-id: string, Regno: string, report-number: int, damageamount: int)
- Consider the following Movie table with the following attributes -
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
Actor_name,Actor_id, Actor_birthdate, Dirctor_name,Director_id, Director_birthdate, film_title, year of production ,type (thriller, comedy, etc.)
- Consider the following Accident Tracker Schema. The primary keys are underlined.
-
- Consider the Cricket database given below. The primary keys are underlined. Assume relevant data types for attributes.
Create the above tables in SQL. Specify primary and foreign keys properly. Enter at least 5 tuples in each table with relevant data. Solve the following queries.
PLAYER (PId, Lname, Fname, Country, Yborn, Bplace) MATCH (MatchId, Team1,Team2, Ground, Date, Winner) BATTING (MatchId, Pid, Nruns, Fours, Sixes) BOWLING (MatchId, Pid, Novers, Maidens, Nruns, Nwickets)
- Consider the following Movie table with the following attributes -
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
Actor_name,Actor_id, Actor_birthdate , Dirctor_name,Director_id, Director_birthdate, film_title, year of production ,type (thriller, comedy, etc.)
- Consider the Cricket database given below. The primary keys are underlined. Assume relevant data types for attributes.
-
- Consider the following shipment schema. The primary keys are underlined. Assume relevant data types for attributes.
Create the above tables in SQL. Specify primary and foreign keys properly. Enter at least 5 tuples in each table with relevant data. Solve the following queries.
CUSTOMER (cust # , cname, city) ORDER (order#, odate, cust #, ord-Amt) ORDER – ITEM (order #, Item #, qty) ITEM (item #, unit price) SHIPMENT (order #, ship-date)
- Consider the following Movie table with the following attributes -
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
Actor_name,Actor_id, Actor_birthdate , Dirctor_name,Director_id, Director_birthdate, film_title, year of production ,type (thriller, comedy, etc.)
- Consider the following shipment schema. The primary keys are underlined. Assume relevant data types for attributes.
-
- Consider the following shipment schema. The primary keys are underlined. Assume relevant data types for attributes.
Create the above tables in SQL. Specify primary and foreign keys properly. Enter at least 5 tuples in each table with relevant data. Solve the following queries.
CUSTOMER (cust # , cname, city) ORDER (order#, odate, cust #, ord-Amt) ORDER – ITEM (order #, Item #, qty) ITEM (item #, unit price) SHIPMENT (order #, ship-date)
- Consider the following Movie table with the following attributes -
Create 10 collections with data relevant to the following questions. Write and execute MongoDB queries:
Actor_name, Actor_id, Actor_birthdate, Director_name, Director_id, Director_birthdate, film_title, year of production, type (thriller, comedy, etc.)
- Consider the following shipment schema. The primary keys are underlined. Assume relevant data types for attributes.