Which four statements are true regarding primary and foreign key constraints and the effect they can have on table data?
Correct Answer: D,E,G
Primary and foreign key constraints are foundational to relational database design:
* Option A: Incorrect. Both primary and foreign key constraints can be defined at the column or table level.
* Option B: Incorrect. Foreign key columns do not need to have the same names as the corresponding primary key columns in the parent table. They must be of the same data type and size.
* Option C: Incorrect. If a foreign key constraint is enforced without ON DELETE CASCADE, deleting the parent row will either prevent the delete (due to constraint) or require a prior deletion or update of the child rows.
* Option D: Correct. A table can indeed have only one primary key, which uniquely identifies each row, but it can have multiple foreign keys linking to primary keys of different tables.
* Option E: Correct. Both types of keys can be defined at either level, providing flexibility in how constraints are applied and enforced.
* Option F: Incorrect. A table can have multiple foreign keys as stated, each referencing a different parent table.
* Option G: Correct. If the ON DELETE CASCADE option is set for a foreign key, then deleting a parent row will automatically delete the corresponding child rows, maintaining referential integrity.