Which four statements are true regarding primary and foreign key constraints and the effect they can have on table data? (Choose four.)
Which four statements are true regarding primary and foreign key constraints and the effect they can have on table data? (Choose four.)
A table can only have one primary key but it can have multiple foreign keys. It is possible for child rows with a foreign key to remain in the child table when the parent row is deleted, especially if the foreign key uses the ON DELETE SET NULL option or the foreign key constraint is temporarily disabled. Child rows can also be automatically deleted from the child table if the parent row is deleted, provided the ON DELETE CASCADE option is used. Both primary key and foreign key constraints can be defined at both the column and table levels.
ADEG i think
How is D possible?
In the relational 1-0, you can use ON DELETE SET NULL to keep child-records, but child-keys will be updated to NULL.
this means that D is wrong
No because the child row stays, just some of its values are nullified.
But you can be achieved by disabling the FK constraint and re enabling with no validate clause after performing delete on parent table.
i agree
ADEG in my opinion too... A. A table can have only one primary key but multiple foreign keys --> For sure B. A table can have only one primary key and one foreign key --> There is no such restrictions C. The foreign key columns and parent table primary key columns must have the same names --> There is no such restriction. D. It is possible for child rows that have a foreign key to remain in the child table at the time the parent row is deleted --> Can be achieved by disabling the FK constraint and re enabling with no validate clause after performing delete on parent table. E. It is possible for child rows that have a foreign key to be deleted automatically from the child table at the time the parent row is deleted --> CASCADE option F. Only the primary key can be defined at the column and table level --> No such restrictions G. Primary key and foreign key constraints can be defined at both the column and table level --> True.
might correct A, B (can have), D, E, G wrong C ("Must"), F (PK,FK, UQ, CK defined at column and table level. only not null in column level). I vote ADEG
ACEG is correct answer
A - true; quote1: A table or view can have only one primary key., quote2: You can define multiple foreign keys in a table or view. B - false; see quote2 in answer A C - false; example, when names of FK columns and parent table columns are different: ALTER TABLE employees2 ADD CONSTRAINT fk_dept2 FOREIGN KEY (dept_id) REFERENCES departments2(id); D - true; example: ALTER TABLE employees ADD CONSTRAINT fk_dept FOREIGN KEY (dept_id) REFERENCES departments (id) ON DELETE SET NULL; perform INSERT(s) into employees with dept_id=17; DELETE FROM departments WHERE dept_id=17; E - true; example: ALTER TABLE employees ADD CONSTRAINT fk_dept FOREIGN KEY (dept_id) REFERENCES departments (id) ON DELETE CASCADE; F - false; Either primary key, unique constraint, foreign key or check contraints can be defined on both table and column levels. G - true; see answer F
quotes originate in following sources: A - Oracle documentation: Database > Oracle > Oracle Database > Release 19 > SQL Language Reference > 8 Common SQL DDL Clauses > constraint F,G - Oracle documentation: Database > Oracle > Oracle Database > Release 19 > SQL Language Reference > 12 SQL Statements: ALTER SYNONYM to COMMENT > ALTER TABLE
A - true; You can define multiple foreign keys in a table or view. B - false; see A C - false; a foreign key needn't be based on a primary key, it can be based on unique key, therefore its columns can have different names. D - true; parent row can be deleted, but parrent column cannot be deleted (ORA-12992: cannot drop parent key column) E - true; foreign key must be defined with ON DELETE CASCADE clause F - false; not only primary key, but also other constraints can be defined both on table level and column level, e.g. CREATE TABLE a (b NUMBER UNIQUE) or CREATE TABLE a (b NUMBER, UNIQUE(b)) G - true; e.g. CREATE TABLE child (a number, b number REFERENCES parent(c)) or CREATE TABLE CHILD (a number, b number, FOREIGN KEY (parent_id) REFERENCES parent(c)) Source: A,B,C Oracle documentation: Oracle Database, Release 19, SQL Language Reference, 8 Common SQL DDL Clauses, constraint
The correct answers are A,C,E,G The D is not correct because for referential integrity it does not allow you to delete rows from the parent table and leave related rows in the child tables. The E is correct because effectively when you delete rows from the parent table and you specify on delete cascade in the delete statement, it will delete the related rows in the child tables. If it is not specified, it does not allow deleting records from the parent table if you have related records.
A,D,E,G is correct
ADEG is correct.
AEG are for sure right BFC are definitely wrong so i believe ADEG is the right combination
ADEG are true ,
good choice
ADEG, without a shadow of doubt, just common DB knowledge.
A is correct. The only restriction is on the PK, a table can have only one. No restrictions exist on the number of FK's a table may have. B is wrong. Tables may have many foreign keys in them, it all depends on the db's relational model. C is wrong. The DB does not care about column names, only data type, size and contents of the PK and FK. D is correct. The FK must be created with the ON DELETE SET NULL option. Without this option ORA-02292 will be raised when attempting to delete a row from the parent table that has child record. E is correct. The FK must be created with ON DELETE CASCADE option. Without this option ORA-02292 will be raised when attempting to delete a row from the parent table that has child record. F is wrong. The only constraint that has to be defined inline (column level) is NOT NULL. G is correct. The only constraint that has to be defined inline (column level) is NOT NULL.
adeg is correct
ADEG correct
D: using ON DELETE cascade F: using on delete set null
sorry error typo: E: using on delete set null