Give an example of an update that is definitely slowed

Assignment Help Database Management System
Reference no: EM13509505

1.Consider the following relation:

Emp(eid: integer, sal: integer, age: real, did: integer)

There is a clustered index on eid and an unclustered index on age.

1. How would you use the indexes to enforce the constraint that eid is a key?

2. Give an example of an update that is definitely speeded up because of the available indexes. (English description is suficient.)

3. Give an example of an update that is definitely slowed down because of the indexes. (English description is suficient.)

4. Can you give an example of an update that is neither speeded up nor slowed down by the indexes?

2.Consider a delete specified using an equality condition. For each of the five file organizations, what is the cost if no record qualifies? What is the cost if the condition is not on a key?

3.(Due to Jeff Derstadt) TechnoBooks.com is in the process of reorganiz-ing its website. A major issue is how to effciently handle a large number of search results. In a human interaction study, it found that modem users typically like to view 20 search results at a time, and it would like to program this logic into the system. Queries that return batches of sorted results are called top N queries. (See Section 23 for a discussion of database support for top N queries.) For example, results 1-20 are returned, then results 21-40, then 41-60, and so on. Different techniques are used for performing top N queries and TechnoBooks.com would like you to implement two of them.

 Infrastructure:    Create a database with a table called Books and populate it with some books, using the format that follows. This gives you 111 books in your database with a title of AAA, BBB, CCC, DDD, or EEE, but the keys are not sequential for books with the same title.

 Books(bookid: INTEGER, title: CHAR(80), author: CHAR(80), price: REAL)

For i = 1 to 111 { 

Insert the tuple (i, AAA, AAA Author, 5.99) i = i + 1

Insert the tuple (i, BBB, BBB Author, 5.99) i = i + 1

Insert the tuple (i, CCC, CCC Author, 5.99) i = i + 1

Insert the tuple (i, DDD, DDD Author, 5.99) i = i + 1

Insert the tuple (i, EEE, EEE Author, 5.99) }

Placeholder Technique:The simplest approach to top N queries is to store a placeholder for the ?rst and last result tuples, and then perform the same query. When the new query results are returned, you can iterate to the placeholders and return the previous or next 20 results.

Tuples Show Lower Placeholder Previous Set Upper Placeholder Next Set

1-20 1 None  20 21-40

21-40  21 1-20  40 41-60

41-60 41 21-40 60 61-80 

Write a webpage in JSP that displays the contents of the Books table, sorted by the Title and BookId, and showing the results 20 at a time. There should be a link (where appropriate) to get the previous 20 results or the next 20 results. To do this, you can encode the placeholders in the Previous or Next Links as follows. Assume that you are displaying records 21–40. Then the previous link is display.jsp?lower=21 and the next link is display.jsp?upper=40.

You should not display a previous link when there are no previous results; nor should you show a Next link if there are no more results. When your page is called again to get another batch of results, you can perform the same query to get all the records, iterate through the result set until you are at the proper starting point, then display 20 more results.

What are the advantages and disadvantages of this technique?

.Query Constraints Technique:  A second technique for performing top N queries is to push boundary constraints into the query (in the WHERE clause) so that the query returns only results that have not yet been displayed. Although this changes the query, fewer results are returned and it saves the cost of iterating up to the boundary. For example, consider the following table, sorted by (title, primary key).

Batch Result Number Title Primary Key

1 1 AAA 105

1 2 BBB 13

1 3 CCC 48

1 4 DDD 52

1 5 DDD 101

2 6 ddd 121

2 7 EEE 19

2 8 EEE 68

2 9 FFF 2

2 10 FFF 33

3 11 FFF 58

3 12 FFF 59

3 13 GGG 93

3 14 HHH 132

3 15 HHH 135

In batch 1, rows 1 through 5 are displayed, in batch 2 rows 6 through 10 are displayed, and so on. Using the placeholder technique, all 15 results would be returned for each batch. Using the constraint technique, batch 1 displays results 1-5 but returns results 1-15, batch 2 will display results 6-10 but returns only results 6-15, and batch 3 will display results 11-15 but return only results 11-15. 

The constraint can be pushed into the query because of the sorting of this table. Consider the following query for batch 2 (displaying results 6-10): 

EXEC SQL SELECT B.Title FROBooks B

WHERE        (B.Title = DDD AND B.BookId > 101) OR (B.Title > DDD) ORDER BY B.Title, B.BookId

This query ?rst selects all books with the title DDD, but with a primary key that is greater than that of record 5 (record 5 has a primary key of 101). This returns record 6. Also, any book that has a title after ‘DDD alphabetically is returned. You can then display the ?rst ?ve results. 

