Given the SQL statement GRANT REFERENCES ON TABLE tab1 TO USER usera, what is USERA allowed to do as a result of this DB2 privilege?

Difficulty: Medium

Correct Answer: Define a dependent table that uses TAB1 as the parent in a foreign key relationship

Explanation:


Introduction / Context:
This question tests DB2 security and data integrity concepts, specifically the meaning of the REFERENCES privilege. DB2 uses granular privileges to control who can read, modify, or define relationships involving a table. Understanding what is granted by REFERENCES is important when designing foreign key relationships between tables owned by different users.


Given Data / Assumptions:

    There is a base table named TAB1 in a DB2 database.

    An administrator has executed GRANT REFERENCES ON TABLE tab1 TO USER usera.

    USERA may want to create tables that reference TAB1.

    Other privileges such as SELECT or ALTER are not mentioned.


Concept / Approach:
In DB2, the REFERENCES privilege allows a user to create or alter foreign key constraints that refer to the specified table. The privilege does not by itself allow reading data, altering the structure of the base table, or defining keys on that base table. Instead, it permits creation of dependent tables whose foreign key columns reference the primary key or unique key of the parent table.


Step-by-Step Solution:
1. Recall that GRANT REFERENCES ON table_name TO user gives the ability to reference that table in foreign key definitions. 2. Option A describes creating a read only view, which would require SELECT or other view related privileges rather than REFERENCES. 3. Option B describes altering TAB1 to add a check constraint, which requires ALTER privilege on TAB1. 4. Option C refers to defining a primary key or unique constraint on TAB1 itself, which is normally performed by the table owner or a user with ALTER privilege. 5. Option D describes creating a dependent table with a foreign key that references TAB1, which is exactly what the REFERENCES privilege is designed to allow.


Verification / Alternative check:
DB2 documentation lists REFERENCES as the privilege needed to create or drop a foreign key that refers to a table. It does not extend to arbitrary structural changes on the parent table. Testing in a development database by trying to create a child table with a foreign key referencing TAB1 under USERA confirms the behavior.


Why Other Options Are Wrong:
Creating views depends on SELECT privilege and does not rely on REFERENCES.
Adding constraints on TAB1 itself is controlled by ALTER privilege and ownership, not by the ability to reference it from another table.
Defining primary or unique keys on TAB1 is part of table definition and not granted simply by REFERENCES.


Common Pitfalls:
A common misunderstanding is assuming that any privilege involving constraints grants broad structural control. Another pitfall is thinking that REFERENCES includes SELECT, which is not the case. Clear separation of privileges helps enforce least privilege and secure database design.


Final Answer:
USERA is allowed to define a dependent table whose foreign key references TAB1 as the parent table.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion