What are the errors in the above query?

Remo works as a Database Designer for Tech Inc. He wants to create a table named Product. He
issues the following query to create the Product table:
CREATE Product (
ProductID Char (10) NOT NULL,
OrderID Char (10) NULL
ProductName Varchar NOT NULL,
Primary key (OrderID, ProductID))
What are the errors in the above query?
Each correct answer represents a complete solution. Choose two.

Remo works as a Database Designer for Tech Inc. He wants to create a table named Product. He
issues the following query to create the Product table:
CREATE Product (
ProductID Char (10) NOT NULL,
OrderID Char (10) NULL
ProductName Varchar NOT NULL,
Primary key (OrderID, ProductID))
What are the errors in the above query?
Each correct answer represents a complete solution. Choose two.

A.
An attribute declared as a primary key cannot contain NULL values.

B.
Each attribute should be defined as a primary key separately.

C.
A table cannot have two primary keys.

D.
ProductName is declared as Varchar without specifying the width of the column.

Explanation:
When a column is declared as Varchar, it is mandatory to declare the maximum width of the column.
The OrderID and ProductID columns are declared as the composite primary key attribute. Therefore,
neither ProductID nor OrderID can contain
NULL values, whereas in the declaration of OrderID, it is not specified as NOT NULL. Therefore, both
answer options D and A are responsible
for introducing errors in the query.



Leave a Reply 1

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


Lena

Lena

B and C are incorrect bc table can have composite pk