You wish to create a user-defined data type that will be used whenever a person’s name must be stored.. Answer B is correct because it uses the nvarchar, which allows Unicode characters,
Trang 1130 Appendix • Self Test Appendix
Incorrect Answers & Explanations: A, C, D Answer A is incorrect because this
CHECK constraint checks that the OrderDate is greater than (occurs after)
the Ship Date Answers C and D are incorrect because triggers will not deliver
the performance of a CHECK constraint.
18 You always allow 50 Unicode characters for names of people, and you never allow names to be null You wish to create a user-defined data type that will be used whenever a person’s name must be stored How should you create the data type?
A CREATE TYPE PersonName { FROM varchar(50) NOT NULL }
B CREATE TYPE PersonName { FROM nvarchar(50) NOT NULL }
C CREATE TYPE PersonName { FOR varchar(50) NOT NULL }
D CREATE TYPE PersonName { FROM nvarchar(50)}
Correct Answer & Explanation: B Answer B is correct because it uses the nvarchar, which allows Unicode characters, limits the length to 50, and declares
the type as not NULL.
Incorrect Answers & Explanations: A, C, D Answer A is incorrect because the varchar data type cannot store Unicode characters Answer C is incorrect
because you must define a data type with the FROM keyword, not the FOR
keyword Answer D is incorrect because by default this data type will allow
NULL values.
19 In your database system, you must frequently convert from EURO currency to USD currency, using the exchange rate stored in the ExchangeRates table What is the best way to achieve this?
A Create a function that accepts an @EURAmount parameter and returns the USD value
B Create a stored procedure that accepts an @EURAmount parameter and
selects the USD value using the SELECT statement.
C Create a view that accepts an @EURAmount parameter and selects the USD value
D Create a stored procedure that accepts an @EURAmount parameter and
returns the USD value using the SELECT statement.
Correct Answer & Explanation: A Answer A is correct because the use of
a function is best suited to performing a calculation and returning a value
Trang 2Self Test Appendix • Appendix 131
Incorrect Answers & Explanations: B, C, D Answers C and D are incorrect
because stored procedures should be used to perform actions, not calculations
Answer B is incorrect because views cannot accept parameters
20 You wish to add a new column to an existing view object What are some of
the ways to do this? (Select all that apply)
A Use Visual Studio object designer
B Use the SQL Management Studio object designer
C Use the ALTER VIEW statement.
D Use the ALTER COLUMN statement.
Correct Answer & Explanation: B, C Answers B and C are correct because
both of these methods can be used to change the view
Incorrect Answers & Explanations: A, D Answer A is incorrect because Visual
Studio is a development tool, not a database administration tool Answer D
is incorrect because ALTER COLUMN is used with tables, not views.