Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is all one thing that cannot be broken up. Please help with this one database. Thanks 1. Create a new user (as yourself or

This is all one thing that cannot be broken up. Please help with this one database. Thanks

1. Create a new user (as yourself or favorite movie character) by inserting into the users table. As the userId is a varchar, choose a random, but unique value (Like abc123). Be sure to populate ALL columns except the createdDate column. Paste the SQL statement below.

2. Write a SQL statement to return the new user (all columns) by filtering on the username. To filter with a select statement, use a where clause. Paste the SQL statement & results below. Remember, pasting the results is 50% of the credit.

3. Write SQL to create 2 emails and 2 phone numbers for the new user. This requires 4 insert statements, 2 inserts into the userEmail table and 2 into the userPhone table. Use the same userId as the user created in question 1. Paste the SQL below.

4. Write a SQL statement to select the user and their emails. Filter on userId. Select the following columns: userId, lastname, firstname, and userEmail This requires a join. Paste the SQL below.

5. Write a SQL statement to select the new user and their phone numbers with the phone type. Filter on userId. This requires 2 joins. Select the following columns: userId, lastname, firstname, userPhone and userPhoneType. Hint: You will need to join 3 tables together. Paste the SQL below.

6. Create 2 new orders for the user created in question 1 by inserting into the orders and orderItem tables (twice). Place at least 1 item per order. Create a new order first, then use that orderId to insert into the orderItem table. In total youll need 4 insert statements. Paste the SQL statement below.

7. Assign 2 vehicles to the new user created in question 1. Paste the SQL statement below.

8. Write a SQL statement to update the new users last name. Only update 1 user by filtering on userId field. Paste the SQL statement below.

9. Write SQL to delete 1 phone from the new user. Only delete 1 row from the userPhone table by filtering on the correct fields. Paste the SQL statement below.

10. Write a SQL statement to update your new users occupation to Computer Software Engineers. Remember, you need to lookup the occupationId in the occupation table, then update the users table correctly. Paste the SQL statement below.

11. Create a new user type called: Totally Awesome. Paste the SQL statement below. Paste the SQL statement below.

12. Update your new user to the new userTypeId created in the previous question. Remember, users are related to a type through the userType table. Paste the SQL statement below.

13. Write a SQL statement to return all users and orders if available. When joining the 2 tables, be sure to choose the correct type of join. Paste SQL statement and the first 10 records below. (2pt)

14. Write a SQL statement to return all users (userId, firstname, lastname) who have not placed an order. Again, when joining the users and order tables, choose the correct join Paste the SQL statement below.

15. Alter the order table to add a column called destinationState. Paste the alter table SQL statement below. Then populate the destinationState column for the existing orders. Ex: update orders set destinationState = FL; Paste the SQL statements below.

16. Create a foreign key between the tables, state and orders. IE: From table states, column state to table order table, column destinationState. FK always point at a FK. Paste the SQL (alter table) statement below.

17. Select all users who have a lastname of Steady and display their full name as a single field. Paste SQL below and the time the query ran. Paste the SQL statements below.

18. Create an index on the last name column for the users table. (A non-unique index, not unique). Paste the SQL statements below.

19. Select the count of all users with a first name starting with J and who are employed. Users who have an occupation of NULL are considered unemployed. Paste SQL and results below.

20. Take a SQL Dump of your example database. Zip the SQL file.

upload this document and your zipped SQL Dump file

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago