MIS 562 Week 4 Homework Assignment NEW
MIS 562 Week 4 Homework Assignment NEW
Using the tables created in week 2:
Question ( 4 pts per question)
1. Show a list of all employee names and their department names and the employees for each department. Be sure to show all departments whether there is an employee in the department or not. Use an outer join.
2. Select all employee names and their department names. Be sure to show all employees whether they are assigned to a department or not. Use an outer join.
Using the student schema:
Question ( 3 pts per question)
3. Write a query that that performs an inner join of the grade, student, and grade_type tables using ANSI SQL 99 syntax.
4. Write a query that that performs an inner join of the grade, student, and grade_type tables using the Oracle inner join convention.
5. List all the zip codes in the ZIPCODE table that are not used in the STUDENT or INSTRUCTOR tables. Use a set operator.
6. Write a SQL statement using a set operator to show which students enrolled in a section that are not enrolled in any classes. Exclude students with student id less than 300.
Question ( 5 pts per question)
1. Write and execute two INSERT statements to insert rows into the ZIPCODE table for the following two cities of your choice. After your INSERT statements are successful, make the changes permanent.
2. Create a sequence called STUDENT_ID_NEW that begins with 900 and increments by 1. If the sequence already exists, drop the sequence and recreate it.
3. Make yourself a student by writing and executing an INSERT statement to insert a row into the STUDENT table with data about you. Use one of the zip codes you inserted in Exercise 1. Only insert values into the columns STUDENT_ID using the sequence you created in step 2, FIRST_NAME, LAST_NAME, ZIP, REGISTRATION_DATE (use a date that is five days after today), CREATED_BY, CREATED_DATE, MODIFIED_BY, and MODIFIED_DATE. Issue a COMMIT command afterwards.
4. Write an UPDATE statement to update the data about you in the STUDENT table. Update the columns SALUTATION, STREET_ADDRESS, PHONE, and EMPLOYER. Be sure to also update the MODIFIED_DATE column and make the changes permanent
5. Delete the row in the STUDENT table and the two rows in the ZIPCODE table you created. Be sure to issue a COMMIT command afterwards
6. Create a table called TEMP_STUDENT with the following columns and constraints: a column STUDID for student ID that is NOT NULL and is the primary key, a column FIRST_NAME for student first name; a column LAST_NAME for student last name, a column ZIP that is a foreign key to the ZIP column in the ZIPCODE table, a column REGISTRATION_DATE that is NOT NULL and has a CHECK constraint to restrict the registration date to dates after January 1st, 2000.
7. Write an INSERT statement violating at least two of the constraints for the TEMP_STUDENT table you just created.
8. Write another INSERT statement that succeeds when executed, and commit your work.
9. Alter the TEMP_STUDENT table to add two more columns called EMPLOYER and EMPLOYER_ZIP. The EMPLOYER_ZIP column should have a foreign key constraint referencing the ZIP column of the ZIPCODE table. Update the EMPLOYER column.
10. Alter the table once again to make the EMPLOYER column NOT NULL.
11. Write a statement that drops the EMPLOYER_ZIP column.
12. Drop the TEMP_STUDENT table once you're done with the exercise.
13. Create a non unique index called crse_modified_by_i on the MODIFIED_BY column of the course table
14. Change the registration date of Paula Valentine to today’s date. Create a view called CURRENT_REGS reflecting all students that registered today. (You will need to execute this query in question 6 on the same day you change the date)
15. Create a view called roster reflecting all students taught by the instructor Marilyn Frantzen. Query the view.
16. Given the MY_EMPLOYEE view, what information is the user allowed to retrieve? Who can update the SALARY column through the view? Hint: The USER function returns the name of the currently logged in user.