Sei sulla pagina 1di 9

Consider the following table Table_Product:

Product_ID Colour Price


1 Red, green 100
2 Yellow 45
3 Green 2
4 Yellow, blue 90
5 Red 120

Normalize the above relation to First normal form.

For the following relation schema:

Employee(employee-name, street, city)


Works(employee-name, company-name, salary)
Company(company-name, city)

Draw a query tree for the following query


Find the names of all employees in the database who live in the same cities as
the companies for which they work.

Map the following ER diagram to a set of relational tables.

Write the SQL command to create Supp_Mastertable for the given data below:

Attribute name Type Constraint


Supplier_id Varchar Primary Key
Supplier_type Varchar Foreign Key , defined
as primary Key in
Detailed Supplier Table
Supplier_name Char Default value is “ABC
pvt. Ltd.”
Supplier_city Char City can be Delhi,
Mumbai, Chennai or Pune
Distinguish between DDL and DML and categorize the following commands as
DDL or DML
i. ALTER
ii. SELECT
iii. UPDATE
iv. INSERT
Consider the following Employee table in a relational database:
Employee (Emp_Id, First_Name, Salary, Dno)
Give SQL commands to
i. Remove the data of the table and its schema
i. Remove the tuple where Emp_Id = ‘101’

There is Car Insurance company whose customers own one or more cars. Each
car is associated with zero to any number of recorded accidents. Each insurance
policy covers one or more cars and has one or more premium payments
associated with it. Each payment is for a particular period of time and has an
associated due date and the date when the payment was received.
i) Identify Entities, Attributes for each entity.
ii) Draw an ER diagram for above mentioned scenario. Also specify all
structural constraints in the diagram. State any assumptions made.
Consider a table Product:
Product_id Product_name Type Price

Write SQL command to


i. Create a view ‘Product_info’ comprising of Product_id, Product_name
and its price
ii. Create a view ‘More_than_average’ comprising of Product_name and
price of the products for tuples where price is greater than average price.
Consider the following database schema:
Representative (RepNo, LastName, FirstName, Street, City,
Commission)
Customer (Cust_No, Cust_name, Street, City, Balance,
Credit_Limit, RepNo)
Orders (OrderNo, Order_Date, Cust_No)
Answer the following queries in SQL.

i. List the Ordernumber, Orderdate, Customer number and Customer name


for each order placed by any sales representatives whose LastName is
‘Kumar’.
ii. List the number and date of all orders that were placed on Jan 15, 2012
by customer whose representative number is 200.
iii. List the details of customers who have placed more than two orders.

Consider a scenario in which a doctor may or may not be a specialist. In case, of


a specialist, he/she specializes only in one department such as cardiology,
Ophthalmology, pediatric or medicine. Draw an extended ER diagram to that
expresses above mentioned scenario.
The relation book (title, price) contains the titles and prices of different books.
Assuming that no two books have the same price, what does the following SQL
query list?
select title
from book as B
where (select count(*)
from book as T
where T.price>B.price)

Consider a file with the following search values 71, 56, 59, 18, 21, 10, 74. Insert
these search values in the given order in a B+ tree of order p = 3. Show the tree
at each step.

Consider the relation R which has attributes that contain schedules of courses
and students at university.
R = {StudentID, StudentName, CourseID, CourseName,
Grade, StudentPosition}
Suppose the following FDs hold on R
CourseID,StudentID→ Grade
StudentId→StudentName
CourseId→CourseName
Grade →StudentPosition
Determine the keys of R and normalize this relation uptothird normal form.

Find the minimal cover for the given set of functional dependencies
F= {AD, BA, BCD, ACBE}of a relation R

Consider the tables given below and answer the following queries in
relationalalgebra
Employee(Fname, Lname, SSN, Sex, Salary, Super_Ssn, Dno)
Department (Dname, Dnumber, Mgr_Ssn, Mgr_start_date)
Dependent (Essn, Dependent_name, Sex, Bdate, Relationship)

(i) List the names of all employees who have a dependent with the same
first name as themselves.
(ii) Find the names of all employees who are directly supervised by
‘Franklin Wong’.
(iii) For each department , retrieve department number, the number of
employees in the department and their average salary.

Consider the two relations BRANCH and STUDENT in the database


Branch
Branch_code Branch_Name
CS Comp. Science
EE Electronics
Engineering
IT Information Technology
CE Civil Engineering

Student

Roll Name Age Branch_


No code
1 Rahul 22 CS
2 Anjali 21 CS
3 Teena 20 IT

Relation Student references the relation Branch.

For each of the following operations, indicate whether it results in constraint


violation and if so, which constraint is violated and why?
i. Insert <1, ‘Meera’, 22, ‘EE’> in Student.
ii. Delete <’CS’, ‘Comp. Science’> in Branch.
iii. Update <’CS’, ‘Comp. Science’> to <’CSE’, ‘Computer Science’> in
Branch.
iv. Insert <5, ‘Preeti’, 21, ‘IT’> in Student.

