In Oracle Database 12c, a PRIMARY KEY constraint is a combination of a NOT NULL constraint and a unique constraint. It ensures that the data contained in a column, or a group of columns, is unique among all the rows in the table and not null. Given the PRODUCT_ID is marked as NOT NULL, it is a candidate for being a primary key because we can assume that it is intended to uniquely identify each product in the table.
[Reference: Oracle 12c documentation states that a column defined with the NOT NULL constraint can be used as a primary key, provided the values in the column are also unique (Oracle Database SQL Language Reference, 12c Release 1 (12.1))., B. EXPIRY_DATE cannot be used in arithmetic expressions. (Incorrect), This statement is not necessarily true. Dates in Oracle can be used in arithmetic expressions, typically to add or subtract days from a date., C. EXPIRY_DATE contains the SYSDATE by default if no date is assigned to it. (Incorrect), Unless explicitly specified, a date column does not default to SYSDATE. A default value must be set using the DEFAULT clause during the table creation or altered later., D. PRODUCT_PRICE can be used in an arithmetic expression even if it has no value stored in it., This is correct. In Oracle, if a numeric column like PRODUCT_PRICE has a NULL value (meaning no value stored in it), it can still be used in an arithmetic expression. In such expressions, NULL is typically treated as a zero, but the result of any arithmetic with NULL is also NULL., Reference: Oracle 12c SQL Language Reference indicates that if you include a numeric column with NULL in an arithmetic expression, the outcome will be NULL, meaning that the operation considers the NULL but does not necessarily treat it as zero (Oracle Database SQL Language Reference, 12c Release 1 (12.1))., E. PRODUCT_PRICE contains the value zero by default if no value is assigned to it. (Incorrect), Unless a default value is explicitly specified during the table creation or altered later, a numeric column like PRODUCT_PRICE does not automatically have a default value of zero., F. PRODUCT_NAME cannot contain duplicate values. (Incorrect), There is no constraint indicated that would prevent PRODUCT_NAME from containing duplicate values. Without a UNIQUE or PRIMARY KEY constraint, a column can contain duplicates., The correct answers are A and D. PRODUCT_ID can be the primary key because it's specified as NOT NULL, thus it can uniquely identify each row in the table. PRODUCT_PRICE can be used in an arithmetic expression with the understanding that if it's NULL, the result of the expression would be NULL as well., ]
Submit