0% found this document useful (0 votes)
178 views5 pages

Quiz-Ans Iitg Ma321

The document contains a database schema for a university consisting of departments, students, lecturers, courses, and enrollments. It also contains 10 multiple choice questions regarding database and relational algebra concepts such as functional dependencies, normal forms, joins, and keys. The questions assess knowledge of SQL, relational algebra operations, functional dependencies, and normalization.

Uploaded by

Tusharbhutad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
178 views5 pages

Quiz-Ans Iitg Ma321

The document contains a database schema for a university consisting of departments, students, lecturers, courses, and enrollments. It also contains 10 multiple choice questions regarding database and relational algebra concepts such as functional dependencies, normal forms, joins, and keys. The questions assess knowledge of SQL, relational algebra operations, functional dependencies, and normalization.

Uploaded by

Tusharbhutad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Roll No: ………………………………… Name:……………………………………………………………………………..

• Each question carries one mark if not specified. There is no partial marking.
• Close Note Exam
• No Mobile/Calculator is allowed

CS345: Database lab

Consider the following Database for the Questions Q1 – Q3


A university consists of a number of departments. A student belongs to only one department. A lecturer belongs to only one
department. Each department offers several courses. Students enrol in a particular course. A course may be taught by more than one
lecturer from the appropriate department, and a lecturer may teach more than one course. A student can enrol courses offered in
any department. However, a lecture can teach the courses that are offered only in his department.

Q1. Identify the list of Entities and Relations [1+1]

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)………………………………………………………………………………………………………………………

Q3. Write SQL query for the following statement. [1+1+3]


(i) Given a lecturer’s id, find the list of students who have not attended any of the courses offered by the
lecturer.

……………………………………………………………………………………………………………

……………………………………………………………………………………………………………

(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…………………………………………………………………………………………………………………………

Q8. Database table by name Loan_Records is given below. [GATE 2011]

What is the output of the SQL query?


5

Q9 Given relations r(w, x) and s(y, z), the result of


SELECT DISTINCT w, x FROM r, s;
is guaranteed to be same as r, provided
a. r has no duplicates and s is non-empty
b. r and s have no duplicates
c. s has no duplicates and r is non-empty
d. r and s have the same number of tuple

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"

SELECT S.Name. FROM Student S, Course C, Enrollments E


WHERE S.EnrollNo = E.EnrollNo AND C.Name = "DBMS" AND E.CourseID = C.CourseID AND.
………S.EnrollNo IN…………………… (SELECT S2.EnrollNo FROM Student S2, Course C2, Enrollments E2
WHERE S2.EnrollNo = E2.EnrollNo AND E2.CourseID = C2.CourseID AND C2.Name = "OS")
Q11. Consider the following Employee table

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?

SELECT S. Student_Name, sum(P.Marks)


FROM Student S, Performance P
WHERE S.Roll_No = P.Roll_No
GROUP BY S.Student_Name;

Raj 310
Rohit 140

Q13. Consider the following relation [GATE 2015]


Cinema (theater, address, capacity)
Which of the following options will be needed at the end of the SQL query
SELECT P1.address FROM Cinema P1
Such that it always finds the addresses of theaters with maximum capacity?
a. WHERE P1. Capacity> = All (select P2. Capacity from Cinema P2)
b. WHERE P1. Capacity> = Any (select P2. Capacity from Cinema P2)
c. WHERE P1. Capacity > All (select max(P2. Capacity) from Cinema P2)
d. WHERE P1. Capacity > Any (select max (P2. Capacity) from Cinema P2)
Q14. Consider the relations r1(P, Q, R) and r2(R, S, T) with primary keys P and R respectively. The relation
r1 contains 2000 tuples and r2 contains 2500 tuples. The maximum size of the join r1⋈ r2 is …2000…[GATE 2006]

Q15. Select operation in SQL is equivalent to [GATE 2015]


a. the selection operation in relational algebra
b. the selection operation in relational algebra, except that select in SQL retains duplicates
c. the projection operation in relational algebra
d. the projection operation in relational algebra, except that select in SQL retains duplicates
Roll No: ………………………………… Name:……………………………………………………………………………..
CS344: Databases (Marks 10)

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…………….

Q3. Which of the following statements is/are true? [GATE 2014]


S1: Every table with two single-valued attributes is in 1NF, 2NF, 3NF and BCNF.
S2: AB->C, D->E, E->C is a minimal cover for the set of functional dependencies AB->C, D->E, AB->E, E->C.
a. Only S1. b. Only S2. c. Both S1 and S2 d. None

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 )

Which of the following is possible if a tuple (x,y) is deleted? ……………………….[GATE 2001]


a. A tuple (z,w) with z > y is deleted
b. A tuple (z,w) with z > x is deleted
c. A tuple (z,w) with w < x is deleted
d. The deletion of (x,y) is prohibited

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy