Q1: The following question are based on these database tables:
EMPLOYEE
FNAME |
MIDINT |
LNAME |
SSN |
BDATE |
ADDRESS |
SEX |
SALARY |
SUPER_SSN |
Dept_No |
James |
A |
Borg |
123123123 |
Houston, TX |
M |
55000 |
Null |
1 |
|
Franklin |
S |
Wong |
234234234 |
Houston, TX |
M |
40000 |
123123123 |
5 |
|
John |
Q |
Smith |
345345345 |
Houston, TX |
M |
30000 |
234234234 |
5 |
|
Jennifer |
L |
Wallace |
456456456 |
Bellaire, TX |
F |
43000 |
123123123 |
4 |
|
Alicia |
M |
Zalaya |
567567567 |
Spring, TX |
F |
25000 |
456456456 |
4 |
|
Ramesh |
R |
Narayan |
678678678 |
Humble, TX |
M |
38000 |
234234234 |
5 |
|
Joyce |
V |
English |
7897789789 |
Houston, TX |
F |
25000 |
234234234 |
5 |
|
Ahmed |
B |
Jabbar |
890890890 |
Houston, TX |
M |
25000 |
456456456 |
1 |
DEPARTMENT
Dept_No |
Dept_Name |
1 |
Headquarter |
4 |
Administration |
5 |
Research |
Write out the SQL queries pertaining to the following questions. You must write the SQL query such that if they was copied and pasted on a database, the query would run.
Q2: In Chapter 4, you can see the creation of the Tiny College database design. That design reflected such business rules as “a professor may advise many students” and “a professor may chair one department.” The diagram is on the next page of this document for your convenience.
Modify the ERD design shown in Figure 4.35 (pg. 147) to include these business rules:
Given that information, create the complete ERD containing all primary keys, foreign keys, and main attributes.
FIGURE4.35 THECOMPLETEDTINYCOLLEGEERD
Q1.
Give me everything you have on employee.
select * from EMPLOYEE
Give me only the social security numbers, last names and the first names of all employees.
select SSN,LNAME,FNAME from EMPLOYEE
Show me all the salaries, but do not show me duplicate salaries figures.
select DISTINCT SALARY from EMPLOYEE
Show me the SSN of employees that are paid 25, 000 in salary.
select SSN from EMPLOYEE where SALARY = 25000
Show me the last name of all male employees
select LNAME from EMPLOYEE where SEX = "M"
Show me the department number, the first and last name of all
employees. Make sure that the department’s number are displayed in
order from low to high.
select Dept_No,LNAME,FNAME from EMPLOYEE order by Dept_No ASC
Give me a list of all those employees whose last name is English and whose sex is female
select * from EMPLOYEE where LNAME = "English" and SEX = "F"
Give me the total salary paid to all the employees who work in
department 5
select sum(SALARY) from EMPLOYEE where Dept_No = 5
Give me average salary for each department.
select Dept_No,avg(salary) from EMPLOYEE group by Dept_No
Show me the employees’ first name, last name along with the department name they work for.
select e.FNAME,e.LNAME,d.Dept_Name from EMPLOYEE E INNER JOIN DEPARTMENT D ON E.Dept_No = D.Dept_No
Q1: The following question are based on these database tables: EMPLOYEE FNAME MIDINT LNAME SSN BDATE ADDRESS SEX SALARY SUPER_SSN Dept_No James A Borg 123123123 Hous...
Problem 1 (25 points) Consider the following database schema: Employee (fname, Iname, ssn, address, salary, mgrssn, dnumber) Department (dname, dnumber, mgrssn, mngrstartdate) Project (pname, pnumber, plocation, dnumber) Works_On (ssn, pnumber, hours_per_week) Dependent (ssn, dependent name, bdate, relationship) The above relations store information about a company. The meaning of most of the relations and attributes is straightforward. For example, the first relation stores information about employees. The mgrssn is the SSN of the manager (supervisor) of the given employee. A manager...
Consider the relational database schema for a company below. EMPLOYEE/NAME, SSN, BDATE, ADDRESS, SEX, SALARY, SUPERSSN, DNA) TA DEPARTMENT(DNAME, DNUMBER. MESSINS, MGRSTARTDATE) DEPT_LOCATIONS(DNUMBER. DLOCATION PROJECT(PNAME, PNUMBER. PLOCATION, DNLIM) WORKS_ONCESSN.PNG, HOURS) DEPENDENTESSN, DEPENDENT-NAME, SEX, BDATE, RELATIONSHIP) Write SQL statements for the following queries: a) List the names of those employees who work in the "Production" department (6 marks). b) Find the maximum salary, minimum salary, and the average salary among employees who work for the "Production department (6 marks). Count the...
(SELECT pnumber FROM project, department, employee WHERE dnum=dnumber AND mgr_ssn=ssn AND lname='Smith') UNION (SELECT pnumber FROM project, works_on, employee WHERE pnumber=pno AND essn=ssnAND lname='Smith') Can you draw the relation step by step , how to solve it ?! Figure 5.6 One possible database state for the COMPANY relational database schema. EMPLOYEE Sex Salary Super ssn Dno B Smith 123456789 1965-01-09 731 Fondren, Houston, TX M 30000 3334455555 Ssn Fname Minit Lname John Franklin TWong 333445555 1955-12-08 638 Voss, Houston, TXM40000...
In Chapter 4, you saw the creation of the Tiny College database design, which reflected such business rules as “a professor may advise many students” and “a professor may chair one department.” Modify the design shown in Figure 4.36 to include these business rules:• An employee could be staff, a professor, or an administrator.• A professor may also be an administrator.• Staff employees have a work-level classification, such as Level I or Level II.• Only professors can chair a department....
Please provide the relation algebra, the oracle SQL code and the output tuples for the following (Answer #6 only the BONUS question). I have the others actually I have the BONUS, but I want to compare with your solution to make sure I did it correctly. Thank you very much! LAB exercises 2 Write the Oracle DML query codes for the following questions and take the screen shot of the output. 1. Retrieve the name and address of all employees...
Using SQL, carry out the various DML and DDL functions on the tables mentioned below: 1. Insert the data given above in both employee, department and project tables. 2. Display all the employees’ information. 3. Display Employee name along with his SSN and Supervisor SSN. 4. Display the employee names whose bdate is ’29-MAR-1959’. 5. Display salary of the employees without duplications. 6. Display the MgrSSN, MgrStartDate of the manager of ‘Finance’ department. 7. Modify the department number of an...
Oracle SQL Assignment 4 - List the name of supervisor who has more supervisee than other supervisors. The supervisor would be the Mgr_ssn from the Department table. Each employee from the Employee table has a Super_ssn which would be their supervisor. 1 to this PC Picture Tools ew Help Acrobat Storyboarding FormatTell me what you want to de Picture Bonde A Bring Send Selection Tent Pictu楩Layout . | | Forward. Backward . Pane Figure 3.6 One possibie database state for...
Search all employee who work total on all project less than 40 hrs from works_on table. Please give me a query for this. Figure 5.6 One possible database state for the COMPANY relational database schema. EMPLOYEE Fname Minit Lname Sex Salary Super ssn Dno B Smith 123456789 1965-01-09 731 Fondren, Houston, TX M 30000 333445555 5 FranklinT Wong 333445555 1955-12-08 638 Voss, Houston, TX M 40000 888665555 5 JZelaya 999887777 1968-01-19 3321 Castle, Spring, TX F 25000 9876543214 JenniferSWallace 9876543211941-06-20...
New to DB's Please help! You are designing and creating a database named COMPANY for an HR (Human Resource) Dept of a Software Consulting Company to manage their employees and their assigned work (projects) in the company First Step to Design and Create a Database is Creating an E-R Diagram by Identifying Entities, Attributes and Relationships between any two Entities to Create a Company Database Scheme. 1. Create an E-R Diagram for the Company database from the raw data files...
4. In Chapter 4, you saw the creation of the Tiny College database design, which reflected such business rules as "a professor may advise many students" and "a professor may chair one department." Modify the design shown in Figure 4.36 to include these business rules: . An employee could be staff, a professor, or an administrator. .A professor may also be an administrator. Staff employees have a work-level classification, such as Level I or Level II. Only professors can chair...