Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Pimpri Chinchwad Education Trust’s

Pimpri Chinchwad College of Engineering

Subject: DBMS
UNIT – I & II QUESTION BANK
UNIT-I:
Question 1 : Suppose you are given the following requirements for a simple database for the
National Hockey League (NHL):
the NHL has many teams,
each team has a name, a city, a coach, a captain, and a set of players,
each player belongs to only one team,
each player has a name, a position (such as left wing or goalie), a skill level, and a set
of
injury records,
a team captain is also a player,
a game is played between two teams (referred to as host_team and guest_team) and has
a date (such as May 11th, 1999) and a score (such as 4 to 2).
Construct a clean and concise ER diagram for the NHL database

Question 2: (a) Construct an E-R diagram for a car-insurance company whose customers
own one or more cars each. Each car has associated with it zero to any number of recorded
accidents.
(b) Construct appropriate tables for the above ER
Diagram ? Car insurance tables:
person (driver-id, name,
address) car (license,
year,model)
accident (report-number, date, location)
participated(driver-id, license, report-number, damage-amount)

Question 4:
(a) Construct an E-R diagram for a hospital with a set of patients and a set of medical
doctors. Associate with each patient a log of the various tests and examinations
conducted

(b) Construct appropriate tables for the above ER


Diagram : Patient(SS#, name, insurance)
Physician ( name, specialization)
Test-log( SS#, test-name, date,
time) Doctor-patient (physicianname,
SS#) Patient-history(SS#,
test-name, date)
Question 5: Consider a database used to record the marks that students get in different
exams of different course offerings.
a) Construct an E-R diagram that models exams as entities, and uses a ternary
relationship, for the above database.

b) Construct an alternative E-R diagram that uses only a binary relationship between
students and course-offerings. Make sure that only one relationship exists between a
particular student and course-offering pair, yet you can represent the marks that a student
gets in different exams of a course offering.
Question 6: Design an E-R diagram for keeping track of the exploits of your favorite sports
team. You should store the matches played, the scores in each match, the players in each
match and individual player statistics for each match. Summary statistics should be modeled as
derived attributes.
Question 7 : Extend the E-R diagram of the previous question to track the same information
for all teams in a league.

Question 8 : Draw the E-R diagram which models an online bookstore


Question 9 : Consider a university database for the scheduling of classrooms for -final exams.
This database could be modeled as the single entity set exam, with attributes course-name,
section-number, room-number, and time. Alternatively, one or more additional entity sets
could be defined, along with relationship sets to replace some of the attributes of the exam
entity set, as
course with attributes name, department, and c-number
section with attributes s-number and enrollment, and dependent as a weak entity set on
course
room with attributes r-number, capacity, and building
Show an E-R diagram illustrating the use of all three additional entity sets listed.
Question 10 : Construct an ER Diagram for Company having following details :
Company organized into DEPARTMENT. Each department has unique name and a particular
employee who manages the department. Start date for the manager is recorded.
Department may have several locations.
A department controls a number of PROJECT. Projects have a unique name, number
and a single location.
Company‟s EMPLOYEE name, ssno, address, salary, sex and birth date are recorded. An
employee is assigned to one department, but may work for several projects (not
necessarily controlled by her dept). Number of
hours/week an employee works on each project is recorded; The immediate
supervisor for the employee.
Employee‟s DEPENDENT are tracked for health insurance purposes (dependent name,
birthdate, relationship to employee).
Question 11 : Consider the following ER Diagram –

a) How many minimum number of tables required ?


Solution :
Step 1 : Conversion of Strong Entities :
Question 12: Design an ER diagram for the College ERP System and convert the same into the database
tables

Question 13 Construct the ER model for the given requirements of Banking application Saving_Account,
Loan_account, Branch, Depositor and Borrower

Question 14: Consider the following ER Diagram and minimize it into relations.
Solution:
Question 14: List four significant differences between a file-processing system and a DBMS
A database coordinates the physical and logical access to the data; a fileprocessing
system only coordinates physical access to the data
A DBMS reduces the amount of data duplication
A DBMS is designed to allow flexibility in what queries give access to the data, where a
file-processing system only allows pre-determined access to data (by specific compiled
programs)
A DBMS is designed to coordinate and permit multiple users to access data at the
same time. A file processing system is much more restrictive in simultaneous data
access
Question 15: What are the major disadvantages of a database system.
Setup of the database system requires much more knowledge, money, skills, and time
Complexity of the database may result in poor performance

.
Question 16: Explain the distinctions among the terms primary key, candidate key, and
superkey
A superkey is any set of attributes such that the values of the attributes (taken
together) uniquely identify one entity in the entity set.
A candidate key is a minimal superkey — a superkey with no redundant attributes. In
other words, if any one of the attributes is removed, the set of attributes that remain no
longer form a superkey.
A primary key is one of the candidate keys, designated by the database designer.
Every primary key is also a candidate key; every candidate key is also a superkey, but not
vice versa.
A superkey is a set of one or more attributes that, taken collectively, allows us to identify
uniquely an entity in the entity set. A superkey may contain extraneous attributes. If K is a
superkey, then so is also a superkey is called a candidate key. It is possible that several distinct
sets of attributes could serve as candidate keys. The primary key is one of the candidate keys
that is chosen by the database designer as the principal means of identifying entities within an
entity set.
Question 17: Explain the difference between a weak and a strong entity set.
A strong entity set has a primary key. All tuples in the set are distinguishable by that key. A
weak entity set has no primary key unless attributes of the strong entity set on which it
depends are included. Tuples in a weak entity set are partitioned according to their relationship
with tuples in a strong entity set. Tuples within each partition are distinguishable by a
discriminator, which is a set of attributes.
Question 18: We can convert any weak entity set to a strong entity set by simply
adding appropriate attributes. Why, then, do we have weak entity sets?

We have weak entities for several reasons:


We want to avoid the data duplication and consequent possible
inconsistencies caused by duplicating the key of the strong entity.
Weak entities reect the logical structure of an entity being
dependent on another entity.
Weak entities can be deleted automatically when their strong entity is deleted.
Weak entities can be stored physically with their strong entities.
Question 19: List the major disadvantages of File Processing System.
1. Duplicate Data – As all files are independent of each other, so, duplicate data may be
present in more than one files.
2. Inconsistency – Inconsistency means different copies of same data that are not
matching. Data may be inconsistent in file processing system.
3. Poor Data Integrity – Data integrity refers to the overall completeness, accuracy
and consistency of data. But in Processing system, Poor data integrity often develops.
4. Data is isolated and separated – Data are separated in various files. SO, if it is
needed to extract data from 2 different files, it will be require to determine which parts
of each of the files are needed and how files are related to one another.
5. Application Programs are dependent on file formats – In processing suystem, the
physical formats of file are entered in application program that process the files. Change
in the file format result in program updates and a change which is time consuming and
error prone.
6. Poor Data Security- Data is stored in different files causing the security problems
7. Difficult to represent complex object – Some data objects may be of variable
length which might produce difficulty in representation in files.
Question 20. Describe and Justify the use of following components in database system
architecture:
1. Storage manager 2. Transaction manager 3. Query Processor
Question 21. Write the role of following components of Query processor in DBMS.
i) DDL Interpreter 2) DML Compiler 3) DBA
Question 22. Discuss all the components of Database System structure with diagram

UNIT-II

Question 1 Consider the following database schema:


Physician(Reg_no, Name, Tel_no, City)
Patient(P_name, Street, City)
Visit(P_name, Reg_no, Date_of_visit, Fee)
Write SQL queries for following requirements
i) Find the name and city of patients who visited a physician on 13th July 2017
ii) Get the name of physician and total no. of pateients visited him.
iii) Get the details of date wise fees collected at clinic

Question 2. Solve the given queries for Employee database


Emp (empno, ename, hiredate, job, mgrno, salary, deptno)
Dept (deptno, dname, loc)
1) Select no. of employee working in each department.
2) Select the department in which no employee works.
3) Find Employee number and name along with manager number and name
Question 3. Schema definition for supplier-and-parts database. Keys are underline
Supplier(supplier_no, supplier_name, status, city)
Parts (Part_no, part_name, color, weight, city)
Shipments(supplier_no, part_no, quantity)
Write SQL queries for following requirements.
i) Find shipment information (supplier_no, supplier_name, Part_no, part_name, quantity) for
those having quantity less than 150.
ii) List supplier_no, supplier_name, Part_no, part_name for those suppliers who made shipment
of parts whose quantity is larger than the average uantity.
iii) Find aggregate quantity of part number „A692‟ of color GREEN for which shipment made by
supplier number who reside in Mumbai.

Question 4 Consider Following Schema Employee(employee_name, Street, City)


Works(employee_Name, Company_Name, Salary)
Comapny(Company_Name,City)
Manages( employee_name,manager_name)
Write SQL queries for following requirements:
a. Find names and cities of residences of all employees who work for “IBM”.
b. Find names, Street addresses and cities of all employees who work for “IBM” and earn more
than 30000.
c. Find all employees in the database who earn more than each employee of “IBM”.
d. Find company that has maximum employees.
e. Find those companies whose employees earn higher salary, on average, than average salary at
“IBM”.

Question 5 Write the SQL statements:-


Emp (empno, ename, hiredate, job, mgrno, salary, deptno)
Dept (deptno, dname, loc)
1) Select no. of employee working in each department.
2) Select the department in which no employee works.
3) Hike the salary of employees by 50% whose salary is less than 3000 and whose job is clerk

Question 6 Consider the following Database Schema:


Employee(e_name, street, city)
Works(e_name, comp_name, salary)
Company(comp_name,city)
1) Find names, street and cities of all employes who works for “infosys” and earn more than
3000
Q2. Find total number of employees in Infosys company
Q.3 Find total no of employees for companies that are located in “Pune City”.

Question 7 Consider Following Database Schema:


Student(s_name,city,state)
Enrolled_Course(s_name,course_name,fees)
Course_teachers(c_name,teacher_name)
Q1. Find names and address of all students who enrolled for”DB Certification course” and fees is
greater than 50000.)
Q2. Find total number of students enrolled for DBA certificate Course.
Q3. Find total number of students for courses teach by “xyz” teacher.

Question 8 Write a function to count total no of students in student table


Write a function to count total number of employees from employee table.

Question 9 Write the PL/SQL block code to display diameter, circumference and area of the circle for
given radius=9.5
Question 10 Write the PL/SQL block code to fetch customer details from the given customer table and
display on the screen whose customer id is „C1‟

Customer (C_id , C_name, age, address, salary)

Question 11 Write a PL/SQL function for following requirements and the same in PL/SQL block:
Account no. and branch name will be accepted from user. The same will be searched in table
acct_details. If details are available in table display message as “Account is active”, otherwise
display message on screen “account is inactive

Question 12 Write a PL/SQL block for following requirement using user defined exception
handling.
The account_master table records the current balance for an account, which is updated whenever,
any deposits or withdrawals takes place. If the withdrawal attempted is more than the current
balance held in the account. The user defined exception is raised, displaying an appropriate
message. Write a PL/SQL block for above requirement using user defined exception handling.

Question 13. Write the PL/SQL block code to find reverse of a number using for loop.

You might also like