The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+15 votes
3.3k views

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 (59.6k points)
edited by | 3.3k views

3 Answers

+29 votes
Best answer
R
a Let(PK)              b        c
1    
2    
S
d(FK referring to PK of R)        e     f
2    
1    

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 would cause no violation.

Delete from R  would cause violation if  it any tuple is deleted,and as a result a value in a gets deleted which is refereed to by d in S.

answered by Active (3.5k points)
edited by
0
This question build my referential integrity constraint concept very well
+11 votes
Let's take an example,
     R
a b c
S1  —
S2  —
S3  —
       S
d e f
S1
S2  —

Here 'd' is the foreign key of S and let 'a' is the primary key of R.

 a) Insertion into R : will cause no violation as it does not result inconsistency.

 b) Insertion into S : may cause violation because there may not be entry of the tuple in relation R. Example entry of    <S4, - ,- > is not  allowed because there is no S4 tuple exists in relation R and it results in inconsistency.

c) Delete form R : may cause violation. For example, Deletion of tuple <S2, - ,- > will cause violation as there is entry of S2 in the foreign key table and so produce inconsistency.

d) Delete from S : will cause no violation as it does not result inconsistency.

answered by Active (3k points)
edited by
+4 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 (6.8k points)
Answer:

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

41,065 questions
47,661 answers
147,302 comments
62,381 users