The following information needs to be retained to have Previous and Next buttons that return more results: 

Previous: The title of the ?rst record in the previous set, and the primary key of the ?rst record in the previous set. 

Next: The title of the ?rst record in the next set; the primary key of the ?rst record in the next set.

These four pieces of information can be encoded into the Previous and Next buttons as in the previous part. Using your database table from the ?rst part, write a JavaServer Page that displays the book information 20 records at a time. The page should include Previous and Next buttons to show the previous or next record set if there is one. Use the constraint query to get the Previous and Next record sets.

Exercise 8.6 Fill in the I/O costs in Figure.

File Type scan EqualitSearch RangSearch  Insert    Delete

Heap file

Sorted file

Clustered file

Unclustered tree index 

Unclustered hash index

figure:I/O Cost Comparison

Reference no: EM13509505

Questions Cloud

Major sociological theoretical paradigms : Identify the three major sociological theoretical paradigms. For each, what are its core questions? Which one do you relate to best? How can you use this particular paradigm to explain your decision to attend college?
How to change a tire-the federal budge : Write the name of the organizational pattern best suited to a speech on each of the following topics. In addition to listing the organizational pattern, give three main points that might be used to develop the topic.
What is the time required to read a ?le containing 100000 : What is the time required to read a ?le containing 100,000 records of 100 bytes each in a random order? To read a record, the block containing the record has to be fetched from disk. Assume that each block request incurs the average seek time and rot..
How many cylinders does the disk have : Consider a disk with a sector size of 512 bytes, 2000 tracks per surface, 50 sectors per track, ?ve double-sided platters, and average seek time of 10 msec.
Give an example of an update that is definitely slowed : The title of the ?rst record in the previous set, and the primary key of the ?rst record in the previous set.
Search for a record based on a particular field value : For each of the following queries, which of the listed index choices would you choose to speed up the query? If your database system does not consider index-only plans (i.e., data records are always retrieved even if enough information is available i..
Prepare a new contribution format segmented income statement : Prepare a new contribution format segmented income statement for the month. Adjust the allocation of equipment depreciation and warehouse rent as indicated by the additional information provided.
Obtain the magnitude of the force : Two blocks, each with weightw, are held in place on a frictionless incline in terms ofwand the angleaof the incline. Calculate the magnitude of the force that the incline exerts on each block in N
Vivians medical expenses paid by the johnsons : Can you report on Schedule A Vivian's medical expenses paid by the Johnsons - Are expenses to prepare you for a new trade or business deductible?

Reviews

Write a Review

Database Management System Questions & Answers

  Program to build a database concerning employee information

Company XYZ needs a program to build a database concerning employee information.

  Advantages and inconveniences of new relational scheme

Compare activity (quite theoretical) of the disk (in number of bytes) required for each of both relational. Write down the advantages and inconveniences of new relational scheme.

  How protocol ensures serializability and deadlock freedom

To lock any other vertex, the transaction must have visited all the parents of that vertex and must be having a lock on one of the parents of the vertex. Show that the protocol ensures serializability and deadlock freedom.

  Explain components represented in cell using mccumber model

Suppose that the security model is required for protection of information in class. Using NSTISSC model, analyze each of cells (i.e. 27 cells related with McCumber model).

  Write procedures using counter and sychronisation techniques

Write the following procedures: woman_wants_to_enter, man_wants_to_enter, woman_leaves, man_leaves, using counters and sychronisation techniques to ensure that the correct behaviour will occur.

  Explain good strategy for processing queries

Explain a good strategy for processing each of following queries. Determine all machines at Almaden plant. Determine employee 1 machine.

  Identify the potential sale and department store transaction

Evaluate whether the use of a distributed DBMS structure is appropriate and identify the optimization techniques that should be factored in to enhance the operations of the database in your design.

  Show the view defnition statements for employeenames and

You want to authorize your secretary to ?re people (you will probably tell him whom to ?re, but you want to be able to delegate thistask), to check on who is an employee, and to check on average department salaries. What privileges should you grant?

  Create a clustered index on the groupid column

Write the CREATE INDEX statements to create a clustered index on the GroupID column and a nonclustered index on the IndividuallD column of the GroupMembership table.

  Problem1 assumethefollowingsimpleb-treewithn4this tree

problem1 assumethefollowingsimpleb-treewithn4this tree consists of only a root node and three leaf nodes. recall that

  Analyse the behaviour of the most important stateful object

Analyse the behaviour of the most important stateful object of the system and document this behaviour with.

  List all the functional dependencies that this relation

Assume that the value of attribute Z of the last record in the relation is changed from z3 to z2. Now list all the functional dependenciesthat this relation instance satis?es.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd