0% found this document useful (0 votes)
80 views

DBMS Assignment

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

DBMS Assignment

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Assignment

Question No: 1

Consider the following information about a university database:

 Professors have an SSN, a name, an age, a rank, and a research specialty.


 Projects have a project number, a sponsor name (e.g., NSF), a starting date, an ending
date, and a budget.
 Graduate students have an SSN, a name, an age, and a degree program (e.g., M.S. or
Ph.D.).
 Each project is managed by one professor (known as the project’s principal
investigator).
 Each project is worked on by one or more professors (known as the project’s co-
investigators).
 Professors can manage and/or work on multiple projects.
 Each project is worked on by one or more graduate students (known as the project’s
research assistants).
 When graduate students work on a project, a professor must supervise their work on
the project. Graduate students can work on multiple projects, in which case they will
have a (potentially different) supervisor for each one.
 Departments have a department number, a department name, and a main office.
 Departments have a professor (known as the chairman) who runs the department.
 Professors work in one or more departments, and for each department that they work
in, a time percentage is associated with their job.
 Graduate students have one major department in which they are working on their
degree.
 Each graduate student has another, more senior graduate student (known as a student
advisor) who advises him or her on what courses to take.

Design and draw an ER diagram that captures the information above. Use only the basic ER
model here; that is, entities, relationships, and attributes. Be sure to indicate any key and
participation constraints.

Question No: 2

Notown Records has decided to store information about musicians who perform on its
albums (as well as other company data) in a database. The company has wisely chosen to hire
you as a database designer (at your usual consulting fee of $2500/day).

 Each musician that records at Notown has an SSN, a name, an address, and a phone
number. Poorly paid musicians often share the same address, and no address has more
than one phone.
 Each instrument used in songs recorded at Notown has a unique identification
number, a name (e.g., guitar, synthesizer, and flute) and a musical key (e.g., C, B-flat,
E-flat).
 Each album recorded on the Notown label has a unique identification number, a title,
a copyright date, a format (e.g., CD or MC), and an album identifier. Each song
recorded at Notown has a title and an author.
 Each musician may play several instruments, and a given instrument may be played
by several musicians.
 Each album has a number of songs on it, but no song may appear on more than one
album.
 Each song is performed by one or more musicians, and a musician may perform a
number of songs.
 Each album has exactly one musician who acts as its producer. A musician may
produce several albums, of course

Design and draw an ER diagram that captures the information above. Use only the basic
ER model here; that is, entities, relationships, and attributes. Be sure to indicate any key
and participation constraints.

Question No: 3

The Prescriptions-R-X chain of pharmacies has offered to give you a free lifetime supply
of medicine if you design its database. Given the rising cost of health care, you agree.
Here’s the information that you gather:

 Patients are identified by an SSN, and their names, addresses, and ages must be
recorded.
 Doctors are identified by an SSN. For each doctor, the name, specialty, and years
of experience must be recorded.
 Each pharmaceutical company is identified by name and has a phone number.
 For each drug, the trade name and formula must be recorded. Each drug is sold by
a given pharmaceutical company, and the trade name identifies a drug uniquely
from among the products of that company. If a pharmaceutical company is
deleted, you need not keep track of its products any longer.
 Each pharmacy has a name, address, and phone number.
 Every patient has a primary physician. Every doctor has at least one patient.
 Each pharmacy sells several drugs and has a price for each. A drug could be sold
at several pharmacies, and the price could vary from one pharmacy to another.
 Doctors prescribe drugs for patients. A doctor could prescribe one or more drugs
for several patients, and a patient could obtain prescriptions from several doctors.
Each prescription has a date and a quantity associated with it. You can assume
that, if a doctor prescribes the same drug for the same patient more than once,
only the last such prescription needs to be stored.
 Pharmaceutical companies have long-term contracts with pharmacies. A
pharmaceutical company can contract with several pharmacies, and a pharmacy
can contract with several pharmaceutical companies. For each contract, you have
to store a start date, an end date, and the text of the contract.
 Pharmacies appoint a supervisor for each contract. There must always be a
supervisor for each contract, but the contract supervisor can change over the
lifetime of the contract.
Design and draw an ER diagram that captures the information above. Use only the basic ER
model here; that is, entities, relationships, and attributes. Be sure to indicate any key and
participation constraints.

Question No: 4

Computer Sciences Department frequent fliers have been complaining to Dane County
Airport officials about the poor organization at the airport. As a result, the officials decided
that all information related to the airport should be organized using a DBMS, and you have
been hired to design the database. Your first task is to organize the information about all the
airplanes stationed and maintained at the airport. The relevant information is as follows:
 Every airplane has a registration number, and each airplane is of a specific model.
 The airport accommodates a number of airplane models, and each model is identified
by a model number (e.g., DC-10) and has a capacity and a weight.
 A number of technicians work at the airport. You need to store the name, SSN,
address, phone number, and salary of each technician.
 Each technician is an expert on one or more plane model(s), and his or her expertise
may overlap with that of other technicians. This information about technicians must
also be recorded.
 Traffic controllers must have an annual medical examination. For each traffic
controller, you must store the date of the most recent exam.
 All airport employees (including technicians) belong to a union. You must store the
union membership number of each employee. You can assume that each employee is
uniquely identified by a social security number.
 The airport has a number of tests that are used periodically to ensure that airplanes
are still airworthy. Each test has a Federal Aviation Administration (FAA) test
number, a name, and a maximum possible score.
 The FAA requires the airport to keep track of each time a given airplane is tested by a
given technician using a given test. For each testing event, the information needed is
the date, the number of hours the technician spent doing the test, and the score the
airplane received on the test.
Design and draw an ER diagram that captures the information above. Use only the basic ER
model here; that is, entities, relationships, and attributes. Be sure to indicate any key and
participation constraints.
Question No: 5

A university database contains information about professors (identified by social security


number, or SSN) and courses (identified by courseid). Professors teach courses; each of the
following situations concerns the Teaches relationship set. For each situation, draw an ER
diagram that describes it (assuming no further constraints hold).
1. Professors can teach the same course in several semesters, and each offering must be
recorded.
2. Professors can teach the same course in several semesters, and only the most recent such
offering needs to be recorded. (Assume this condition applies in all subsequent questions.)
3. Every professor must teach some course.
4. Every professor teaches exactly one course (no more, no less).
5. Every professor teaches exactly one course (no more, no less), and every course must be
taught by some professor
6. Now suppose that certain courses can be taught by a team of professors jointly, but it is
possible that no one professor in a team can teach the course. Model this situation,
introducing additional entity sets and relationship sets if necessary.

Question No: 6

Produce the relational schema for the following ER diagram


Question No: 7

Produce the relational schema for the following ER diagram

Question No: 8

Produce the relational schema for the following ER diagram


Question No: 9

Produce the relational schema for the following ER diagram

Question No: 10

Produce the relational schema for the following ER diagram


Question No: 11

Normalize the given table

Question No: 12

Normalize the given table

Question No: 13

Normalize the given table


Question No: 14

Normalize into 3NF

BRANCH (Branch#, Branch_Addr, (ISBN, Title, Author, Publisher, Num_copies))

CLIENT (Client#, Name, Location, Manager#, Manager_name, Manager_location,


(Contract#, Estimated_cost, Completion_date, (Staff#, Staff_name, Staff_location)))

Question No: 15

Normalize into 3NF

PATIENT (Patient#, Name, DOB, Address, (Prescription#, Drug, Date, Dosage, Doctor,
Secretary))

DOCTOR (Doctor#, DoctorName, Secretary, (Patient#, PatientName, PatientDOB,


PatientAddress, (Prescription#, Drug, Date, Dosage)))

Question No: 16

For the following relation schema R and set of Functional Dependencies F:

R(A,B,C,D,E), F = {AC → E, B → D, E → A}

List all candidate keys.

Question No: 17

Suppose that you are given a relation R = (A,B,C,D,E) with the following functional
dependencies: {CE → D,D → B,C → A}

Find all candidate keys.

Question No: 18

Suppose that you are given a relation R = (A,B,C,D,E) with the following functional
dependencies:

{BC → ADE, D → B}.

Find all candidate keys.


Question No: 19

You are given the following set of functional dependencies for a relation R(A,B,C,D,E,F),

F = {AB → C, DC → AE, E → F}.

What are the keys of this relation?

Question No: 20

Consider a relation R(A, B, C, D, E) with FD's AB → C, CD → E, C → A, C → D, D → B.

Determine all the keys of relation R. Do not list super keys that are not a candidate key.

Question 21:

Consider the following transactions with data items P and Q initialized to zero:

T1: read (P) ;

read (Q) ;

if P = 0 then Q : = Q + 1 ;

write (Q) ;

T2: read (Q) ;

read (P) ;

if Q = 0 then P : = P + 1 ;

write (P) ;

Any non-serial interleaving of T1 and T2 for concurrent execution leads to a schedule that is not
conflict serializable. Explain

Question 22:

Consider the following schedule for transactions T1, T2 and T3: Create a serializable sequence
Question 23:

Consider the following four schedules due to three transactions (indicated by the subscript) using
read and write on a data item x, denoted by r(x) and w(x) respectively. Which one of them is conflict
serializable? Explain

Question 24:

Consider the transactions T1, T2, and T3 and the schedules S1 and S2 given below.

T1: r1(X); r1(Z); w1(X); w1(Z)

T2: r2(Y); r2(Z); w2(Z)

T3: r3(Y); r3(X); w3(Y)


S1: r1(X); r3(Y); r3(X); r2(Y); r2(Z);

w3(Y); w2(Z); r1(Z); w1(X); w1(Z)

S2: r1(X); r3(Y); r2(Y); r3(X); r1(Z);

r2(Z); w3(Y); w1(X); w2(Z); w1(Z)

Which is Conflict Serializable? Explain

Question 25:

Consider three data items D1, D2 and D3 and the following execution schedule of transactions T1, T2
and T3. In the diagram, R(D) and W(D) denote the actions reading and writing the data item D
respectively. Create a serializable sequence

Question 26:

person (driver-id, name, address)

car (license, year, model)

accident (report-number, location, date)

owns (driver-id, license)

participated (report-number driver-id, license, damage-amount)

employee (person-name, street, city)

works (person-name, company-name, salary)

company (company-name, city)

manages (person-name, manager-name)

Give an expression in the relational algebra to express each of the following


queries:

a. Find the names of all employees who work for First Bank Corporation.
b. Find the names and cities of residence of all employees who work for First Bank
Corporation.

c. Find the names, street address, and cities of residence of all employees who work for
First Bank Corporation and earn more than $10,000 per annum.

d. Find the names of all employees in this database who live in the same city as the
company for which they work.

e. Find the names of all employees who live in the same city and on the same street as
do their managers.

f. Find the names of all employees in this database who do not work for First Bank
Corporation.

g. Find the names of all employees who earn more than every employee of Small Bank
Corporation.

h. Assume the companies may be located in several cities. Find all companies located in
every city in which Small Bank Corporation is located.

Question No: 27

person (driver-id, name, address)

car (license, year, model)

accident (report-number, location, date)

owns (driver-id, license)

participated (report-number driver-id, license, damage-amount)

employee (person-name, street, city)

works (person-name, company-name, salary)

company (company-name, city)

manages (person-name, manager-name)

Give an expression in the relational algebra for each request:


a. Modify the database so that Jones now lives in Newtown.
b. Give all employees of First Bank Corporation a 10 percent salary raise.
c. Give all managers in this database a 10 percent salary raise.
d. Give allmanagers in this database a 10 percent salary raise, unless the salary would
be greater than $100,000. In such cases, give only a 3 percent raise.
e. Delete all tuples in the works relation for employees of Small Bank Corporation.
Question No: 28

person (driver-id, name, address)

car (license, year, model)

accident (report-number, location, date)

owns (driver-id, license)

participated (report-number driver-id, license, damage-amount)

employee (person-name, street, city)

works (person-name, company-name, salary)

company (company-name, city)

manages (person-name, manager-name)

Give an expression in the relational algebra for each request:


a. Find the company with the most employees.

b. Find the company with the smallest payroll.

c. Find those companies whose employees earn a higher salary, on average, than the
average salary at First Bank Corporation.

Question No: 29

person (driver-id, name, address)

car (license, model, year)

accident (report-number, date, location)

owns (driver-id, license)

participated (driver-id, car, report-number, damage-amount)

Construct the following SQL queries for this relational database.

a. Find the total number of people who owned cars that were involved in accidents in 1989.

b. Find the number of accidents in which the cars belonging to “John Smith” were involved.

c. Add a new accident to the database; assume any values for required attributes.

d. Delete the Mazda belonging to “John Smith”.

e. Update the damage amount for the car with license number “AABB2000” in the accident
with report number “AR2197” to $3000.
Question No: 30 Overview and Features of db4

Question No: 31 Overview and Features of Mongo DB

Question No: 32 Overview and Features of Oracle NoSQL Database

Question No: 33 Overview and Features of Aerospike

Question No: 34 Overview and Features of Parallel Databases

Question No: 35 Overview and Features of Bridge SQL

Question No: 36 Overview and Features of Multidimensional Databases

Question No: 37 Business Intelligence and data warehousing trends

Question No: 38 Overview of different clustering techniques in data mining

Question No: 39 Overview of OLAP

Question No: 40 Overview of OLTP

Question No: 41 Overview of HBase

Question No: 42 Overview of Cassandra

Question No: 43 Overview of Neo4j

Question No: 44 Overview of CouchDB

Question No: 45 Overview of Memcached

Question No: 46 Overview of Redis


sid bid day
sid sname ratin age
g 22 101 10/10/98
Sailor Reservers
22 Dustin 7 45 22 102 10/10/98

29 Brutus 1 33 22 103 10/8/98

31 Lubber 8 55.5 22 104 10/7/98

32 Andy 8 25.5 31 102 11/10/98

58 Rusty 10 35 31 103 11/6/98

64 Horatio 7 35 31 104 11/12/98

71 Zorba 10 16 64 101 9/5/98

74 Horatio 9 35.0 64 102 9/8/98

74 103 9/8/98
85 Art 3 25.5

95 Bob 3 63.5

Boat

bid bname color

101 Interlake blue

102 Interlake red

103 Clipper green

104 Marine red

Using the above table write Relational Algebra Expression and SQL Query for the following

Question No: 47

1. Find the name and age of all sailors


2. Find all sailors with a rating above 7
3. Find the names of sailors who have reserved boat 103.
4. Find the names of sailors who have reserved a red boat
5. Find the colors of boats reserved by Lubber
Question No: 48

1. Find the names of sailors who have reserved at least one boat
2. Find the names of sailors who have reserved a red or a green boat.
3. Find the names of sailors who have reserved a red and green boat
4. Find the sids of all sailors who have reserved red boats but not green boats
5. Find the names of sailors who have not reserved a red boat

Question No: 49

1. Find the names of sailors who have reserved at least two boats.
2. Find the sids of sailors with age over 20 who have not reserved a red boat.
3. Find the names of sailors who have reserved all boats.
4. Find the names of sailors who have reserved all boats called Interlake
5. Find sailors whose rating is better than some sailor called Horatio

Question No: 50

1. Find the average age of all sailors


2. Find the average age of sailors with a rating of 10
3. Find the name and age of the oldest sailor
4. Count the number of sailors
5. Count the number of distinct sailors

Question No: 51

1. Find the age of the youngest sailor for each rating level.
2. Find the age of the youngest sailor who is eligible to vote (i.e., is at least 18 years old) for each rating
level with at least two such sailors.
3. For each red boat, find the number of reservations for this boat
4. Find the average age of sailors for each rating level that has at least two sailors.

Question No: 52

Construct a B+-tree for the following set of key values:

(2, 3, 5, 7, 11, 17, 19, 23, 29, 31)

Assume that the tree is initially empty and values are added in ascending order. Construct B+-trees for the
cases where the number of pointers that will fit in one node is as follows:

a. Four

b. Six

c. Eight

Question No: 53 Overview and Features of Dsitibuted Databases

Question No: 54 Explain B+ Tree files structures with an example

You might also like