Use CREATE? statement to create a table Client (ClientName,? phone). Note ClientName is primary key and you must define this primary key in CREATE statement
a1. Use CREATE statement to create a table Client (ClientName, phone). Note ClientName is primary key and you must define this primary key in CREATE statement. Show the statement.
a2. Use INSERT statement to add two client records into Client table (make up your own data for clients). Show the INSERT statements and use select statement to show the table contents.
a3. Use ALTER statements to add a foreign key ClientName as a constraint into the Project table. So that table Client has a one to many relationship with table Project. Note, you need to use TWO ALTER statements , one for adding attribute ClientName into Project table; one for adding foreign key constraint into Project table. Show the ALTER statements.
a4. User ALTER statement to Add an attribute Project_Count into Employee table (data type to be integer, refer to the data type used for Workon table (hours) in loadDB file).
a5. Use UPDATE statement to fill the value of Project_count of each employee record in Employee table. Namely, add the count of total number of projects an employee works on into Project_count in Employee table for each employee. Hint: you need a subquery in Update statement as follows
Update _________
Set _____ = (select count (pid) …… )
Show the contents of Employee after update.
a6 Create a table Promotion_list (EMPID, Name, Salary, DivisionName).
a7 Load Promotion_list with the information of employees who make less than company average and work on at least 2 projects. (Hint use INSERT INTO SELECT statement ). Show the code and result.
Part B
b1. Increase the budget of a project by 5% if there is a manager working on it .
b2. List the name of employee who work on a project sponsored by his/her own division. (corelated subquery)
b3. List the name of project that has budget that is higher than ALL projects from 'marketing' division.
b4. List the name of project that has budget that are higher than ALL projects from 'chen's division.
b5. List the name of employee who work on more projects than his/her manager.
b6. List The name of division that has employee(s) who work on other division's project . (corelated subquery)
drop table workon; drop table employee; drop table project; drop table division; create table division (did integer, dname varchar (25), managerID integer, constraint division_did_pk primary key (did) ); create table employee (empID integer, name varchar(30), salary float, did integer, constraint employee_empid_pk primary key (empid), constraint employee_did_fk foreign key (did) references division(did) ); create table project (pid integer, pname varchar(25), budget float, did integer, constraint project_pid_pk primary key (pid), constraint project_did_fk foreign key (did) references division(did) ); create table workon (pid integer, empID integer, hours integer, constraint workon_pk primary key (pid, empID) ); /* loading the data into the database */ insert into division values (1,'engineering', 2); insert into division values (2,'marketing', 1); insert into division values (3,'human resource', 3); insert into division values (4,'Research and development', 5); insert into division values (5,'accounting', 4); insert into project values (1, 'DB development', 8000, 2); insert into project values (2, 'network development', 6000, 2); insert into project values (3, 'Web development', 5000, 3); insert into project values (4, 'Wireless development', 5000, 1); insert into project values (5, 'security system', 6000, 4); insert into project values (6, 'system development', 7000, 1); insert into employee values (1,'kevin', 32000,2); insert into employee values (2,'joan', 42000,1); insert into employee values (3,'brian', 37000,3); insert into employee values (4,'larry', 82000,5); insert into employee values (5,'harry', 92000,4); insert into employee values (6,'peter', 45000,2); insert into employee values (7,'peter', 68000,3); insert into employee values (8,'smith', 39000,4); insert into employee values (9,'chen', 71000,1); insert into employee values (10,'kim', 46000,5); insert into employee values (11,'smith', 46000,1); insert into employee values (12,'joan', 48000,1); insert into employee values (13,'kim', 49000,2); insert into employee values (14,'austin', 46000,1); insert into employee values (15,'sam', 52000,3); insert into workon values (3,1,30); insert into workon values (2,3,40); insert into workon values (5,4,30); insert into workon values (6,6,60); insert into workon values (4,3,70); insert into workon values (2,4,45); insert into workon values (5,3,90); insert into workon values (3,3,100); insert into workon values (6,8,30); insert into workon values (4,4,30); insert into workon values (5,8,30); insert into workon values (6,7,30); insert into workon values (6,9,40); insert into workon values (5,9,50); insert into workon values (4,6,45); insert into workon values (2,7,30); insert into workon values (2,8,30); insert into workon values (2,9,30); insert into workon values (1,9,30); insert into workon values (1,8,30); insert into workon values (1,7,30); insert into workon values (1,5,30); insert into workon values (1,6,30); insert into workon values (2,6,30); insert into workon values (2,12,30); insert into workon values (3,13,30); insert into workon values (4,14,20); insert into workon values (4,15,40);
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.