Halaman

Thursday, August 8, 2019

Answer Sections 14 Quiz Database Programming with SQL 2019 Learner - English



Section 14 

Foreign Key Constraints are also known as:         
                                                                               
                                               
                Parental Key Constraints

                                               
                Child Key Constraints

                                               
                Multi-Table Constraints

                                               
                Referential Integrity Constraints (*)

                                                                               
Which line of the following code will cause an error:
CREATE TABLE clients
(client_number NUMBER(4) CONSTRAINT client_client_num_pk PRIMARY KEY,
first_name VARCHAR2(14),
last_name VARCHAR2(13),
hire_date DATE CONSTRAINT emp_min_hire_date CHECK (hire_date < SYSDATE),
department_id NUMBER(4),
CONSTRAINT clients_dept_id_fk FOREIGN KEY(department_id) REFERENCES departments(department_id));
                                                                               
                                               
                Line 2

                                               
                Line 3

                                               
                Line 5 (*)

                                               
                Line 7

                                                                               
If a Primary Key is made up of more than one column, one of the columns can be null. True or False?                
                                               
                True

                                               
                False (*)

                                                                               
Which of the following best describes the function of a CHECK constraint?          
                                                                               
                                               
                A CHECK constraint defines restrictions on the values that can be entered in a column or combination of columns. (*)

                                               
                A CHECK constraint is created automatically when a PRIMARY KEY constraint is created.

                                               
                A CHECK constraint enforces referential data integrity.

                                               
                A CHECK constraint enforces uniqueness of the values that can be entered in a column or combination of columns.

                                                                               
A composite primary key may only be defined at the table level. True or False?                                                           
                                               
                True (*)

                                               
                False

A table must have at least one not null constraint and one unique constraint. True or False?      
                                                                               
                                               
                True

                                               
                False (*)

                                                                               
Which of the following is not a valid Oracle constraint type?        
                                                                               
                                               
                EXTERNAL KEY (*)

                                               
                UNIQUE KEY

                                               
                PRIMARY KEY

                                               
                NOT NULL

                                                                               
If the employees table has a UNIQUE constraint on the DEPARTMENT_ID column, we can only have one employee per department. True or False?                                                                       
                                               
                True (*)

                                               
                False

                                                                               
Evaluate this CREATE TABLE statement:
CREATE TABLE customers
    (customer_id NUMBER,
     customer_name VARCHAR2(25),
     address VARCHAR2(25),
     city VARCHAR2(25),
     region VARCHAR2(25),
     postal_code VARCHAR2(11),
     CONSTRAINT customer_id_un UNIQUE(customer_id),
     CONSTRAINT customer_name_nn NOT NULL(customer_name));

Why does this statement fail when executed?
                                                              
                                               
                NOT NULL constraints CANNOT be defined at the table level. (*)

                                               
                The NUMBER data types require precision values.

                                               
                The CREATE TABLE statement does NOT define a PRIMARY KEY.

                                               
                UNIQUE constraints must be defined at the column level.

                                                                               
A column defined as NOT NULL can have a DEFAULT value of NULL. True or False?           
                                                                               
                                               
                True

                                               
                False (*)

This SQL command will do what?
ALTER TABLE employees
ADD CONSTRAINT emp_manager_fk FOREIGN KEY(manager_id) REFERENCES employees(employee_id);

                                                          
                                               
                Add a FOREIGN KEY constraint to the EMPLOYEES table restricting manager ID to match every employee ID.

                                               
                Add a FOREIGN KEY constraint to the EMPLOYEES table indicating that a manager must already be an employee. (*)

                                               
                Alter table employees and add a FOREIGN KEY constraint that indicates each employee ID must be unique.

                                               
                Alter the table employees and disable the emp_manager_fk constraint.

                                                                               
Once constraints have been created on a table, you will have to live with them as they are unless you drop and re-create the table. True or False? 
                                                                               
                                               
                True

                                               
                False (*)

                                                                               
You can drop a column in a table with a simple ALTER TABLE DROP COLUMN statement, even if the column is referenced in a constraint. True or False?   
                                                                               
                                               
                True

                                               
                False (*)

                                                                               
What mechamisn does Oracle use in the background to enforce uniqueness in Primary and Unique key constraints?         
                                                                               
                                               
                Internal Pointers

                                               
                Nothing extra is created when Primary Keys and Unique Keys are created

                                               
                Ordered Lists

                                               
                Unique key indexes are created in the background by Oracle when Primary key and Unique key constraints are created or enabled (*)

                                                                               
Evaluate this statement:
ALTER TABLE employees
ADD CONSTRAINT employee_id PRIMARY KEY;

Which result will the statement provide?

                                                            
                                               
                An existing constraint on the EMPLOYEES table will be enabled.

                                               
                A syntax error will be returned. (*)

                                               
                A constraint will be added to the EMPLOYEES table.

                                               
                An existing constraint on the EMPLOYEES table will be overwritten.

                               

No comments:

Post a Comment

Final Exam Java Programming 2019 Learner - English

Final Exam