Starting from:
$35

$29

Assignment 2 SQL CRUD Solution

Directions: For each question, write a SQL query that corresponds to each question.




Turning In: Please submit a single .sql file with the answer to each question. You can do this in DBVis or in a text editor of your choice. Make sure your queries run correctly and produce the desired result. The solution to each question should be structured like so:

EXAMPLE QUESTION #1: How many records does this table have in it?

EXAMPLE SOLUTION:

--solution for question #1

--this query selects the count of all records in <table_name_here

SELECT COUNT(*)

FROM <table_name_here;




If a solution requires multiple queries, make sure to put a comment on top of each query to explain what it does.




Other notes: I encourage you to work together with your peers to get problems solved, but your work must be your own (aka, don’t copy and paste someone else’s code). Please include any references you used to complete this assignment (including other students) in a comment section at the top of your .sql file.




Create a table called Customers with the following structure:
Customer ID – this is a primary key

Customer first name

Customer last name

Customer age




Insert 3 full customer records into the table



You gain a new customer but only know their first name is Jim, and their last name is Terf. Insert this customer into your table - don’t forget to give him a primary key



Update all customer’s names to be upper case



Create a table called Customer_Address with the following structure:
Customer ID – this is a foreign key to the Customers table

Street number

Street name

City

State

Zip




Insert an address for each of the customers you made in step 2 – make sure to adhere to foreign key rules



Update Jim Terf’s customer ID to be something different



Delete one of the records you made in step 2.

More products