CIS 423- Assignment 3- JLBaptiste
-
Upload
publictivity -
Category
Documents
-
view
219 -
download
0
Transcript of CIS 423- Assignment 3- JLBaptiste
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 1/12
Files Included
• assignment3_create_tables_with_keys_and_constraints.sql - this creates thetables, checks if they exist, inserts foreign keys, primary keys, and table structure.• assignment3_insert_content.sql - this only inserts the content into the tables.
• assumptions_and_sqlqueries.pdf- this document. it includes a list of files included,assumptions, and the answers to the queries to be crafted.
Assumptions
• MySQL used as the database of choice. No specific database was specified to beused, and my Windows 7 install is completely corrupted. Only difference is foreign keysbeing called keys. You can see this in the .SQL files• Actual .SQL files included, not text.• Combined some operations into one - ie- creating primary keys happened with theactual table creation.
1. Question 1
SELECT *FROM EmployeeWHERE Last LIKE '%S' and last LIKE 'A%';
Result: No rows selected.
To get Franklin Wong, do the following
SELECT *FROM EmployeeWHERE Last LIKE '%G' and last LIKE 'W%';
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 2/12
2. Question 2
DELETEFROM EmployeeWHERE Birthday < 1959-11-08 ;
Result: 1 birthday deleted.
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 3/12
3. Question 3
UPDATE EmployeeSET `Salary` = `Salary`*1.10 ;
Result: Salaries updated 10%
4. Question 4
SELECT first,middle,lastFROM EmployeeWHERE Birthday LIKE ʻ%-11-08ʼ ;
Result: None selected, but if the birthday were a month from today it would be:
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 4/12
5. Question 5
SELECT count(SSN) AS ʻManaged By Franklin Wongʼ
FROM EmployeeWHERE SuperSSN = 333445555;
Result: 2
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 5/12
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 6/12
8. Question 8
SELECT COUNT(SSN) as 'Employees Per Department',DNumberFROM EmployeeGROUP By DNumber;
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 7/12
9. Question 9
SELECT AVG(Salary) as 'Average Salary'FROM EmployeeWHERE Sex = 'M';
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 8/12
SELECT AVG(Salary) as 'Average Salary'
FROM EmployeeWHERE Sex = 'F';
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 9/12
10. Question 10
SELECT COUNT(Sex) as 'Number of Men',DNumberFROM EmployeeWHERE Sex = 'M'GROUP BY DNumber;
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 10/12
SELECT COUNT(Sex) as 'Number of Women',DNumber
FROM EmployeeWHERE Sex = 'F'GROUP BY DNumber;
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala
8/14/2019 CIS 423- Assignment 3- JLBaptiste
http://slidepdf.com/reader/full/cis-423-assignment-3-jlbaptiste 11/12
11.Question 11
SELECT AVG(Salary) as 'Average Salary',DNumberFROM EmployeeGROUP BY DNumber;
Jason L. Baptiste! November 8, 2009
CIS 423! Professor Kadiyala