Quiz-Ans Iitg Ma321
Quiz-Ans Iitg Ma321
• Each question carries one mark if not specified. There is no partial marking.
• Close Note Exam
• No Mobile/Calculator is allowed
Entities :………………………………………………………………………………………………………………
Relations:………………………………………………………………………………………………………………
Q2. Define the schema for the relations (i) students enrolling to courses, (ii) lecturer teaching courses.
Hints: Ensure ICs. [1 + 1 ]
(i)………………………………………………………………………………………………………………………
(ii)………………………………………………………………………………………………………………………
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
(ii) Find the course in each department that has highest average mark compare to other courses in the same
department.
……………………………………………………………………………………………………………
……………………………………………………………………………………………………………
(iii) Create a table to store student id and his/her grade on a course <sid, cid, grade>. Create a trigger on INSERT to an
appropriate table to determine grade of a student based on their mark. student scoring (i) lesser than 40 has F grade,
(ii) greater than or equal to 40, but lesser than 70 has B grade, and (iii) greater than or equal to 70 has A grade.
Highest possible mark is 100. The sid, cid and corresponding grade is to be inserted in the newly created table.
Q4. Which of the following is/are true?
a. Primary key attributes can not have NULL values.
b. Unique key attribute can have one NULL value.
c. Primary key attributes can have any number of NULL values.
d. Unique key attributes can have any number of NULL values.
Q5. The …Check….. constraint is used to limit the value range that can be placed in a column.
Q6. Which of the following statements are TRUE about an SQL query? [GATE 2012]
a. An SQL query can contain a HAVING clause even if it does not have a GROUP BY clause
b. An SQL query can contain a HAVING clause only if it has a GROUP BY clause
c. All attributes used in the GROUP BY clause must appear in the SELECT clause
d. Not all attributes used in the GROUP BY clause need to appear in the SELECT clause
Q7. Consider a database table T containing two columns X and Y each of type integer. After the creation of the table,
one record (X=1, Y=1) is inserted in the table. Let MX and MY denote the respective maximum values of X and Y
among all records in the table at any point in time. Using MX and MY, new records are inserted in the table 128 times
with X and Y values being MX+1, 2*MY+1 respectively. It may be noted that each time after the insertion, values of
MX and MY change. What will be the output of the following SQL query after the steps mentioned above are carried
out? [Gate 2011]
SELECT Y FROM T WHERE X=7;
Ans: …127…………………………………………………………………………………………………………………………
Q10. Consider the following three table to store student enrolments in different courses.
Student(EnrollNo, Name)
Course(CourseID, Name)
EnrollMents(EnrollNo, CourseID)
Complete the following SQL command to find the name of all students who are enrolled in "DBMS" and "OS"
How many rows are there in the result of following query? ……5…………………………………………
Q12. Consider the following two relations; Students and Performance. What will be the output of the following
query?
Raj 310
Rohit 140
Q1. Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic values. F = {CH -> G, A -> BC, B
-> CFH, E -> A, F -> EG} is a set of functional dependencies (FDs) so that F+ is exactly the set of FDs that hold for
R. How many candidate keys does the relation R have?..... AD, BD, ED and FD.........................
Q2. Consider the FDs given in above question. What is the Normal Form of the relation R? …1NF…………….
Q4. The maximum number of superkeys for the relation schema R(E,F,G,H) with E as the key is …8[GATE 2014]
Q5. Let r be a relation instance with schema R = (A, B, C, D). We define r1 = ΠA, B, C (r) and r2 = ΠA.D (r). Let s = r1 *
r2 where * denotes natural join. Given that the decomposition of r into r1 and r2 is lossy, which one of the following is
TRUE? ……………..[GATE 2005]
a. s ⊂ r. b. r ∪ s. c. r ⊂ s d. r * s = s
Q6 Let R1 (A, B, C) and R2 (D, E) be two relation schema, where the primary keys are shown underlined, and let C
be a foreign key in R1 referring to R2. Suppose there is no violation of the above referential integrity constraint in the
corresponding relation instances r1 and r2. Which one of the following relational algebra expressions would
necessarily produce an empty relation? …2………………………………….[GATE 2004]
Q7. Consider a schema R(A,B,C,D) and functional dependencies A->B and C->D. Then the decomposition of R into
R1(AB) and R2(CD) is …………………………………[GATE 2001]
a. dependency preserving and lossless join
b. lossless join but not dependency preserving
c. dependency preserving but not lossless join
d. not dependency preserving and not lossless join
Q8. Consider a relation geq which represents “greater than or equal to”, that is, (x,y) ∈ geq only if y >= x.
CREATE TABLE geq
( ib integer not null, ub integer not null, primary key 1b, foreign key (ub) references geq on delete cascade )
Q9. Consider an Entity-Relationship (ER) model in which entity sets E1 and E2 are connected by an m : n relationship
R12, E1 and E3 are connected by a 1 : n (1 on the side of E1 and n on the side of E3) relationship R13. E1 has two
single-valued attributes a11 and a12 of which a11 is the key attribute. E2 has two single-valued attributes a21 and a22 is
the key attribute. E3 has two single-valued attributes a31 and a32 of which a31 is the key attribute. The relationships do
not have any attributes. If a relational model is derived from the above ER model, then the minimum number of
relations that would be generated if all the relations are in 3NF is ___4________.[GATE 2015]
Q10. Which of the following FD can’t be implied from FD set: {A->B, A->BC, C->D} ? …………………
a. A->C b. B->D. c. BC->D. d. All of the above