You are the database developer at ABC.com. ABC.com has a SQL Server 2012 database
infrastructure that has a database named ComDB with a table named Partners.
The Partners table was created using the following Transact-SQL code:
CREATE TABLE [dbo].[Partners]
(
[CompanyID] [int] NOT NULL PRIMARY KEY,
[CompanyName] [varchar] (150) NOT NULL,
[Location] [varchar] (150) NOT NULL,
[ContactName] [varchar] (150) NOT NULL,
[Email] [varchar] (150) NOT NULL,
[Phone] [varchar] (10) NOT NULL
)
You develop a new table named Events using the following Transact-SQL code:
CREATE TABLE [dbo].[Events]
(
[EventID] [int] NOT NULL PRIMARY KEY,
[CompanyID] [int] NOT NULL,
[EventDescription] [varchar] (2500),
[EventCordinator] [varchar] (150) NOT NULL
)
How would you guarantee that values in the Events.CompanyID column already exist in the
Partners.CompanyID column?
A.
You should add a Foreign Key Constraint on the Events table.
B.
You should add a Check Constraint on the Events table.
C.
You should add a Unique Constraint on the Events table.
D.
You should specify Events.CompanyID as a spars column.
E.
You should change the Events table to a partitioned table.
Explanation:
Ref: http://msdn.microsoft.com/en-us/library/ms179610.aspx
?
Answer is A.
alter table Events
add constraint FK_CompanyID
foreign key(CompanyID) References Partners(CompanyID)