You are designing a solution for a company that operates retail stores. Each store has a database that tracks sales transactions. You create a summary table in the database at the corporate office. You plan to use the table to record the quantity of each product sold at each store on each day. Managers will use this data to identify reorder levels for products.
Every evening stores, must transmit sales data to the corporate office. The data must be inserted into the summary table that includes the StoreID, ProductID, Qtysold, Totprodsales, and Datesold columns.
You need to prevent duplicate rows in the summary table. Each row must uniquely identify the store that sold the product and the total amount sold for that store on a specific date.
What should you include in your solution?
A . Create a unique constraint.
B . Create a foreign key constraint to the StoreID column in each of the store tables.
C . Create a rule and bind it to the StoreID column.
D . Create a check constraint.
E . Create a table-valued user-defined function.
Answer: A
Explanation:
You can use UNIQUE constraints to make sure that no duplicate values are entered in specific columns that do not participate in a primary key. Although both a UNIQUE constraint and a PRIMARY KEY constraint enforce uniqueness, use a UNIQUE constraint instead of a PRIMARY KEY constraint when you want to enforce the uniqueness of a column, or combination of columns, that is not the primary key.
Incorrect Answers:
D: CHECK constraints enforce domain integrity by limiting the values that are accepted by one or more columns.
References:
https://docs.microsoft.com/en-us/sql/relational-databases/tables/unique-constraints-and-checkconstraints?view=sql-server-2017
Leave a Reply