Question: / * Create department table * / CREATE TABLE department ( dpt _ no INT PRIMARY KEY, dpt _ name VARCHAR ( 2 0 )
Create department table
CREATE TABLE department
dptnoINT PRIMARY KEY,
dptname VARCHAR NOT NULL,
dptmgrssn CHAR
dptmgrstartdateDATE;
Create deptlocations table
CREATE TABLE deptlocation
dptno INT NOT NULL,
dptlocation VARCHAR
PRIMARY KEY dptno dptlocation
FOREIGN KEY dptno REFERENCES departmentdptno;
Create project table
CREATE TABLE project
pronumINT
pronameVARCHAR NOT NULL,
prolocationVARCHAR
prodeptnum INT
PRIMARY KEY pronum
FOREIGN KEY prodeptnum REFERENCES departmentdptno;
Create employee table
CREATE TABLE employee
empssnCHAR PRIMARY KEY,
emplastnameVARCHAR NOT NULL,
empfirstnameVARCHAR NOT NULL,
empmiddlenameVARCHAR
empaddressVARCHAR
empcityVARCHAR
empstateCHAR
empzipCHAR
empdateofbirthDATE
empsalaryINT NOT NULL,
CONSTRAINT ckempsalary CHECK empsalary
empparkingspaceINT UNIQUE,
empgenderCHAR
empdptnumINT
empsuperssnCHAR
CONSTRAINT fkempdpt FOREIGN KEY empdptnum REFERENCES departmentdptno
CONSTRAINT fkempsuperssn FOREIGN KEY empsuperssn REFERENCES employeeempssn;
Create assignment table
CREATE TABLE assignment
workempssnCHAR
workpronumINT
workhours INT,
workhoursplannedINT
CONSTRAINT pkassignment PRIMARY KEY workempssn workpronum
CONSTRAINT fkworkempFOREIGN KEY workempssn REFERENCES employeeempssn
CONSTRAINT fkworkpronum FOREIGN KEY workpronum REFERENCES projectpronum;
Create dependent table
CREATE TABLE dependent
depempssnCHAR
depnameVARCHAR
depgenderCHAR
depdateofbirthDATE
deprelationshipVARCHAR NOT NULL,
CONSTRAINT pkdependent PRIMARY KEY depempssn depname
CONSTRAINT fkdepempssn FOREIGN KEY depempssn REFERENCES employeeempssn;
Write a query to display all employees with the total number of projects they work on including employees with no assignment. Display six columnsEmployee Name, department number and name, # of projects, the total actual hours, total planned hours and the difference. List the employee name as first and last name with a space in between. Sort the results by the department in ascending order, then # of projects in ascending order. Your name should be in the result list. See sample output below. pts
IMPORTANT: You need to research how to use IFNULL function. No partial credit, if the format of your results is different than provided in the sample output.
Write a query to display all employees, the total number of projects they worked on and the total $ amount of the equipment used in those projects. If an employee does not have any assignment, you still must include those employees in the results list. Display four columnsEmployee SSN Employee Name, # of Projects, and Equipment Total. Format the employee SSN as shown below. List the employee first and last name with a space between. Format the equipment total with a dollar sign as shown below. Sort the results by equipment total in ascending order. See sample output below. Your output must match the sample output. pts
IMPORTANT: You need to research how to use the FORMAT function and add $ sign in the results. No partial credit, if the format of your results is different than provided in the sample
Write a query to display projects that have the difference between hours planned and hours worked is more than Display five columns. List the project number and name with a dash in between, name the column as Project the total hours planned as Hours Planned the total hours worked as Hours Worked the difference, and the number of employees worked in each project. Sort the results in descending order by the difference. See sample output below. Your output must match the sample output. pts
Write a query to display the managers SSN managers first and last name with a space between them, department number, department name, employees SSN employees first and last name with a space between them, and the following information about the employee's dependents: name, relationship and date of birth. The department number and name are that of the employee, not the manager. Name the columns as follows: Manager SSN Manager Name, Department, Employee SSN Employee Name, Dependent Name, Relationship and Dependent DOB. Sort the results by department number, employee SSN in all ascending order. See sample output below. pts
IMPORTANT: You need to research how to use SUBSTRING and DATEFORM
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
