Question

Microsoft SQL Server Management Studio 1. Write SQL statements to insert, update, and delete a record...

Microsoft SQL Server Management Studio

1. Write SQL statements to insert, update, and delete a record in each of the Clients, Assist, Task, Outreach, and Specialist tables. Finish by inserting records into the tables (sample data follows). 5 points

2. Write Select statements to organize data from different tables. 4 points each

  • Select all clients who have had an assist; include client name, assist date and type.
  • List all assists including the name of the Specialist.
  • List client names having tasks needing follow up.
  • List all clients having an assist in 2003; include client name and specialist name in the result.
  • List all clients having an open assist; include client name, assist date and type, and specialist name in the result.

Copy the SQL statements from #1 and #2 into a Word document and submit to Canvas.

Sample Data

Clients

First

Last

Message Phone

Home Phone

Street*

City*

State*

Zip*

Terry

Bradshaw

3603333333

3603333333

303 4th

Olympia

WA

98501

Sam

Jones

3605545555

1525 Pacific

Olympia

WA

98501

Ginger

Baker

3608787878

3608787877

Sarah

Hughes

3604443333

8702 54th

Lacey

WA

Lovey

Howell

3607777777

3607777755

4226 X St.

Tumwater

WA

98501

*residence address

Specialists

First

Last

Title

BB

King

Specialist II

Ann

Wilson

Specialist I

Assists

Client

Open

Close

Specialist

Type

Referral

Ref. Phone

Confidential

3

10/2/04

12/12/04

1

Counseling

Dr. Jones

Yes

3

10/5/04

10/5/04

1

Referral

Dr. Barnes

No

4

11/21/04

1/6/05

1

Forms assistance

4

11/10/04

12/7/04

1

Counseling

3

12/1/04

12/1/04

2

Referral

3

12/18/04

2

Dr. Eligibility

4

12/8/04

1/10/05

2

Forms Assistance

Dr. Jason

3605555555

3

12/15/04

12/18/04

2

Counseling

1

12/12/04

1

Referral

DSHS

No

1

12/29/04

1/29/05

1

Advocacy

2

12/27/04

1/15/05

1

Dr. Eligibility

Tasks

Assist

Date

Followup

Activity

Status

2

10/05/04

Phone call

Complete

3

12/15/04

Phone call

Complete

4

12/1/04

Yes

Phone call

6

12/1/04

Letter

Complete

6

12/6/04

Phone call

Complete

7

1/5/05

Yes

Letter

10

1/4/05

Yes

Letter

Homework Answers

Answer #1

Consideration : Given tables have no proper mapping among each other so we can not use different join apart from Cartesian Join so i have used Cartesian Join only in the SQL queries .

Question 1 :

Write SQL statements to insert, update, and delete a record in each of the Clients, Assist, Task, Outreach, and Specialist tables. Finish by inserting records into the tables (sample data follows).

Query :  

(a) Insert , Update and Delete queries for Clients Table

INSERT INTO Clients (First, Last, Message_Phone, Home_Phone , 
Street , City , S )
VALUES ('Terry','Bradshaw',3603333333 ,3603333333,'303 4th','Olympia','W' ); 

UPDATE Clients
SET First = 'Alfred', 
WHERE Message_Phone=3603333333 ;

DELETE FROM Clients WHERE First='Terry';

(b) Insert , Update and Delete queries for Assists table


INSERT INTO Assists (Client, Open, Close, SpecialistType ,Referral , Ref.Phone , Confidential )
VALUES (3 , '10/2/04', '12/12/04' , 1 , 'Counseling','Dr.Jones',3605555555,'Yes' );

UPDATE Assists
SET SpecialistType = 'Regerral', 
WHERE Close='12/12/04' ;

DELETE FROM Assists WHERE Close='12/12/04';

(c) Insert , Update and Delete queries for Specialist table

INSERT INTO Specialist (First, Last, Title)
VALUES ('BB','King','Specialist II'); 

UPDATE Specialist
SET First = 'Wilson', 
WHERE First='BB';

DELETE FROM Specialist WHERE First='BB';

(c) Insert , Update and Delete queries for Task table

INSERT INTO Tasks(Assist, Date, Followup, Activity, Status)
VALUES (2, '10/05/04',NULL , 'Phone call','Complete'); 

