You are a database developer of a Microsoft SQL Server 2012 database. The database contains a table named Customers that has the following definition:
You need to ensure that the CustomerId column in the Orders table contains only values that exist in the CustomerId column of the Customer table.
Which Transact-SQL statement should you use?
A. ALTER TABLE Orders
ADD CONSTRAINT FX_Orders_CustomerID FOREIGN KEY (CustomerId) REFERENCES Customer (CustomerId)
B. ALTER TABLE Customer
ADD CONSTRAINT FK_Customer_CustomerID FOREIGN KEY {CustomerID) REFERENCES Orders (CustomerId)
C. ALTER TABLE Orders
ADD CONSTRAINT CK_Orders_CustomerID
CHECK (CustomerId IN (SELECT CustomerId FROM Customer))
D. ALTER TABLE Customer ADD OrderId INT NOT NULL;
ALTER TABLE Customer
ADD CONSTRAINT FK_Customer_OrderID FOREIGN KEY (OrderID) REFERENCES Orders
(OrderID);
E. ALTER TABLE Orders
ADD CONSTRAINT PK Orders CustomerId PRIMARY KEY (CustomerID)
This question is – as has been the case with so many questions – a total mess.
Intro:-
The database contains a table named Customers that has the following definition:
What follows is a VIEW not a table.
Answers:-
These refer to a Customer Table. The VIEW refers to Dentists, etc.
AGAIN – does anybody check this stuff before posting. AGAIN – not very helpful.