Use SQL Management Studio to create a database called ITCO630_P1.MDF. Be sure to
ID: 3714207 • Letter: U
Question
Use SQL Management Studio to create a database called ITCO630_P1.MDF. Be sure to store the database in a location that you will remember. Add the following tables and data to the database. Use the appropriate field types and lengths for the tables.
Create the following queries and save them all in a file called ITCO630_P1.SQL. Please note that you can execute individual queries in a query file by highlighting the lines that you want to execute before running the script. Define what database to use with a USE statement.
Get the full details of the employee table.
Get the full details of the employees who work in store S2.
Get the full details of the promotions with a budget greater than $100,000.
Get the employee number and promotion number for employees with unknown (NULL) jobs who work on promotion P2.
Using a subquery, get the first and last names of the employees who work in the Orange Appeal store.
Using a subquery, get full details of all the employees whose stores are located in Orlando.
Detach the database and create a zip file called ITCO630_P1.ZIP including the associated log file and the query file. After creating the zip file, reattach the database.
- store no S1 S2 S3 store name Orange Appeal | Rocky Mountain Produce Baked Bean Bonanza city Orlando Denver Orlando store.no Employee Table employee no 25348 10102 18316 29346 90316 25813 28559 employee fname Jerry June Randy Jimmy Edith Louise Sandy employee Iname | Dors ett Carter Houston Estes | Hart | Branch Mulland 48 844 Promotion Table promotion no P1 P2 P3 promotion name | Spring Bonanza Harvest Ball Winter Wonderland budget 120,000 95,000 185,000 - promotion no Summary Table employee no 10102 10102 25348 18316 29346 25813 90316 28559 28559 90316 29346 job Designer Manager Stocker NULL NULL Designer Manager NULL Stocker Stocker Stocker start date 10/1/2005 1/1/2006 2/15/2005 | 6/1/2005 11/15/2004 10/15/2005 4/15/2005 8/1/2005 2/1/2006 11/15/2004 1/4/2005Explanation / Answer
// Command to use database ITC)630_P1.MDF
USE ITCO630_P1.MDF;
1) The query will select all the details of the employee. '*' is used to get all the columns.
SELECT * FROM Employee;
2) This query will result the detail of employee who work in store_no S2. Where clause is used to filter result based on store_no.
SELECT * FROM Employee
WHERE store_no = 'S2';
3) This query will result in all the details of the promotion with budget greater than $100,00.
SELECT * FROM Promotion
WHERE budget > 100,000;
4) This will result in employee_no and promotion_no of those employee whose job is NULL and promotion_no is P2.
SELECT employee_no, promotion_no
FROM Summary
WHERE job IS NULL AND promotion_no = 'P2';
5) THis will result in employee first name and last name who work in store 'Orange Appeal'. Subquery is used to get the store_no of Orange Appeal.
SELECT employee_fname, employee_lname
FROM Employee
WHERE store_no = (SELECT store_no FROM Store WHERE store_name = 'Orange Appeal');
6) This will result in all the employee detail whose store is located in city Orlando.
SELECT *
FROM Employee
WHERE store_no IN (SELECT store_no FROM Store WHERE city = 'Orlando');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.