Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Try to solve the question appropriately and in detail. This is a Database problem of computer science. ##From the company and company2 file by import-

Try to solve the question appropriately and in detail. This is a Database problem of computer science.

image text in transcribed

##From the company and company2 file by import-

#Company Database

create table department ( dname char(20) not null, dnumber numeric(1) not null, mgrssn numeric(9) not null, mgrstartdate date not null, primary key (dnumber), unique (dname) ); insert into department values ('Research',5,333445555,'22-MAY-1988'), ('Administration',4,987654321,'01-JAN-1996'), ('Headquarters',1,888665555,'19=JUN-1981');

create table employee ( fname char(10) not null, lname char(20) not null, ssn numeric(9) not null, bdate date not null, address char(30) not null, gender char(1) not null, salary numeric(5) not null, superssn numeric(9), dno numeric(1) not null, primary key (ssn), foreign key (dno) references department(dnumber) ); insert into employee values ('John','Smith',123456789,'09-JAN-1965','731 Fondren, Houston TX','M',30000,333445555,5), ('Franklin','Wong',333445555,'08-DEC-1965','638 Voss, Houston TX','M',40000,888665555,5), ('Alicia','Zelaya',999887777,'19-JAN-1968','3321 Castle, Spring TX','F',25000,987654321,4), ('Jennifer','Wallace',987654321,'20-JUN-1941','291 Berry, Bellaire TX','F',43000,888665555,4), ('Ramesh','Narayan',666884444,'15-SEP-1962','975 Fire Oak, Humble TX','M',38000,333445555,5), ('Joyce','English',453453453,'31-JUL-1972','5631 Rice, Houston TX','F',25000,333445555,5), ('Ahmad','Jabbar',987987987,'29-MAR-1969','980 Dallas, Houston TX','M',25000,987654321,4), ('James','Borg',888665555,'10-NOV-1937','450 Stone, Houston TX','M',55000,null,1);

create table project ( pname char(20) not null, pnumber numeric(2) not null, plocation char(20) not null, dnum numeric(1) not null, primary key (pnumber), unique (pname), foreign key (dnum) references department(dnumber) ); insert into project values ('ProductX',1,'Bellaire',5), ('ProductY',2,'Sugarland',5), ('ProductZ',3,'Houston',5), ('Computerization',10,'Stafford',4), ('Reorganization',20,'Houston',1), ('Newbenefits',30,'Stafford',4);

create table works_on ( essn numeric(9) not null, pno numeric(2) not null, hours numeric(5,1), primary key (essn, pno), foreign key (essn) references employee(ssn), foreign key (pno) references project(pnumber) ); insert into works_on values (123456789,1,32.5), (123456789,2,7.5), (666884444,3,40.0), (453453453,1,20.0), (453453453,2,20.0), (333445555,2,10.0), (333445555,3,10.0), (333445555,10,10.0), (333445555,20,10.0), (999887777,30,30.0), (999887777,10,10.0), (987987987,10,35.0), (987987987,30,5.0), (987654321,30,20.0), (987654321,20,15.0), (888665555,20,null);

create table dependent ( essn numeric(9) not null, dependent_name char(10) not null, gender char(1) not null, bdate date not null, relationship char(30) not null, primary key (essn, dependent_name), foreign key (essn) references employee(ssn) );

insert into dependent values (333445555,'Alice','F','04-APR-1986','Daughter'), (333445555,'Theodore','M','25-OCT-1983','Son'), (333445555,'Joy','F','03-MAY-1958','Spouse'), (987654321,'Abner','M','28-FEB-1942','Spouse'), (123456789,'Michael','M','04-JAN-1988','Son'), (123456789,'Alice','F','30-DEC-1988','Daughter'), (123456789,'Elizabeth','F','05-MAY-1967','Spouse');

create table dept_locations ( dnumber numeric(1) not null, dlocation char (15) not null, primary key (dnumber, dlocation), foreign key (dnumber) references department(dnumber) ); insert into dept_locations values (1,'Houston'), (4,'Stafford'), (5,'Bellaire'), (5,'Sugarland'), (5,'Houston');

alter table department add constraint depemp foreign key (mgrssn) references employee(ssn);

alter table employee add constraint empemp foreign key (superssn) references employee(ssn);

#Company2 Database

CREATE TABLE Emps( Employee_Id integer(6) PRIMARY KEY, First_Name VARCHAR(20), Last_Name VARCHAR(25) NOT NULL, Email VARCHAR(25) NOT NULL, Phone_Number VARCHAR(15), Hire_Date DATE NOT NULL, Job_Id VARCHAR(10) NOT NULL, Salary integer(255), Commission_pct integer(255), Manager_id integer(255), Department_Id integer(255));