Consider a data file EMPLOYEE(EmpId, Ename, Salary, DeptNo, Designation). Create a


primary index on EmpId. Assuming that a block contains five keys.

EmpId Ename Salary DeptNo Designation


101 A 1000 CS Peon
102 S 2341 EE Teacher
103 D 2564 IT Officer
104 F 3456 CS Teacher
105 G 6432 CS Principal
106 H 4323 IT Accountant
107 J 4554 FT Librarian
108 K 4567 EE Teacher
109 M 3467 CS Attendant
110 N 7890 IT Assistant
111 W 2456 EE Attendant
112 F 6777 IT Assistant
Give two advantages of DBMS over traditional file system?

For a relation R (A, B, C, D, E) a set of Fd’s F is given as follows:


F = {A  B, AB  C, D  AC, D  E}
Find key of R.

Find the output of the following expressions in relational algebra on the tables

T1, T2, and T3 as given below:

I. T1/T2
II. T1UT3
III.
IV. T1∩T2

T1 T2 T3
A B
X Y
X d a
a b
a e d
c d
c b
c
c b
b a
d a

For the given binary relationship, suggest the cardinality ratio of the relationship based
on the usual context of entity types and state the context clearly:
4

Entity1 Entity2

Country Prime Minister

Faculty Course

Student Course

Course Book

How data independence is achieved using the three tier architecture of a database
management system?
Give an example of each of Total-disjoint specialization and partial-disjoint
specialization in the context of EER modelling.

Consider the following Employee table in a relational database:

Employee (Emp_Id, First_Name, Salary, Dno)

Give SQL commands to

i. Add a new attribute Last_Name in the Employee table


ii. Delete the entire contents of the table Employee. However the table should
remain the part of the schema.
Two transactions T1 and T2 are executing concurrently (assuming concurrency control is not in
place) with initial value of A=5 and B=10

T1 _____ T2 _________
read_item(B)
B = B+1
read_item(B)
read_item(A)
A = A+B
write_Item(B)
read_item(A)
write_Item(A)
write_Item(A)

On the completion of the transactions T1 and T2 what will be the value of A and B. Justify your
answer.
Find the minimal cover for the given set of functional dependencies {BC->D,
AC->BE, B->E}

of a relation R
Consider the Relation R (ABCDEFGH)and the following set f of Fds of R: F = {CH -> G, A ->
BC, B -> CFH, E -> A, F -> EG}
i. What is the key of the relation R?
ii) Apply normalization to convert it into 3NF stating the reasons behind each decomposition

Give two reasons to avoid occurrence of null values in a database.

Why can we have at most one primary or clustering index on a file, but several secondary indexes?

Consider a file with the following key values: 17, 7, 11, 8, 41, 4, 13. Suppose these search key values are
inserted in the given order in a B+ tree of order p = 3. Show the tree at each step.

Consider the database schema given below:

Salesman
(salesman_id, name, city, commission)
Orders
(ord_no, amt, ord_date, customer_id, salesman_id)
Customer
(customer_id, cust_name, city, grade, salesman_id)

Write the following queries in relational algebra form.


1) Display all the orders having salesman 'John Paul'.
2) Write a query to display all the orders for the salesman who belongs to the city “Delhi”.
3) Write a query to find the salesmen who have multiple customers.

.Consider the database schema given below:

Book(Book_Id, Title, Publisher)


Book_copies(Book_Id, Branch_Id, No. of Copies)
Library_branch(Branch_Id, BranchName, Address)
Book_Authors(Book_Id, AuthorName

Write the SQL queries for each of the following:

i. Display number of copies of book titled”Data Base Management System” owned by library branch
the name of which is “Delhi Public Library”.
ii. Display number of copies of book titled “Data Base Management System” owned by each library
branch.
iii. For each book authored by ‘Navathe’, retrieve the title and the number of copies owned by the
library branch whose name is ‘Central’ .

Consider the database schema given below:

CUSTOMER(Cust#, Cname, City)


ORDER(Order#, Odate, Cust#, Ord_amt)
ORDER_ITEM(Order#, Item#, Qty)
ITEM(Item#, Unit_price)
SHIPMENT(Order#, Warehouse#, Ship_date)
WAREHOUSE(Warehouse#, City)

State referential integrity constraint and depict the referential integrity constraints for the above relational
schema diagrammatically.
Map the following ER diagram to a set of relational tables.

For the following relation schema

Employee(employee-name, street, city)


Works(employee-name, company-name, salary)

Draw a query tree for the following query


Find the names, street address, and cities of residence for all employees who work for “ABC” and earn more
than Rs 10,000.

Potrebbero piacerti anche