Unit 2 - Question Bank
Unit 2 - Question Bank
UNIT-II QUESTIONBANK
UNIT-2
QUESTION BANK
Course Competence
Q.No. Questions Outcome BT Level
How many rules are there for reducing the ER Diagram into a
table?
1 a) 3 CO2 BT1
b) 4
c) 5
d) 6
What are some important points to convert ER Diagrams into
tables?
A) Contextual-design phase
9 CO2 BT1
B) Virtual-design phase
C) Physical-design phase
D) Logical-design phase
Suppose now that R(A,B:) and S(A,B:) are two relations with r
and s tuples, respectively (again, not necessarily distinct). If m is
the number of (not necessarily distinct) tuples in the result of the
SQL query: R intersect S; Then which of the following is the most
restrictive, correct condition on the value of m?
10 CO2 BT1
A. m = min(r,s)
B. 0 <= m <= r + s
C. min(r,s) <= m <= max(r,s)
D. 0 <= m <= min(r,s)
What action does ⋈ operator perform in relational algebra?
A. Domain constraints
19 CO2 BT1
B. Key constraints
C. Integrity constraints
D. Rule constraints
A. Structured
20 B. Logical CO2 BT1
C. Procedural
D. Relational
The relational calculus is considered to be __________________.
A. a nonprocedural language
21 B. a procedural language CO2 BT1
C. a structured language
D. a unstructured language
A. primary key
22 CO2 BT1
B. referential integrity
C. alternate key
D. super key
Relationship can be created between
A. Intersection Value
24 CO2 BT1
B. Union Value
C. Deny Value
D. Truth Value
A. Super Key
25 CO2 BT1
B. Referential integrity
C. Primary Key
D. Candidate Key
A. Finite Relation
29 B. Infinite Relation CO2 BT1
C. Invalid Relation
D. Composite Relation
A. Binary operations
32 CO2 BT1
B. Ternary Operations
C. Unary operations
D. None of the above.
A relational query language L is considered relationally complete
if we can express in L any query that can be expressed
in__________.
33 CO2 BT1
A. Relational Algebra
B. Structured Language
C. Relational calculus
D. Logical Language
Which of the following is the Binary Operations?
A. Set difference, Union, Project
34 B. Rename, union, Set difference CO2 BT1
C. Cartesian product, Set difference and project
D. Cartesian product, union, set difference
The select operation selects tuples that satisfy a given predicate.
We use the lowercase______ to denote selection
A. String Variables
36 CO2 BT1
B. Column Variables.
C. Relation Variables
D. Tuple Variables.
Suppose we want to list all loan numbers and the amount of the
loans, but do not care about the branch name. Which of the
following operation allows us to produce this relation?
37 A. Set difference CO2 BT3
B. Union
C. Cartesian product
D. Project
The relation X(ABCDEF) with functional dependency set
F={AB🡪CD,C🡪CA,B🡪E,D🡪B,E🡪F}. The number of candidate
keys of a relation R is ______.
38 A. 3 CO2 BT3
B. 4
C. 2
D. 5
A ________of a relation schema R = {A1, A2, ... , An} is a set of
attributes S ⊆ R with the property that no two tuples t 1 and t 2 in
any legal relation state r of R will have t 1[S] = t2[S].
A. a non-prime attribute
42 CO2 BT2
B. a prime attribute
C. Composite attribute
D. Derived attribute
A. =
46 CO2 BT1
B. =+
C. ==
D. ←
Ans:
Select operation
It displays the records that satisfy a condition. It is denoted by sigma
(σ) and is a horizontal subset of the original relation.
1 Syntax: CO2 BT1
σcondition(table name)
Projection operation
It displays the specific column of a table. It is denoted by pie (∏). It is
a vertical subset of the original relation. It eliminates duplicate tuples.
Syntax:
∏condition(table name)
Consider the following schema:
Suppliers(sid: integer, sname: string, address: string)
Parts(pid: integer, pname: string, color: string)
Catalog(sid: integer, pid: integer, cost: real)
The key fields are underlined, and the domain of each field is listed
after the field name. Thus sid is the key for Suppliers, pid is the key for
Parts,and sid and pid together form the key for Catalog. The Catalog
relation lists the prices charged for parts by Suppliers. Write the
following queries in relational algebra.
a) Find the names of suppliers who supply some red part
b) Find the sids of suppliers who supply some red or green part.
c) Find the sids of suppliers who supply some red part or are at 221
Packer Ave
2 d) Find the sids of suppliers who supply some red part and some green BT2
part CO2
Ans:
What are the Pitfalls in Relational database design?
Ans:
Relational database design requires that we find a “good”
collection of relational schemas. A bad design may lead to
● Repetition of information
● Inability to represent certain information
Design Goals for Relational Database:
1. Avoid redundant data
2. Ensure that relationships among attributes are represented.
3. Facilitate the checking of updates for violation of database integrity
constraints
Example:
3 BT1
Consider the relational schema Lending-schema = (branch-name, CO2
branch-city, assets, customer-name, loan- number, amount)
Redundancy:
● Data for branch name, branch city, assets are repeated for each
loan that a branch makes.
● Wastes space and complicates updating.
Null Values:
● cannot store information about a branch if no loan exists.
● can use null values, but they are difficult to handle.
In the given example the database design is faulty which makes the
above pitfalls in database. So, in relational database design if the
design is not good then there will be faults in databases.
Find the minimum number of tables required to represent the given ER
diagram in relational model-
4 BT1
Answer:
Applying the rules, minimum 5 tables will be required-
BR1R4R5 (b1 , b2 , a1 , c1 , d1)
A (a1 , a2)
CO2
R2 (a1 , c1)
CR3 (c1 , c2 , d1)
D (d1 , d2)
5 BT1
CO2
6 BT2
CO2
BT2
CO2
BT2
CO2
Difference between Tuple Relational Calculus (TRC) and Domain
Relational Calculus (DRC) :
9 CO2 BT2
10 CO2 BT3
Answer
Applying the rules, minimum 4 tables will be required-
AR1R2 (a1 , a2 , b1 , c1)
B (b1 , b2)
C (c1 , c2)
R3 (b1 , c1)
PART C (12 Marks)
Draw ER diagram for Hospital Management System CO2
1 (Use DOCTOR, PATIENT,HOSPITAL and MEDICAL_RECORD BT2
Entity). Identify Primary Key and Foreign Key.
Write the following queries in relational algebra, using the university CO2
schema.
a. Find the titles of courses in the Comp. Sci. department that have 3
credits.
b. Find the IDs of all students who were taught by an instructor named
Einstein; make sure there are no duplicates in the result.
c. Find the highest salary of any instructor.
d. Find all instructors earning the highest salary (there may be more
than one with the same salary).
e. Find the enrollment of each section that was offered in Autumn
2009.
f. Find the maximum enrollment, across all sections, in Autumn 2009.
g. Find the sections that had the maximum enrollment in Autumn 2009
Ans:
2 BT1
4 BT2
A. To display name of student whose age is greater than 15.
B. To remove the record of the student who are from Kathmandu.
C. To update address of student to Kathmandu whose sid is
'S1101'.
Use the following schema to write relational algebra statements for the
questions that follow. The primary keys are underlined in the schema:
STUDENT(Ssn, Name, Major, DOB)
COURSE(Cnum, Cname, Dept)
ENROLL(Ssn, Cnum, Semester, Grade)
BOOK_ADOPTION(Cnum, Semester, ISBN)
TEXTBOOK(ISBN, Title, Publisher, Author)
Specify the following queries in relational algebra:
A. List the course number taken by all students named 'John
5 CO2 BT2
Smith' in winter 1999 (i.e., Semester = 'W99').
B. Produce a list of textbooks (include Course#, ISBN, Title) for
courses offered by the Computer Science Department (i.e.,
Dept = 'CS').
C. List any department that has its adopted books published by
'BC Publishing'.
D. Find the names of students who have not been enrolled in any
course.
E. Find all the textbooks that were authored by Mike Wilkins.
Consider the following relational database:
Employee(empid, gender, name, dob, salary, address, deptno,
start_date)
Department(dpetno, name)
Students(std_id, gender, name, dob, projectno, deptno)
Project(projectno, name, location)