GATE 2008
185 questions
MCQ 1851-mark 52 · 2-mark 133
Questions 151–155 of 185
Consider the following ER diagram
Which of the following is a correct attribute set for one of the tables for the minimum number of tables needed to represent M, N, P, R1, R2?
Which of the following is a correct attribute set for one of the tables for the minimum number of tables needed to represent M, N, P, R1, R2?
Answer: (A)
Entities , and each need a table, but a relationship can often be folded into one of them.
R1: the arrow towards means each is related to at most one , so R1 is many-to-one. has total participation (double line), so every has exactly one . R1 has no attributes, so no table is needed for it. Add the key of to as a foreign key that references .
R2: is a weak entity (double box) with partial key , identified through by the identifying relationship R2 (double diamond). Its table holds the key of , so R2 also needs no table of its own.
Minimum tables, 3 in all:
M() with key , references
P() with key
N() with key , references
Of the options, only is one of these tables. (B), (C) and (D) leave out attributes of or mix attributes of and .
Answer: (A)
R1: the arrow towards means each is related to at most one , so R1 is many-to-one. has total participation (double line), so every has exactly one . R1 has no attributes, so no table is needed for it. Add the key of to as a foreign key that references .
R2: is a weak entity (double box) with partial key , identified through by the identifying relationship R2 (double diamond). Its table holds the key of , so R2 also needs no table of its own.
Minimum tables, 3 in all:
M() with key , references
P() with key
N() with key , references
Of the options, only is one of these tables. (B), (C) and (D) leave out attributes of or mix attributes of and .
Answer: (A)
Consider the following ER diagram
The minimum number of tables needed to represent M, N, P, R1, R2 is
The minimum number of tables needed to represent M, N, P, R1, R2 is
Answer: (B)
In the diagram, M and P are strong entities, N is a weak entity, R1 is a relationship from M to P, and R2 is the identifying relationship between N and P.
- R1: the arrow towards P means many M to one P, and R1 has no attribute. So no table is needed for R1. We put the key of P (P1) into the table of M as a foreign key. M's participation is total (double line), so every M has a P1 value.
- N: a weak entity needs its own table with the key of P, because N1 is only a partial key. The identifying relationship R2 (many N to one P) is covered by this key, so R2 needs no separate table.
- P: its own table.
The tables are:
M(M1, M2, M3, P1): M1 is the primary key, P1 is a foreign key to P
P(P1, P2): P1 is the primary key
N(P1, N1, N2): (P1, N1) is the primary key, P1 is a foreign key to P
So 3 tables are needed.
Answer: (B)
- R1: the arrow towards P means many M to one P, and R1 has no attribute. So no table is needed for R1. We put the key of P (P1) into the table of M as a foreign key. M's participation is total (double line), so every M has a P1 value.
- N: a weak entity needs its own table with the key of P, because N1 is only a partial key. The identifying relationship R2 (many N to one P) is covered by this key, so R2 needs no separate table.
- P: its own table.
The tables are:
M(M1, M2, M3, P1): M1 is the primary key, P1 is a foreign key to P
P(P1, P2): P1 is the primary key
N(P1, N1, N2): (P1, N1) is the primary key, P1 is a foreign key to P
So 3 tables are needed.
Answer: (B)
Consider the following relational schema:
Consider the following tuple relational calculus query.
If a student needs to score more than 35 marks to pass an exam, what does the query return?
Student(school-id,sch-roll-no,sname,saddress)
School(school-id,sch-name,sch-address,sch-phone)
Enrolment(school-id,sch-roll-no,erollno,examname)
ExamResult(erollno,examname,marks) Consider the following tuple relational calculus query.
If a student needs to score more than 35 marks to pass an exam, what does the query return?
Answer: (C)
For each school id in Enrolment, the query makes two counts:
- Top: the enrolment tuples of school that have a matching ExamResult row (same erollno and examname) with . These are the passes.
- Bottom: all enrolment tuples of school .
It then checks . A student needs more than 35 marks to pass, so this is the pass percentage of the school.
Both counts run over all of the school's enrolments, with no grouping by examname. So the percentage is taken over all exams taken together, not exam by exam.
- (A) is wrong: the query can return schools.
- (B) is wrong: the top count needs marks , not just an enrolment.
- (D) is wrong: the percentage is not computed separately for each exam.
Answer: (C)
- Top: the enrolment tuples of school that have a matching ExamResult row (same erollno and examname) with . These are the passes.
- Bottom: all enrolment tuples of school .
It then checks . A student needs more than 35 marks to pass, so this is the pass percentage of the school.
Both counts run over all of the school's enrolments, with no grouping by examname. So the percentage is taken over all exams taken together, not exam by exam.
- (A) is wrong: the query can return schools.
- (B) is wrong: the top count needs marks , not just an enrolment.
- (D) is wrong: the percentage is not computed separately for each exam.
Answer: (C)
Let R and S be two relations with the following schema
R (,R1,R2,R3)
S (,S1,S2)
Where {P, Q} is the key for both schemas. Which of the following queries are equivalent?
I.
II.
III.
IV.
R (,R1,R2,R3)
S (,S1,S2)
Where {P, Q} is the key for both schemas. Which of the following queries are equivalent?
I.
II.
III.
IV.
Answer: (D)
R and S share only the attributes and . So joins tuples that agree on both and (the whole key).
I keeps the of every pair that occurs in both R and S. That is , which is III. So I and III are equivalent.
IV uses with and . So the inner part is , and IV is the same as III.
II is . This joins on alone, so it gives the values present in both relations, even if they come with different values. Counterexample: has pairs and has . Then I gives , but II gives . So II is not equivalent.
I, III and IV are equivalent.
Answer: (D)
I keeps the of every pair that occurs in both R and S. That is , which is III. So I and III are equivalent.
IV uses with and . So the inner part is , and IV is the same as III.
II is . This joins on alone, so it gives the values present in both relations, even if they come with different values. Counterexample: has pairs and has . Then I gives , but II gives . So II is not equivalent.
I, III and IV are equivalent.
Answer: (D)
Which of the following tuple relational calculus expression(s) is/are equivalent to ?
I.
II.
III.
IV.
I.
II.
III.
IV.
Answer: (C)
says every tuple of satisfies . Its negation is that some tuple of fails : . So the statement itself equals , which is III.
I says no tuple of satisfies . That is much stronger. If has one tuple and holds for it, the given formula is true but I is false.
II is a double negation of membership, , which just says is in . It does not say that holds for all tuples.
IV says some tuple of fails . This is the opposite (negation) of the given formula.
Answer: (C)
I says no tuple of satisfies . That is much stronger. If has one tuple and holds for it, the given formula is true but I is false.
II is a double negation of membership, , which just says is in . It does not say that holds for all tuples.
IV says some tuple of fails . This is the opposite (negation) of the given formula.
Answer: (C)