Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
COMPSCI 280 Tutorial 2 Exercises For the purposes of our discussion we will be using the Lunches database on the MYSQL server : Let’s take a look at all the information on the L_EMPLOYEES table: SELECT * FROM L_EMPLOYEES; Looks quite large and cryptic doesn’t it. For starters, if the Sales Manager of this company was only interested in the information on the L_EMPLOYEES table as a contacts list, a lot of columns are unnecessary for example the HIRE_DATE and CREDIT_LIMIT. Add to that the fact that the list is not arranged in alphabetic order of the last name. In other words, while the information on this table is all correct and accurate, it is not presented in the best way to serve the manager. Let’s suppose the Sales manager of this company wants to create a contacts list for all employees who work in the sales department. A) Create a new table called L_CONTACTS that lists the customer’s first name, last name, department code and phone number for all employees. Ensure that results are ordered alphabetically in Ascending order of the surname. B) Why is this a bad way of solving the CEO’s problem? C) Is it ever a good idea to INSERT information into a database that is based on the results of a query from the same database? D) Let’s suppose that Nancy Hoffman has moved from the sales department to the executive department. Update that detail in the L_CONTACTS table. E) Check whether the change you’ve made to Susan’s phone number has been propagated to the L_EMPLOYEES table. F) Let’s delete all records in the L_CONTACTS table whose surname name has a k in it. G) Now let’s create a view called V_CONTACTS for Sales manager that achieves their goal? Ensure that it has the check option. Why is this a good idea? H) Insert the following 2 records into the V_CONTACTS view: 'BRUCE', 'BANNER', 'EXE', '1212' 'BRUCE', 'BANNER', 'SAL', '1212' I) check if the record exists on the L_EMPLOYEES table. J) Add a column called Sex to the L_CONTACTS table Of type VARCHAR(1) K) Change the datatype of Sex to INT. L) Now that we’ve put our heads together and realised it’s a bad idea, let’s go ahead and delete the L_CONTACTS table from the database. M) Copy and paste the code that is the solution to exercise M from the .sql file with solutions to this tutorial to get your database back to it’s original state. N) Primary Keys discussion, if there’s time.