Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

PostgreSQL Exam PGCES-02 Topic 4 Question 54 Discussion

Actual exam question for PostgreSQL's PGCES-02 exam
Question #: 54
Topic #: 4
[All PGCES-02 Questions]

You want to set a constraint so that the "item_id" in the "sales" table will always have a value that already exists as "id" in the "item_master" table. Select the correct SQL statement to fill in the underlined blank of the "sales" table. Definitions: CREATE TABLE item_master ( id INTEGER PRIMARY KEY, name TEXT ); CREATE TABLE sales ( sales_id INTEGER, item_id INTEGER, num INTEGER, );

Show Suggested Answer Hide Answer
Suggested Answer: A, E

Contribute your Thoughts:

Justine
3 days ago
I'm not sure about the answer. Can someone explain why option B is the correct one?
upvoted 0 times
...
Evangelina
6 days ago
I agree with Earlean. Using FOREIGN KEY (item_id) REFERENCES item_master (id) ensures that the 'item_id' in 'sales' table will always have a value that exists in the 'id' column of 'item_master' table.
upvoted 0 times
...
Earlean
7 days ago
I think the correct answer is B) FOREIGN KEY (item_id) REFERENCES item_master (id). It makes sense to reference the 'id' column in 'item_master' table.
upvoted 0 times
...

Save Cancel