nerdexam
PostgreSQL_CE

PGCES-02 · Question #14

A table is defined as below. Select the most suitable description about the foreign key constraint. CREATE TABLE master (id INTEGER PRIMARY KEY, name TEXT); CREATE TABLE record (id INTEGER…

The correct answer is C. If the "record" table contains a row with an "id", the corresponding "id" row in the "master" table. See the full explanation below for the reasoning.

Question

A table is defined as below. Select the most suitable description about the foreign key constraint. CREATE TABLE master (id INTEGER PRIMARY KEY, name TEXT); CREATE TABLE record (id INTEGER REFERENCES master (id), count INTEGER);

Options

  • AIf any row exists in the "record" table, no change can be made to the "master" table.
  • BIf the "record" table contains a row with an "id", no change can be made at all to the
  • CIf the "record" table contains a row with an "id", the corresponding "id" row in the "master" table
  • DThe "record" table cannot have duplicate "id"s.
  • EThese SQL statements are invalid; no constraints are created.

How the community answered

(29 responses)
  • A
    3% (1)
  • B
    3% (1)
  • C
    86% (25)
  • E
    7% (2)

Community Discussion

No community discussion yet for this question.

Full PGCES-02 Practice