Anda di halaman 1dari 11

Database Management System: Assignment 3

Total Marks : 20

March 14, 2019

Question 1
Database schema is given below:

customer (customerId, name, phonenumber, address)


account (accountNo, balance, branchName )

(i) Find out the phonenumber and address of the customer named by Aditya in relational
algebra from the above database schema. Marks: 1 MCQ

a) σname=0 Aditya0 (Πname,phonenumber,address (customer))

b) Πphonenumber,address (σname=0 Aditya0 (customer))

c) σname=0 Aditya0 (Πphonenumber,address (customer))

d) ρphonenumber,name (σname=0 Aditya0 (customer))

Answer: b) Πphonenumber,address (σname=0 Aditya0 (customer))

Explanation: This relational algebra queries will be solved by using the select and project
operator from the above mentioned relational schemas. At first it will select all the tuples from
the relation whose name is Aditya using select operator then it will select phonenumber and
address of ’Aditya’ through the project operator.

(ii) Find out the accountNo and branchName of all those account where the balance is less
than 1000 in relational algebra from the above database schema.

Marks: 1 MCQ

a) ΠaccountNo,branchName (σbalance<1000 (account))

b) ΠaccountNo,balance (σbalance<1000 (account))

c) σbalance<1000 (ΠaccountNo,balance (account))

d) σbalance<1000 (ΠbranchName (account))

Answer: a) ΠaccountNo,branchName (σbalance<1000 (account))

1
Explanation: It will select those tuples whose balance is less than 1000 from the relation
account and then the accountNo and branchName is selected.

2
Question 2
Consider the schema of relations shown below and the SQL query that follow:

students (roll number, name, date of birth)


courses (course number, course Name, instructor)
grades (roll number, course number, grade)

SELECT DISTINCT name


FROM students, courses, grades
WHERE students.roll_number = grades.roll_number}
AND courses.instructor="Korth"
AND courses.course_number = grades.course_number
AND grades.grade="A"

Which of the following sets is computed by the above query? Marks: 2 MCQ

a) Names of the students who have not got an A grade in all courses taught by Korth

b) Names of the students who have got an A grade in all courses

c) Names of the students who have got an A grade in at least one of the courses taught by
Korth

d) None of the above

Answer: c)
Name of the students who have got an A grade in at least one of the courses taught by Korth.

Explanation: There are three relations


Select distinct name, select the name of students and then there are three predicates
Courses.Instructor=”korth” specify the courses taught by Korth.
The other two predicate specify that a student can earn a grade at least A from causes so
the SQL query complete.
Hence, the answer is ” Name of the students who have got an A grade in at least one of the
courses taught by Korth.”

3
Question 3
Find out the account details where the balance is greater than 5000 in both tuple and domain
relational calculus from the given relation schema.

account (accountNo, balance, branchName)

Marks: 2 MCQ

a) {t|t ∈ account ∪ t[balance] > 5000}


{< a, b, c > | < a, b, c >∈ account ∩ b > 5000}

b) {t|t ∈ account ∪ t[balance] > 5000}


{< a, b, c > | < a, b, c >∈ account ∪ b > 5000}

c) t|t ∈ account ∩ t[balance] > 5000


{< a, b, c > | < a, b, c >∈ account ∪ b > 5000}

d) t|t ∈ account ∩ t[balance] > 5000


{< a, b, c > | < a, b, c >∈ account ∩ b > 5000}

Answer: d) {t|t ∈ account ∩ t[balance] > 5000}


{< a, b, c > | < a, b, c >∈ account ∩ b > 5000}

Explanation: Generic expression for tuple relational calculus {t—P (t)}, where p repre-
sents the tuple variable and P(t) is the predicate using tuple variable t. t|t ∈ account ∩ t[balance] >
5000.

Generic expression for domain relational calculus {< a, b, c, · · · , n > |P(< a, b, c, , n >)},
where a, b, c, · · · , n are domain variables and P is the predicate one or more of these variables.
{< a, b, c > | < a, b, c >∈ account ∩ b > 5000}

4
Question 4
From within a host language, select the correct Embedded SQL query/s to find the names
of all instructors whose salary is between min salary and max salary declared in the host
language. Marks: 2 MSQ

a) EXEC SQL
DECLARE c CURSOR FOR
SELECT name
FROM instructor
WHERE salary BETWEEN :min_salary AND :max_salary
END_EXEC

b) DECLARE c CURSOR FOR


SELECT name
FROM instructor
WHERE salary BETWEEN min_salary AND max_salary

c) EXEC SQL
DECLARE c CURSOR FOR
SELECT name
FROM instructor
WHERE salary >= :min_salary AND salary <= :max_salary
END_EXEC

d) EXEC SQL
DECLARE c CURSOR FOR
SELECT name
FROM instructor
WHERE salary BETWEEN min_salary AND max_salary
END_EXEC

Answer: a), c)
Explanation: min salary and max salary are the variables of the Embedded SQL host
language which contains the values of the minimum and maximum salary. We use these
variables to find the names of the instructors whose salaries are between the range with the
help of between construct.

5
Question 5
Loan (Loan No, LoanAmount, BranchName)

Find out the loan details for Branch name Alipore and Loan amount is greater than 5000
in tuple relational calculus from the given relation schema. Marks: 2 MCQ

a) {t|t ∈ loan ∪ t[branchName] = Alipore ∩ t[loanAmount] > 5000}

b) {t|t ∈ loan ∩ t[branchName] = Alipore ∪ t[loanAmount] > 5000}

c) {t|t ∈ loan ∩ t[branchName] = Alipore ∩ t[loanAmount] > 5000}

d) {t|t ∈ loan ∪ t[branchName] = Alipore ∪ t[loanAmount] > 5000}

Answer: c) {t|t ∈ loan ∩ t[branchName] = Alipore ∩ t[loanAmount] > 5000}

Explanation: Use the generic expression of tuple relational calculus.

6
Question 6
Map the given E-R model into relational model in the context of M:N relationship type.

Marks: 2 MCQ

a) work on(ssn, hours)

b) work on(ssn, pnumber, hours)

c) work on(emp name, ssn, pnumber, gender, salary, dob, dateofjoining, pname, location)

d) work on(ssn, pnumber)

Answer: b)work on(ssn, pnumber, hours)


Explanation:
Mapping of binary M:N relationship types by creating a separate relationship relation with
two foreign keys, which are the primary key of the participating entity types.

7
Question 7

What is the correct notation for the above E-R diagram? Marks: 2 MSQ

a) Partial participation of E2 in R.

b) Total participation of E2 in R.

c) Total participation of E1 in R.

d) Partial participation of E1 in R.

Answer: b) Total participation of E2 in R and d) Partial participation of E1 in R.

Explanation: Based on the participation constraints on Relationship type double line shows
the total participation and single line represents the partial participation.

8
Question 8
What constraints do the partial key and the identifying relationship of the weak entity type
specify in this diagram?

Marks: 2 MCQ

a) Total participation with the ratio 1:N

b) Partial participation with the ration 1:N

c) Total participation with the ratio N:1

d) Partial participation with the ration N:1

Answer:
c) Total participation with the ratio N:1

Explanation: BANK is the owner entity type.


BANK BRANCH is the weak entity type.
Branch No is the partial key.
Branches is the identifying relationship type.
The two methods for specifying the structural constraints on relationship types are
Cardinality ratios(1:1, 1:N, N:1, M:N)
Participation Constraints(Total, Participation)
Total participation of BANK BRANCH in relationship Branches with the ratio of N:1.
As all the BANK BRANCH must be associated to a particular BANK and many BANK BRANCH can
be associated to one BANK.

9
Question 9
The CREATE TRIGGER statement is used to create the trigger. THE ––––clause specifies
the table name on which the trigger is to be attached. The ––––specifies that this is an AFTER
INSERT trigger.
Identify the correct options for the gaps in the above sentences. Marks: 2 MCQ

a) for insert, on

b) On, for insert

c) for, insert

d) None of the mentioned

Answer: b)

Explanation: The triggers run after an insert, update or delete on a table. They are not
supported for views.

10
Question 10

What constraint will be applied on the question mark? Marks: 2 MCQ

a) Overlap Constraint

b) disjoint Constraint

c) Specific Constraint

d) Multiple Constraint

Answer: b) disjoint Constraint.

Explanation: An employee can either be a salaried employee or hourly employee, it can


not be both.

11

Anda mungkin juga menyukai