Which code segment or segments should you add at line 27 of Tables.sql?

###BeginCaseStudy###
Case Study: 3

Scenario 3
Application Information
You have two servers named SQL1 and SQL2. SQL1 has SQL Server 2012 Enterprise
installed. SQL2 has SQL Server 2008 Standard installed.
You have an application that is used to manage employees and office space.
Users report that the application has many errors and is very slow.
You are updating the application to resolve the issues.
You plan to create a new database on SQL1 to support the application. The script that you
plan to use to create the tables for the new database is shown in Tables.sql. The script that
you plan to use to create the stored procedures for the new database is shown in
StoredProcedures.sql. The script that you plan to use to create the indexes for the new
database is shown in Indexes.sql.
A database named DB2 resides on SQL2. DB2 has a table named EmployeeAudit that will
audit changes to a table named Employees.
A stored procedure named usp_UpdateEmployeeName will be executed only by other stored
procedures. The stored procedures executing usp_UpdateEmp!oyeeName will always handle
transactions.
A stored procedure named usp_SelectEmployeesByName will be used to retrieve the names
of employees. Usp_SelectEmployeesByName can read uncommitted data.
A stored procedure named usp_GetFutureOfficeAssignments will be used to retrieve office
assignments that will occur in the future.
StoredProcedures.sql

Indexes.sql

Tables.sql


###EndCaseStudy###

You need to provide referential integrity between the Offices table and Employees table.
Which code segment or segments should you add at line 27 of Tables.sql? (Each correct
answer presents part of the solution. Choose all that apply.)

###BeginCaseStudy###
Case Study: 3

Scenario 3
Application Information
You have two servers named SQL1 and SQL2. SQL1 has SQL Server 2012 Enterprise
installed. SQL2 has SQL Server 2008 Standard installed.
You have an application that is used to manage employees and office space.
Users report that the application has many errors and is very slow.
You are updating the application to resolve the issues.
You plan to create a new database on SQL1 to support the application. The script that you
plan to use to create the tables for the new database is shown in Tables.sql. The script that
you plan to use to create the stored procedures for the new database is shown in
StoredProcedures.sql. The script that you plan to use to create the indexes for the new
database is shown in Indexes.sql.
A database named DB2 resides on SQL2. DB2 has a table named EmployeeAudit that will
audit changes to a table named Employees.
A stored procedure named usp_UpdateEmployeeName will be executed only by other stored
procedures. The stored procedures executing usp_UpdateEmp!oyeeName will always handle
transactions.
A stored procedure named usp_SelectEmployeesByName will be used to retrieve the names
of employees. Usp_SelectEmployeesByName can read uncommitted data.
A stored procedure named usp_GetFutureOfficeAssignments will be used to retrieve office
assignments that will occur in the future.
StoredProcedures.sql

Indexes.sql

Tables.sql


###EndCaseStudy###

You need to provide referential integrity between the Offices table and Employees table.
Which code segment or segments should you add at line 27 of Tables.sql? (Each correct
answer presents part of the solution. Choose all that apply.)

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
http://msdn.microsoft.com/en-us/library/ms189049.aspx



Leave a Reply 5

Your email address will not be published. Required fields are marked *


MickBig

MickBig

C and D are correct. Each EmployeeID needs to be unique, hence you do C to give it a Primary Key.

The Office table then needs the EmployeeID column to reference the EmployeeID PK in the Employees table.

mickeyW

mickeyW

If D would be right, you would have to demolish the Office if you want to fire the Employee, because there is a not null constraint for the employeeId column in the office Table.

chintu

chintu

Don’t need to demolish the office please. Just update it with new employee number. 🙂

Ben

Ben

what’s the answer please?

Kevin

Kevin

— Create the primary key constraint
ALTER TABLE dbo.Employees ADD CONSTRAINT
PK_Employees_EmployeeID PRIMARY KEY (EmployeeID);

— Then create the foreign key constraint
ALTER TABLE dbo.Offices ADD CONSTRAINT
FK_Offices_Employees FOREIGN KEY (EmployeeID)
REFERENCES dbo.Employees (EmployeeID);