The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+16 votes

Let $R (a, b, c)$ and $S(d, e, f)$ be two relations in which $d$ is the foreign key of $S$ that refers to the primary key of $R$. Consider the following four operations $R$ and $S$

  1. Insert into $R$

  2. Insert into $S$

  3. Delete from $R$

  4. Delete from $S$

Which of the following can cause violation of the referential integrity constraint above?

  1. Both I and IV

  2. Both II and III

  3. All of these

  4. None of these

asked in Databases by Veteran (52k points)
edited by | 4.2k views

2 Answers

+31 votes
Best answer

$$\overset{R}{\begin{array}{|c|c|c|} \hline \textbf {a (PK)} &  \textbf {b} & \textbf {c} \\\hline  \text{1} \\\hline \text{2}  \\\hline \end{array}} \qquad \overset{S}{\begin{array}{|c|c|c|} \hline \textbf {d (FK referring to PK of R)} &  \textbf {e} & \textbf{f} \\\hline  \text{2} \\\hline \text{1}  \\\hline \end{array}}$$

  • Insert into $R$ cannot cause any violation.
  • Insert into $S$ can cause violation if any value is inserted into d of S, which value is not in a of R.
  • Delete from $S$ cannot cause any violation.
  • Delete from $R$ can cause violation if any tuple is deleted, and as a result a value in 'a' gets deleted which is referenced to by 'd' in $S.$

Correct Answer: $B$

answered by Active (3.6k points)
edited by
This question build my referential integrity constraint concept very well
+5 votes
2-Insert into S   and  3-Delete from R  ,can cause Violation of the Referential integrity constraints.

Hence ,ans  is  (B) Both II and III
answered by Loyal (7.5k points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,540 questions
54,099 answers
71,007 users