INSERT INTO Emps VALUES(100, 'Steven','King', 'SKING','515.123.4567', '17-JUN-2006', 'AD_PRESS',24000, NULL, NULL, 90), (101, 'Neena','Kochar', 'NKOCHAR','515.123.4568', '21-SEP-2008', 'AD_VP',17000, NULL, 100, 90), (102, 'Lex','De Haan', 'DEHAAN','515.123.4569', '13-JAN-2009', 'AD_VP',17000, NULL, 100, 90), (103, 'Alexander','Hunold', 'AHUNOLD','590.423.4567', '03-JAN-2008', 'IT_PROG',9000,NULL, 102, 60), (104, 'Bruce','Ernst', 'BERNST','590.423.4568', '21-MAY-2009', 'IT_PROG',6000,NULL, 103, 60), (107, 'Diana','Lorentz', 'DLORENTZ','590.423.5567', '07-FEB-2008', 'IT_PROG',4200,NULL, 103, 60), (124, 'Kevin','Mourgos', 'KMORGOS','650.123.5234', '16-NOV-2012', 'ST_MAN',5800,NULL, 100, 50), (141, 'Treena','Rajs', 'RRAJS','650.121.5234', '17-OCT-2004', 'ST_CLERK',3500,NULL, 124, 50), (142, 'Curtis','Davies', 'CDAVIES','121.123.5234', '29-JAN-2007', 'ST_CLERK',3100,NULL, 124, 50), (143, 'Randall','Matos', 'RMATOS','121.123.5234', '15-MAR-2008', 'ST_CLERK',2600,NULL, 124, 50), (144, 'Peter','Vargas', 'PVARGAS','121.123.5234', '09-JUL-2008', 'ST_CLERK',2500,NULL, 124, 50), (149, 'Eleni','Zlotkey', 'EZLOTKEY','44.1344.429018', '29-JAN-2014', 'SA_MAN',10500,.2, 100, 80), (174, 'Ellen','Abel', 'EABEL','44.1644.429017', '11-MAY-2004', 'SA_REP',11000,.3, 149, 80), (176, 'Jnathon','Taylor', 'JTAILOR','44.1644.429021', '24-MAR-2008', 'SA_MAN',8600,.2, 149, 80), (178, 'Kimberely','Grant', 'KGRANT','44.1644.429023', '24-MAY-2009', 'SA_MAN',7000,.15, 149, NULL), (200, 'Jennifer','Whalem', 'JWHALEN','515.123.4444', '17-SEP-2003', 'ADD_ASST',4400,NULL, 101, 10), (201, 'Michael','Hartstein', 'MHARSTEIN','515.123.5555', '17-FEB-2008', 'MK_MAN',13000,NULL, 100, 20), (202, 'Pat','Fay','PFAY','603.123.6666', '17-AUG-2010', 'MK_REP',6000,NULL, 201, 20), (205, 'Shelley','Higgins', 'SHIGGINS','515.123.8050', '07-JUN-2007', 'AC_MGR',12000,NULL, 101, 110), (206, 'William','Gietz', 'WGIETZ','515.123.8181', '07-JUN-2007', 'AC_ACCOUNT',8300,NULL, 205, 110);

CREATE TABLE Depts( Department_id integer(255) PRIMARY KEY, Department_Name VARCHAR(30) NOT NULL, Manager_id integer(255), Location_id integer(255));

INSERT INTO Depts VALUES(10, 'Administration',200,1700), (20, 'Marketing',201,1800), (50, 'Shipping',124,1500), (60, 'IT',103,1400), (80, 'Sales',149,2500), (90, 'Executive',100,1700), (110, 'Accounting',205,1700), (190, 'Contracting',NULL,1700);

CREATE TABLE Locs( Location_id integer(4) PRIMARY KEY, Street_Address VARCHAR(40), Postal_Code VARCHAR(12), City VARCHAR(30) NOT NULL, State_Province VARCHAR(25), Country_ID CHAR(2));

INSERT INTO Locs VALUES(1400, '2014 Jabberwocky Rd','26192','Southlake', 'Texas', 'US'), (1500, '2011 Interiors Blvd','99236','South San Francisco', 'California', 'US'), (1700, '2004 Charade Rd','98199', 'Seattle','Washington', 'US'), (1800, '460 Bloor St. W.','ON M5S 1X8', 'Toronto','Ontario', 'CA'), (2500, 'Magdalen Centre- The Oxford Sc. Park','OX9 9ZB', 'OXford','Oxford', 'UK');

Activity 02: 1)Find the first name and Last name of the employees who are supervised by "Franklin Wong'? 2) Find the last and first name of the female employees who have a dependent with the same first name as themselves? 3)For each department find out the department manager's last name, his start date and the name his dependents (if any)? 4) For each employee find out the employee's last and first name, the department name in which he works and the project name he works in and the number of hours he work in those projects

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Generative Artificial Intelligence For Project Management With Aws

Authors: Timothy Krimmel

1st Edition

B0CQV9KWB8, 979-8872627197

More Books

Students also viewed these Databases questions

Question

Explain Potters general framework for mass media scholarship.

Answered: 1 week ago

Question

Language in Context?

Answered: 1 week ago