Vous êtes sur la page 1sur 9

ADVANCED DATABASE MANAGEMENT SYSTEM ASSIGNMENT Name: Shruti Mehrotra Roll No.

: 2011VLSI-03
Q1. Consider a database that is used to record the marks that the students get in different exams of different course offerings (sections). a. Construct an E-R diagram that models exams as entities, and uses a ternary relationship for the database. b. Construct an alternative E-R diagram that uses only a binary relationship between student and section. Make sure that only one relationship exists between a particular student and section pair, yet you can represent the marks that a student gets in different exams. Ans. a. The E-R diagram modelling exams as entities using a ternary relationship is: ID Name Time Location

Student

Takes exam

Class

Department

Course No.

Grade

Exam

b. The E-R diagram using binary relationships between students and course offerings is: Final Grade ID Name Time

Location

Student

Takes course

Class

Quiz1 Grade

Department

Course No.

Quiz2 Grade Midterm Exam Grade

Q2. Consider the representation of a ternary relationship using binary relationships as shown below:

RA

RB

RC

a. Show a simple instance of E,A,B,C,RA,RB and RC that cannot correspond to any instance of R. b. Modify the E-R diagram to introduce the constraints that will guarantee that any instance of E,A,B,C,RA,RB and RC that satisfies the constraints that will correspond to an instance of A,B,C ,and R. c. Modify the translation to above handle total participation constraints on the ternary relationship. d. The above representation requires that we create a primary key attribute for E. Show how to treat E as a weak entity set so that a primary key attribute is not required.

Ans. a. Let E={e1,e2}, A={a1,a2}, B={b1}, C={c1}, RA={(e1,a1),(e2,a2)}, RB={(e1,b1)} and RC={(e1,c1)}. Because of (e2,a2), no instance of R exists which corresponds to E, RA, RB and RC. b. Total participation constraints have been introduced between E and the relationships RA, RB and RC so that every tuple in E has a relationship with A, B and C. A

RA

RB

RA

c. Suppose A totally participates in relationship R, then introduce a total participation constraint between A and RA.

d. Consider E as a weak entity set and RA, RB and RC as its identifying relationship sets.

RA RA

B B

RB

RC A

C C

Q3. Draw an E-R diagram to represent the genealogy. Ans. The E-R diagram for genealogy is:

Address

Gender Name Name Job ID Address Is a ID Address Is a ID Name Child Mother Father Age Father Mother Father

Mother

Is a

Person

Name

Father Mother

ID

Q4. Perform Normalization of the following relation: Name, Address, Favourite Paper, Papers liked, Publisher. Ans. In this relation, name can be a primary key. Address and favourite paper may be redundant. Normalized form: Name, Address, Favourite paper Name, Papers liked, Publisher Papers liked, Publisher

Q5. Why do database systems support concurrent execution of transactions, inspite of the extra programming effort needed to ensure that concurrent execution does not cause any problems? Ans. Concurrent execution of transactions improves throughput of transactions and system utilization, and also reduces waiting time of transactions. But when several transactions execute concurrently in a database, the consistency of data may no longer be preserved. Therefore, it is necessary for the system to control the interaction among the concurrent transactions which is achieved through concurrency control. Q6. Consider the following graph based locking protocol that allows only exclusive mode locks modes, and that operates on data graphs that are in the form of a rooted directed acyclic graph. y A transaction can lock any vertex first. y To lock any other vertex, the transaction must have visited all the parents of that vertex, and must be holding a lock on one of the parents of the vertex. Show that the protocol ensures serializability and deadlock freedom. Ans. Since the transaction can lock any vertex after the first one only if it has visited all the parents and is holding a lock on one of the parents and since locking is allowed only in exclusive mode, no other transaction can hold a lock on those vertices. Thus, deadlock cannot occur as no other transaction shall be

kept waiting. Also, serializability is ensured as only one transaction after the other will be able to proceed, because until exclusive mode locks are released, the locked vertices cannot be accessed by any other transaction. Q7. (XML coding) Ans. The XML code is: >XML2Rel t file.xml file_tbl: PRE 1 2 3 4 5 6 7 8 9 10 11 12 POST 12 2 1 7 4 3 6 5 9 8 11 10 LEVEL TAG TEXT 1 book null 2 title null 3 null TCP/IP Illustrated 2 author null 3 last null 4 null Stevens 3 first null 4 null John 2 publisher null 3 null Addison-Wesley 2 price null 3 null 65.95

book_attr: PRE 1 1 11 ATTRIB isbn year currency VALUE 1-2345-6789-0 1994 USD

>XML2Rel p file.xml CREATE TABLE file_tbl( pre INTEGER PRIMARY KEY, post INTEGER, parent INTEGER, tag VARCHAR(256),

text VARCHAR(1000) ); CREATE TABLE file_attr( pre INTEGER REFERENCES file_tbl (pre), attr VARCHAR(256), value VARCHAR(1000), ); INSERT INTO file_tbl(pre, post, tag, text) VALUES(1,12, null, book, null); INSERT INTO file_tbl(pre, post, tag, text) VALUES(2,2,1, title, null); INSERT INTO file_tbl(pre, post, tag, text) VALUES(3, 1,2, null, TCP/IP Illustrated); INSERT INTO file_tbl(pre, post, tag, text) VALUES(4, 7, 1, author, null); INSERT INTO file_tbl(pre, post, tag, text) VALUES(5, 4, 4, last, null); INSERT INTO file_tbl(pre, post, tag, text) VALUES(6, 3, 5, null, Stevens); INSERT INTO file_tbl(pre, post, tag, text) VALUES(7, 6, 4, first, null); INSERT INTO file_tbl(pre, post, tag, text) VALUES(9, 9, 1, Publisher, null); INSERT INTO file_tbl(pre, post, tag, text)

VALUES(10, 8, 9 null, Addison-Wesley); INSERT INTO file_tbl(pre, post, tag, text) VALUES(11, 11, 1, price, null); INSERT INTO file_tbl(pre, post, tag, text) VALUES(12,10,11, null, 65.95); INSERT INTO file_tbl(pre, attr, value) VALUES(1,isbn, 1-2345-6789-0); INSERT INTO file_tbl(pre, attr, value) VALUES(1, year, 1994); INSERT INTO file_tbl(pre, attr, value) VALUES(11, currency, USD); <author> <last> Stevens </last> <first> John </first> </author>