0
0
SQLquery~10 mins

Constraint naming conventions in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to name a primary key constraint following the convention.

SQL
ALTER TABLE employees ADD CONSTRAINT [1] PRIMARY KEY (employee_id);
Drag options to blanks, or click blank then click option'
Aprimary_key
Bpk_employees
Ckey_employee
Demp_pk
Attempts:
3 left
💡 Hint
Common Mistakes
Using generic names like 'primary_key' without table reference.
Not using the 'pk_' prefix.
2fill in blank
medium

Complete the code to name a foreign key constraint following the convention.

SQL
ALTER TABLE orders ADD CONSTRAINT [1] FOREIGN KEY (customer_id) REFERENCES customers(customer_id);
Drag options to blanks, or click blank then click option'
Afk_customer
Bforeign_key
Corders_fk
Dfk_orders_customers
Attempts:
3 left
💡 Hint
Common Mistakes
Using vague names like 'foreign_key' without table names.
Omitting the referenced table name.
3fill in blank
hard

Fix the error in naming a unique constraint following the convention.

SQL
ALTER TABLE products ADD CONSTRAINT [1] UNIQUE (product_code);
Drag options to blanks, or click blank then click option'
Auq_products_product_code
Bunique_products_code
Cunique_code
Dproducts_uniq
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'unique_' prefix instead of 'uq_'.
Not including column name in the constraint name.
4fill in blank
hard

Fill both blanks to name a check constraint following the convention.

SQL
ALTER TABLE employees ADD CONSTRAINT [1] CHECK (salary [2] 0);
Drag options to blanks, or click blank then click option'
Achk_employees_salary
B>
C<
Dsalary_positive
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong prefix like 'check_' instead of 'chk_'.
Using '<' instead of '>' for salary check.
5fill in blank
hard

Fill both blanks to name a default constraint following the convention.

SQL
ALTER TABLE orders ADD CONSTRAINT [1] DEFAULT [2] FOR order_status;
Drag options to blanks, or click blank then click option'
Adf_orders_order_status
B'pending'
Ddefault_status
Attempts:
3 left
💡 Hint
Common Mistakes
Using extra syntax after the column name.
Not quoting string default values.