UPDATE Tasks
SET Followup = 'No', 
WHERE Date='10/05/04';

DELETE FROM Task WHERE Date='10/05/04';

Question 2 :

(a) Select all clients who have had an assist; include client name, assist date and type.

SELECT 
          Clients.First ,
      Clients.Last ,
      Assists.Open ,
      Assists.Close 
      FROM Assists ,Clients where Assists.Client=(SELECT Client FROM Assists);

(b) List all assists including the name of the Specialist.

SELECT * ,
        Specialists.First ,
        Specialists.Last 
        FROM Assists , Specialists ;

(c) List client names having tasks needing follow up.

SELECT 
        Clients.First,
        Clients.Last,
        FROM Assists JOIN Tasks ON (Assits.Open = Tasks.Date) , Clients ;

(d) List all clients having an assist in 2003; include client name and specialist name in the result.

        SELECT 
                Clients.First , 
            Clients.Last ,
            Specialists.First ,
            Specialists.Last 
            FROM Clinents , Specialists , Assists WHERE 
            YEAR(Assists.Open) = 03 ;

(e) List all clients having an open assist; include client name, assist date and type, and specialist name in the result.

SELECT 
                Client.First ,
        Client.Last ,
        Assists.Open ,
        Assists.SpecialistType,
        Specialists.First ,
        Specialists.Last 
        FROM Clients , Specialists , Assists ;

Hope you got your answer !

if you still have any doubts please let me know in comment box . Thanks ! happy learning ;)  

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the...
***This is a complete question. Do not tag this as incomplete. Write SQL queries to the below Relational Database. • Regarding the SQL queries: • Do not use SELECT * in any query. • Do not use any SQL features (including Nullif) that were not covered in this course. • Do not use subqueries IF joins can be used to answer a question. However, some questions may require the use of subqueries. The Movie Database Notes: TheaterNum, MovieNum, and ActorNum...
Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables: OWNER...
Garden Glory Project Questions Assume that Garden Glory designs a database with the following tables: OWNER (OwnerID, OwnerName, OwnerEmail, OwnerType) OWNED_PROPERTY (PropertyID, PropertyName, PropertyType, Street, City, State, Zip, OwnerID) GG_SERVICE (ServiceID, ServiceDescription, CostPerHour); EMPLOYEE (EmployeeID, LastName, FirstName, CellPhone, ExperienceLevel) PROPERTY_SERVICE ( PropertyServiceID , PropertyID , ServiceID, ServiceDate , EmployeeID, HoursWorked) The referential integrity constraints are: OwnerID in OWNED_PROPERTY must exist in OwnerID in OWNER PropertyID in PROPERTY_SERVICE must exist in PropertyID in OWNED_PROPERTY ServiceID in PROPERTY_SERVICE must exist in ServiceID...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment...
Question 1: Group by and Aggregates: Write SQL statements to answer the following questions using Assignment 4’s schema (Customer-Invoice-Line-Product-Vendor). Make sure that your SQL script runs without any errors. Submit your answers in a .SQL file. 1 (2 Points) - Find the count of distinctvendors thatsupplied products that are priced lowerthan 185? 2 (2 Points) - For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product description and product...
SQL Write the queries necessary to obtain the required information 1) Use sub query and “in”...
SQL Write the queries necessary to obtain the required information 1) Use sub query and “in” keyword to print the salesreps (ids) who have taken order for the companies ‘Zetacorp’ or ‘JCP Inc.’ . Duplicate rows are not allowed 2) Use sub query to find the id and the name of every sales rep that represents at least one customer with a credit limit of greater than $5000. 3) Use sub query and keyword “exists” to list the id and...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first...
using mysql lyrics.database. i will provide the lyrics schema database info below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in...
Q1. Use Union statements to show the following: list the number of artists that have a...
Q1. Use Union statements to show the following: list the number of artists that have a webaddress, the number of artists that do not have a webaddress, and the total number of artists. The output should look like: +--------------------------+----------+ | Has webaddress | count(*) | +--------------------------+----------+ | Has webaddress | 5 | | Does not have webaddress | 6 | | Total | 11 | +--------------------------+----------+ Q2. A new salesperson has been hired. Their SalesID is 5, full name is...