Question

In: Computer Science

B) DML and SQL Query For this DB Schema, answer the below questions: Employee (Fname, Minit,...

B) DML and SQL Query
For this DB Schema, answer the below questions:
Employee (Fname, Minit, Lname, Ssn, Bdate, Address, Sex, Salary, Super_ssn, Dno)
Department (Dname, Dnumber, Mgr_ssn, Mgr_start_date)

5. Delete from Employee table, those who have First name: James.
6. Delete from Employee table, those who have Salary more than 4000.
7. What happens if you try to delete one department?
8. Retrieve the data of all employee.
9. Retrieve the data of all male employee.
10. Retrieve the Fname, Lname of all male employee.
11. Retrieve the Fname, Lname and Salary of all employee
12. Retrieve the Fname, Lname and Salary of all employee with Salary more than 4000
13. Retrieve the Fname, Lname and Salary of all female employee with Salary more than 4000
14. Retrieve the Fname, Lname and Address of all female employee with Salary more than 4000 and Birthdate after 1-1-1990.
15. Retrieve the Address and Salary of all employee with Fname = John or James.
16. Retrieve the Address and Salary of all employee with Fname = John or Birthdate after 1-1-1990
17. Retrieve the Name and Number of all Departments
18. Retrieve the Name and Number of all Departments with Manager SSN=123456
19. Retrieve the Employee Fname, Lnameand Department number for all employees.
20. Retrieve the Employee Fname, Lnameand Department number and Department Name for all employees.
21. Retrieve the Employee Fname, Lnameand who works in Department name = Research
22. Retrieve the Employee Fname, Lnameand who works in Department name = Research and IT
23. Retrieve the Employee Fname, Lnameand who works in Department name = Research OR IT
24. Retrieve the Department Name ,Number , Manager SSN
25. Retrieve the Department Name ,Number , Manager SSN, Manager FName
26. Retrieve the Department Name, Manager SSN, Manager FName for departments with Manager Start Date > 1-1-2010
please write it in computer word not pin and thank you

Solutions

Expert Solution

Hi, hope you are doing good.

5) DELETE FROM Employee WHERE Fname='James';

6) DELETE FROM Employee WHERE Salary>4000;

7) When we delete one tuple/row from Department table then entry in Employee table for that Dno changed to NULL or deleted.

8) SELECT * FROM Employee;

9) SELECT * FROM Employee WHERE Sex='Male';

10) SELECT Fname, Lname FROM Employee WHERE Sex='Male';

11) SELECT Fname, Lname, Salary From Employee;

12) SELECT Fname, Lname, Salary From Employee WHERE Salary>4000;

13) SELECT Fname, Lname, Salary From Employee WHERE Sex='Female' ^ Salary>4000;

14) SELECT Fname, Lname, Salary From Employee WHERE Salary>4000^Sex='Female'^Bdate>('1-1-1990');

15) SELECT Address, Salary FROM Employee WHERE Fname IN ('John','James');

16) SELECT Address, Salary FROM Employee WHERE Fname='John' Bdate >('1-1-1990');

17) SELECT Dname, Dnumber FROM Department;

18) SELECT Dname, Dnumber FROM Department WHERE Mgr_ssn='123456';

19) SELECT Fname, Lname, Dnumber From Employee, Department;

20) SELECT Fname, Lname, Dnumber, Dname From Employee, Department;

21) SELECT Fname, Lname, Dnumber FROM Department Where Dname ='Research';

22) SELECT Fname, Lname, Dnumber FROM Department Where Dname ='Research'^Dname='IT';

23) SELECT Fname, Lname, Dnumber FROM Department Where Dname IN('Research', 'IT');

24) SELECT Dname, Dnumber, Mgr_ssn FROM Department ;

25) SELECT Dname, Dnumber, Mgr_ssn, Fname From Employee, Department WHERE Department.Mgr_ssn= Employee.ssn;

26) SELECT Dname, Dnumber, Mgr_ssn, Fname From Employee, Department WHERE Department.Mgr_ssn= Employee.ssn ^ Mgr_start_date>'1-1-2010';

Note: If you have any query please let me know in the comment. Have a nice day!


Related Solutions

