Assignment DBDA Preeti
Assignment DBDA Preeti
Assignment DBDA Preeti
Note:
1. The students in class are divided into groups, each group is assigned with 5
questions
2. Each individual in that group should answer all the 5 questions separately
3. Assignment should be hand written( no print outs) in A-4 size sheets
4. The cover page should contain Name,ID, Group No
5. The sheets need to be stapled and submitted( no files/folders)
6. Specify the question numbers properly as in the question sheet, do not start
from 1,2...
7. The last date for submission of assignment is strictly on or before: 5th Dec 2015
COURSE No. & Title: SESAP ZG518 Database Design and Applications
Assignment (Set 1)
2. Suppose we have the following requirements for a university database that is used to
keep track of students’ transcripts:
(a) The university keeps track of each student’s name (SNAME), student number
(SNUM),social security number (SSSN), current address (SCADDR) and phone
(SCPHONE),permanent address (SPADDR) and phone (SPPHONE), birthdate (BDATE),
sex (SEX),class (CLASS) (freshman, sophomore, ..., graduate), major department
(MAJORDEPTCODE),minor department (MINORDEPTCODE) (if any), and degree
program (PROG)(B.A., B.S., ..., Ph.D.). Both ssn and student number have unique
values for each student.
(b) Each department is described by a name (DEPTNAME), department code
(DEPTCODE),office number (DEPTOFFICE), office phone (DEPTPHONE), and college
(DEPTCOLLEGE). Both name and code have unique values for each department.
(c) Each course has a course name (CNAME), description (CDESC), code number
(CNUM),number of semester hours (CREDIT), level (LEVEL), and offering department
(CDEPT).The value of code number is unique for each course.
(d) Each section has an instructor (INSTUCTORNAME), semester (SEMESTER), year
(YEAR), course (SECCOURSE), and section number (SECNUM). Section numbers
distinguish different sections of the same course that are taught during the same
semester/year; its values are 1, 2, 3, ...; up to the number of sections taught during
each semester.
(e) A grade record refers to a student (Ssn), refers to a particular section, and grade
(GRADE).
Design an relational database schema for this database application. First show all the
functional dependencies that should hold among the attributes. Then, design relation
schemas for the database that are each in 3NF or BCNF. Specify the key attributes of
each relation. Note any unspecified requirements, and make appropriate assumptions
to make the specification complete.
3. Consider the LIBRARY relational database schema of Figure 4.6. Choose the
appropriate action (reject, cascade, set to null, set to default) for each referential
integrity constraint, both for the deletion of a referenced tuple, and for the update of a
primary key attribute value in a referenced tuple. Justify your choices.
4. How many serial schedules exist for the three transactions in Figure 20.8 (a)? What
are they? What is the total number of possible schedules?
5. Exercise 5.2 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 Catalog relation lists the prices charged for parts by Suppliers. Write the following
queries in SQL:
1. Find the pnames of parts for which there is some supplier.
2. Find the snames of suppliers who supply every part.
3. Find the snames of suppliers who supply every red part.
4. Find the pnames of parts supplied by Acme Widget Suppliers and no one else.
5. Find the sids of suppliers who charge more for some part than the average cost of
that part (averaged over all the suppliers who supply that part).
6. For each part, find the sname of the supplier who charges the most for that part.
7. Find the sids of suppliers who supply only red parts.
8. Find the sids of suppliers who supply a red part and a green part.
COURSE No. & Title: : SESAP ZG518 Database Design and Applications
Assignment (Set 2)
1. What is the difference between attributes and elements in XML? List some of
the important attributes used to specify elements in XML schema.
2. Write appropriate SQL DDL statements for declaring the LIBRARY relational database
schema of Figure 4.6. Specify the keys and referential triggered actions.
3. Consider the three transactions T1, T2, and T3, and the schedules S1 and S2 given
below.Draw the serializibility (precedence) graphs for S1 and S2 and state whether
each schedule is serializable or not. If a schedule is serializable, write down the
equivalent serial schedule(s).
T1: r1(x); r1(z); w1(x)
T2: r2(z); r2(y); w2(z); w2(y)
T3: r3(x); r3(y); w3(y)
S1: r1(x); r2(z); r1(x); r3(x); r3(y); w1(x); w3(y); r2(y); w2(z); w2(y)
S2: r1(x); r2(z); r3(x); r1(z); r2(y); r3(y); w1(x); w2(z); w3(y); w2(y)
4. Suppose that the following search field values are deleted, in the given order, from the
B+tree of Exercise 17.19, show how the tree will shrink and show the final tree. The
deleted values are: 65, 75, 43, 18, 20, 92, 59, 37.
5. Consider the following relational schema. An employee can work in more than one
department; the pct time field of the Works relation shows the percentage of time that a
given employee works in a given department.
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pct time: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer)
Write the following queries in SQL:
1. Print the names and ages of each employee who works in both the Hardware
department and the Software department.
2. For each department with more than 20 full-time-equivalent employees (i.e., where
the part-time and full-time employees add up to at least that many full-time
employees), print the did together with the number of employees that work in
that department.
3. Print the name of each employee whose salary exceeds the budget of all of the
departments that he or she works in.
4. Find the managerids of managers who manage only departments with budgets
greater than $1 million.
5. Find the enames of managers who manage the departments with the largest budgets.
6. If a manager manages more than one department, he or she controls the sum of all
the budgets for those departments. Find the managerids of managers who control
more than $5 million.
COURSE No. & Title: : SESAP ZG518 Database Design and Applications
Assignment (Set 3)
4 A PARTS file with Part# as key field includes records with the following Part# values:
23,65, 37, 60, 46, 92, 48, 71, 56, 59, 18, 21, 10, 74, 78, 15, 16, 20, 24, 28, 39, 43,
47, 50, 69, 75,8, 49, 33, 38. Suppose the search field values are inserted in the given
order in a B + -treeof order p=4 and p leaf =3; show how the tree will expand and
what the final tree looks like.
COURSE No. & Title: : SESAP ZG518 Database Design and Applications
Assignment (Set 4)
1. What are the differences between the use of tags in XML versus HTML?
2. Consider the following relations for an order-processing application database at ABC,
Inc.
ORDER (O#, Odate, Cust#, Total_amount)
ORDER-ITEM (O#, I#, Qty_ordered, Total_price, Discount%)
Assume that each item has a different discount. The Total_price refers to one item,
Odate is the date on which the order was placed, and the Total_amount is the amount
of the order. If we apply a natural join on the relations Order-Item and Order in this
database, what does the resulting relation schema look like? What will be its key?
Show the FDs in this resulting relation. Is it in 2NF? Is it in 3NF? Why or why not? (
State assumptions, if you make any )
3. Load the records with hash keys – 24, 31, 48, 65, 33, 86, 8, 51, 4, 30,16,24,70 in
the same order, into an expandable hash file using Linear hashing technique. The
family of hash functions used are- h0 (K mod 2), h1 (K mod 4), h2 (K mod 8), and so
on, where K is the hash key value.
Assume that each bucket can accommodate two records. Show the dynamic
structure of the hashing scheme after each insertion (complete working is needed)
4. Consider the instance of Sailors shown in Figure 5.1(Raghu Ramakrishna- DATABASE
MANAGEMENT SYSTEMS). Let us define instance S1 of Sailors to consist of the first
two tuples, instance S2 to be the last two tuples, and
S to be the given instance.
(a) Show the left outer join of S with itself, with the join condition being sid=sid.
(b) Show the right outer join of S with itself, with the join condition being
sid=sid.
(c) Show the full outer join of S with itself, with the join condition being sid=sid.
(d) Show the left outer join of S1 with S2, with the join condition being sid=sid.
(e) Show the right outer join of S1 with S2, with the join condition being sid=sid.
(f) Show the full outer join of S1 with S2, with the join condition being sid=sid.
COURSE No. & Title: : SESAP ZG518 Database Design and Applications
Assignment (Set 5)
4. Consider the following set of requirements for a UNIVERSITY database that is used to
keep track of students’ transcripts. This is similar but not identical to the database shown
in Figure 1.2:
(a) The university keeps track of each student’s name, student number, social security
number, current address and phone, permanent address and phone, birthdate, sex, class
(freshman, sophomore, ..., graduate), major department, minor department (if any), and
degree program (B.A., B.S., ..., Ph.D.). Some user applications need to refer to the city,
state, and zip of the student’s permanent address, and to the student’s last name. Both
social security number and student number have unique values for each student.
(b) Each department is described by a name, department code, office number, office
phone, and college. Both name and code have unique values for each department.
(c) Each course has a course name, description, course number, number of semester
hours, level, and offering department. The value of course number is unique for each
course.
(d) Each section has an instructor, semester, year, course, and section number. The
section number distinguishes different sections of the same course that are taught during
the same semester/year; its values are 1, 2, 3, ..., up to the number of sections taught
during each semester.
(e) A grade report has a student, section, letter grade, and numeric grade (0, 1, 2, 3, 4 for
F, D, C, B, A, respectively).
Design an ER schema for this application, and draw an ER diagram for that schema.
Specify key attributes of each entity type and structural constraints on each relationship
type. Note any unspecified requirements, and make appropriate assumptions to make the
specification complete.
5. you were about to create an index on a relation, what considerations
would guide your choice? Discuss:
1. The choice of primary index.
2. Clustered versus unclustered indexes.
3. Hash versus tree indexes.
4. The use of a sorted file rather than a tree-based index.
5. Choice of search key for the index. What is a composite search key, and what
considerations are made in choosing composite search keys? What are index-only
plans, and what is the influence of potential index-only evaluation plans on the
choice of search key for an index?
COURSE No. & Title: : SESAP ZG518 Database Design and Applications
Assignment (Set 6 )
4. Figure 9.8 shows an ER schema for a database that can be used to keep track
of transport ships and their locations for maritime authorities. Map this
schema into a relational schema and specify all primary keys and foreign
keys.
5. Consider the following relational schema. An employee can work in more than one
department; the pct time field of the Works relation shows the percentage of time that
a given employee works in a given department.
Emp(eid: integer, ename: string, age: integer, salary: real)
Works(eid: integer, did: integer, pct time: integer)
Dept(did: integer, dname: string, budget: real, managerid: integer)
Write the following queries in SQL:
1. Print the names and ages of each employee who works in both the Hardware
department and the Software department.
2. For each department with more than 20 full-time-equivalent employees (i.e., where
the part-time and full-time employees add up to at least that many full-time
employees), print the did together with the number of employees that work in
that department.
3. Print the name of each employee whose salary exceeds the budget of all of the
departments that he or she works in.
4. Find the managerids of managers who manage only departments with budgets
greater than $1 million.
5. Find the enames of managers who manage the departments with the largest
budgets.
6. If a manager manages more than one department, he or she controls the sum of all
the budgets for those departments. Find the managerids of managers who control
more than $5 million.
COURSE No. & Title: : SESAP ZG518 Database Design and Applications
Assignment (Set 8)