[SOLVED] CSIS 325 – Lab 5 Insert, Update, Delete (DML) Instructions

Before beginning this lab, run the following script in the SQL Server query window.  If you have already created a database called “hourglass”, be sure to drop the database before running these queries.

create database hourglass

Struggling to find relevant content? Order a custom essay on
[SOLVED] CSIS 325 – Lab 5 Insert, Update, Delete (DML) Instructions
Let our experts save you the hassle
Order Now

go use hourglass

go

CREATE TABLE Regions

(RegionID int not null,

RegionName varchar(40),

CONSTRAINT PK_Regions PRIMARY KEY (RegionID));

 

CREATE TABLE Countries

(CountryID int not null,

CountryName varchar(50),

RegionID int not null,

CONSTRAINT PK_Countries PRIMARY KEY (CountryID),

CONSTRAINT FK_CountriesRegions FOREIGN KEY (RegionID) References Regions);

 

CREATE TABLE Offices

(OfficeID int,

OfficeName varchar(50),

CountryID int not null,

CONSTRAINT pk_Offices PRIMARY KEY (OfficeID),

CONSTRAINT fk_Offices_Countries FOREIGN KEY (CountryID) REFERENCES Countries)

 

CREATE TABLE Employees

(EmpID int,

FirstName varchar(30),

LastName varchar(50),

Email varchar(50),

Salary decimal(10, 2),

OfficeID int not null,

SupervisorID int,

CONSTRAINT pk_Employees PRIMARY KEY (EmpID),

CONSTRAINT fk_Employees_Offices FOREIGN KEY (OfficeID) REFERENCES Offices,

CONSTRAINT fk_Employees_Employees FOREIGN KEY (SupervisorID) REFERENCES Employees)

 

CREATE TABLE Clients

(ClientID int,

LegalName varchar(100),

ClientName varchar(50),

CountryID int not null,

CONSTRAINT pk_Clients PRIMARY KEY (ClientID),

CONSTRAINT fk_Clients_Countries FOREIGN KEY (CountryID) REFERENCES Countries)

 

CREATE TABLE ContractTypes

(ContractTypeID int not null,

ContractTypeName varchar(50),

CONSTRAINT pk_ContractTypes PRIMARY KEY (ContractTypeID))

 

CREATE TABLE Contracts

(ContractID int not null,

ContractDesc varchar(100),

ClientID int not null,

ContractTypeID int not null,

CONSTRAINT PK_Contracts PRIMARY KEY (ContractID),

CONSTRAINT FK_ContractsClients FOREIGN KEY (ClientID) REFERENCES Clients,

CONSTRAINT FK_ContractsContractTypes FOREIGN KEY (ContractTypeID) REFERENCES ContractTypes)

 

CREATE TABLE Projects

(ProjectID int,

ProjectName varchar(100),

ManagerID int not null,

ContractID int not null,

CONSTRAINT pk_Projects PRIMARY KEY (ProjectID),

CONSTRAINT fk_Projects_Employees FOREIGN KEY (ManagerID) REFERENCES Employees,

CONSTRAINT fk_Projects_Contracts FOREIGN KEY (ContractID) REFERENCES Contracts)

 

CREATE TABLE EmployeeProjectAssignments

(ProjectID int,

EmpID int,

StartDate smalldatetime,

EndDate smalldatetime,

CONSTRAINT pk_EmployeeProjectAssignments PRIMARY KEY (ProjectID, EmpID),

CONSTRAINT fk_EmployeeProjectAssignments_Projects FOREIGN KEY (ProjectID) REFERENCES Projects,

CONSTRAINT fk_EmployeeProjectAssignments_Employees FOREIGN KEY (EmpID) REFERENCES Employees)

 

CREATE TABLE WorkHours

(ProjectID int,

EmpID int,

Day int,

Month int,

Year int,

HoursWorked float,

CONSTRAINT pk_WorkHours PRIMARY KEY (ProjectID, EmpID, Day, Month, Year),

CONSTRAINT fk_WorkHours_Projects FOREIGN KEY (ProjectID) REFERENCES Projects,

CONSTRAINT fk_WorkHours_Employees FOREIGN KEY (EmpID) REFERENCES Employees)

Deliverables:

Part 1:

Given the worksheets in the “Lab 5 Insert Update Delete (DML) – Data.xls” file, populate the tables you created above using SQL Insert statements.  Note that there are multiple sheets in this workbook.  Each sheet contains data for a separate table.

You may find it easier to create formulas in your Excel file to generate “insert” statements and then paste those queries into a sql script file.  Conversely, you may find it easier to pull the data from Excel into Microsoft Access and import it directly into SQL Server using ODBC.  To use this latter technique, refer to the “How to Import Data from Access to SQL Server” document in your lab folder.

Once the data are loaded, execute the following SELECT statements in SQL Server and paste a screenshot of your results below each SELECT query.  Make sure your screenshot includes the bottom status bar in the query results window that indicates the number of rows displayed.

 

Select * from Regions

Select * from Countries

Select * from Offices

Select * from Employees

Select * from ContractTypes

Select * from Clients

Select * from Contracts

Select * from Projects

Select * from EmployeeProjectAssignments

Select * from Workhours

 

For example:

Part 2:

Write and execute the queries below in SQL Server.  Take a screenshot of your query as well as the query results and paste it below each question.

  1. Write and execute a query that will change the name of United Kingdom to Great Britain in the Countries table.
  2. Write and execute a query that will increase every employee’s salary by 10%.
  3. Write and execute a query that will change the contract type of every “Time and Materials” contract to “Fixed Price”.
  4. Write and execute queries to delete the employee Paul Davis. [Note that before you remove him from the Employees table, you will need to remove his records from any other tables that refer to his ID.] You may use a separate query for each table that requires removal of Paul Davis’s records, but only one query per table should be used.  That is, if he has multiple records in the EmployeeProjectAssignments table, only one query should be used to remove all of his records in that table.  You may also need to reassign any of the projects that he manages before you can delete him.  That is, if Paul Davis manages any projects, reassign those projects to Matthew Smith.  Do this in a single query as well.  Write each query below that you used to remove Paul Davis from the database and then execute this Select statement:

 

Select * from employees where firstname = ‘Paul’ and lastname = ‘Davis’

 

Take a screenshot of the results of this query and paste it below, as well.

  1. Write and execute a query that will reassign all employees in the Cambridge office to the Denver office.
  2. Write and execute a query that will end the employee project assignment for Mark Jones and the DT Work Order – Customization project. Give the row an end date of August 1, 2017.
  3. Write and execute a query that will remove the contract type “Time and Materials” from the ContractTypes table.

Related: CSIS 325 – Lab 4 (SQL CREATE TABLE)

  1. Write and execute a query that will delete all countries that are not assigned to an office or a client.

You must do this in a single query to receive credit for this question. 

Write the delete query below and then execute the following statement in SQL Server:

Select * from Countries.

Take a screenshot of your select query results and paste them below your delete query that you constructed.

do my homework

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
Sign up, place your order, and leave the rest to our professional paper writers in less than 2 minutes.
step 1
Upload assignment instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
s
Get personalized services with GPA Fix
One writer for all your papers
You can select one writer for all your papers. This option enhances the consistency in the quality of your assignments. Select your preferred writer from the list of writers who have handledf your previous assignments
Same paper from different writers
Are you ordering the same assignment for a friend? You can get the same paper from different writers. The goal is to produce 100% unique and original papers
Copy of sources used
Our homework writers will provide you with copies of sources used on your request. Just add the option when plaing your order
What our partners say about us
We appreciate every review and are always looking for ways to grow. See what other students think about our do my paper service.
Professions and Applied Sciences
Thank you!
Customer 452707, March 4th, 2022
Nursing
Thank you!
Customer 452707, October 16th, 2022
Strategic Management
Thank you very much for the help, really appreciate it
Customer 452821, June 27th, 2022
Social Work and Human Services
Awesome, Work! Didn't have to add much to it. Thank You!
Customer 452587, September 7th, 2021
Finance
Thank You
Customer 452643, October 24th, 2021
Human Resources Management (HRM)
Dynamic!!
Customer 452701, October 17th, 2023
Nursing
The writer went above and beyond as usual. Always a great experience with these writers.
Customer 452707, December 4th, 2022
Web programming
outstanding!
Customer 452715, September 16th, 2022
English 101
Although a little late, the content and structure of the paper was great! I would definitely use this writer again!
Customer 452561, July 12th, 2021
Social Work and Human Services
Excellent
Customer 452587, July 28th, 2021
Education
Great
Customer 452813, June 29th, 2023
Criminal Justice
always great!
Customer 452465, February 23rd, 2021
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat

Good News ! We now help with PROCTORED EXAM. Chat with a support agent for more information