A) DDL For Company DB Schema, Answer the below questions: Emp (Empno, Ename, Job, Hiredate, Sal,...
A) DDL For Company DB Schema, Answer the below questions: Emp (Empno, Ename, Job, Hiredate, Sal, Comm, Deptno) Dept (Deptno, Dname, loc) 1. Retrieve the data of all employees. 2. Retrieve the data of all Salemanemployees. 3. Retrieve the name and Salary of all employees. 4. Retrieve the name and salary of Salemanemployees. 5. Retrieve the name and salary of all employees with Salary more than 2000. 6. Retrieve the Name and Salary of all employees who work in department...
Given the following relational schema, write queries in SQL to answer the English questions. There is...
Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...
Given the following relational schema, write queries in SQL to answer the English questions. There is...
Given the following relational schema, write queries in SQL to answer the English questions. There is a shipment database on the MySQL server. You can also use the DDL for MySQL. You must only submit the SQL for your answers but you can include the query output as well to help the TA with marking. Customer(cid: integer, cname: string, address: string, city: string, state: string) Product(pid: integer, pname: string, price: currency, inventory: integer) Shipment(sid: integer, cid: integer, shipdate: Date/Time) ShippedProduct(sid:...
Basic SQL Use the following schema to answer the queries below using SQL DEVICE [dno, dtype,...
Basic SQL Use the following schema to answer the queries below using SQL DEVICE [dno, dtype, price] PROVIDER [pno, pname, web] SERVICE [dno, pno, servicedate] SERVICE.dno references DEVICE.dno SERVICE.pno references PROVIDER.pno bold is underline. a) Find the dno for the most expensive device b) Find all providers that have the work fast in the name c) Find the number of different device types (dtype) d) Give all details of devices with price more than $400
SQL query exercises: Consider the following database schema:                Product(maker, model, type)              &
SQL query exercises: Consider the following database schema:                Product(maker, model, type)                PC(model, speed, ram, hd, rd, price)                Laptop(model, speed, ram, hd, screen, price)                Printer(model, color, type, price) Consider the Drivers-Cars-Reserves DB for a small rental car company:                Drivers(id, name, rating, age)                Cars(vin, maker, model, year, color)                Reserves(did, vin, date) Give SQL statement each of the following operations: Find the colors of cars reserved by Smith. Find all id’s of drivers who have a...
Structured query language (SQL): A. Does not allow conditions to be put on the query. B....
Structured query language (SQL): A. Does not allow conditions to be put on the query. B. Is a complex language used to extract data from a limited number of tables. C. Isolates data within tables. D. Takes advantage of the primary record key to link tables.
Multiple Choice (20 marks) Query Questions (use the tables below to answer the 5 query questions...
Multiple Choice Query Questions (use the tables below to answer the 5 query questions below) The Business. A retail company sells electronics items by phone and on its web site. The company records information about each item sold in a table called Sales. A few rows of the Sales table in the database are shown below: Sales table (primary key = SaleID and ItemID) SaleID ItemID CustomerID ItemType SaleDate 101 151 52 4 1/1/2019 101 176 52 1 1/1/2019 102...
Write an SQL query that will output the employee id, first name and hire date from...
Write an SQL query that will output the employee id, first name and hire date from the employee table. Pick only those employees whose employee ID is specified in the employee table (no nulls). If the employee id is 777, name is ABC and hire date is 01-JAN-2016, the output should be like - ' ABC (Employee ID - 777) was hired on 1, January of 2016'. Note - The date should not have preceding zeros.
QUERY PROCESSING JOIN 1) Let the schema of a relation r as R(A,B,C), and a relation...
QUERY PROCESSING JOIN 1) Let the schema of a relation r as R(A,B,C), and a relation s has schema S(C,D,E). Relation table r has 40K tuples, relation s has 60K tuples. The block factor of r is 25. The block factor of s is 30. Let the average seek time is t S and average block transfer time is t T . Assume you have a memory that contains M pages, but M< 40K/25 (indicating that s cannot be entirely...
Write SQL queries for the following statements based on Employees table whose schema is given below:...
Write SQL queries for the following statements based on Employees table whose schema is given below: (Employee_ID,First_Name,Last_Name,Email,Phone_Number,Hire_Date,Job_ID,Salary, Manager_Id, Department_Id) a. Create the given table along with the following constraints: Phone_Number should not be left undefined, salary should be between 10000 and 20000, employee_id should uniquely identify rows and should not be left undefined. User-defined names should be given to constraints. b.  Display each employee’s last name, hire date and salary review date (which is the date after six months of service)....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT