Need help with DBMS query processing? Check out Q1 and Q2 for assistance!

  • Thread starter momentum
  • Start date
  • Tags
    Processing
In summary: From the description, it seems like the blocks are read and copied into memory one after the other, in the same order as they appear in the file. This allows for an efficient scan and comparison with the other file for matching records."records are scanned ... each for matching with the other file"...This means that only the records from the blocks that have been copied into memory are scanned and compared with the records from the other file. This is how the equi-join operation works, by only selecting and outputting the matching records from the two files. This allows for a more efficient process as it avoids scanning and copying the entire files.
  • #1
momentum
111
0
This is written in my book.

Can you please reply to these queries in Q1 & Q2.

4Gl3cAB.jpg


I'm stuck on those
 

Attachments

  • 4Gl3cAB.jpg
    4Gl3cAB.jpg
    61.2 KB · Views: 652
Technology news on Phys.org
  • #2
1) A and B are attributes of relations R and S respectively. If you are thinking in terms of a spread sheet, then you could call them columns. If you are thinking of the relation as files and records, then they would be fields.
2) A DBMS is implemented as file(s). The records in those files is in some order - sorted or not.

For example:
R may be a relation that lists your customer and S may be a relation that is a phone directory.
R is implemented as a file named RF with records ordered by the "customer number" field.
S is implemented as a file names SF with records ordered by the "last name" and "first name" fields.

And say we want to do a "EQUIJOIN" between relation R, attribute "business phone" and relation S, attribute "number".
So this is what we do:
1a) If we already have an index into file RF that is sorted by "business phone", then we skip to step 2.
1b) We build an index into the records in RF that includes field "business phone".
1c) We sort that index by "business phone".

2a) If we already have an index into file SF that is sorted by "number", then we skip to step 3.
2b) We build an index into the records in SF that includes field "number".
2c) We sort that index by "number".

3) We step through those two sorted indexes looking for matches.

Relational terms: relation, tuple, attribute
File terms: file, record, fields.
Spreadsheet terms: sheet, row, column
 
Last edited:
  • #3
momentum said:
This is written in my book.

What book?
 
  • #4
.Scott said:
1) A and B are attributes of relations R and S respectively. If you are thinking in terms of a spread sheet, then you could call them columns. If you are thinking of the relation as files and records, then they would be fields.
2) A DBMS is implemented as file(s). The records in those files is in some order - sorted or not.

For example:
R may be a relation that lists your customer and S may be a relation that is a phone directory.
R is implemented as a file named RF with records ordered by the "customer number" field.
S is implemented as a file names SF with records ordered by the "last name" and "first name" fields.

And say we want to do a "EQUIJOIN" between relation R, attribute "business phone" and relation S, attribute "number".
So this is what we do:
1a) If we already have an index into file RF that is sorted by "business phone", then we skip to step 2.
1b) We build an index into the records in RF that includes field "business phone".
1c) We sort that index by "business phone".

2a) If we already have an index into file SF that is sorted by "number", then we skip to step 3.
2b) We build an index into the records in SF that includes field "number".
2c) We sort that index by "number".

3) We step through those two sorted indexes looking for matches.

Relational terms: relation, tuple, attribute
File terms: file, record, fields.
Spreadsheet terms: sheet, row, column

okay. But it says "Pair of file blocks" (marked in red) . What is this ? Could you please elaborate this part a bit
T6yz7ID.jpg
 

Attachments

  • T6yz7ID.jpg
    T6yz7ID.jpg
    75 KB · Views: 281
  • #5
momentum said:
okay. But it says "Pair of file blocks" (marked in red) . What is this ? Could you please elaborate this part a bit
What I described was an index sort. In their description, they are creating two files, one from relation R the other from S. Both are sorted.
They are then reading from each of these files, a block at a time. Blocks are the smallest unit that can be read from the file system - typically 512, 1K, 2K, or 4K bytes. So it will read one block from R and one block from S - thus a pair.
 
  • #6
.Scott said:
What I described was an index sort. In their description, they are creating two files, one from relation R the other from S. Both are sorted.
They are then reading from each of these files, a block at a time. Blocks are the smallest unit that can be read from the file system - typically 512, 1K, 2K, or 4K bytes. So it will read one block from R and one block from S - thus a pair.

Okay. this is better.

Some more doubts on this.

They also said

"blocks are copied into memory in order " ---------> what does it mean by in order here ? Is not they are copied separately

"
records are scanned ... each for matching with the other file" -------> does it mean only the matching records (i.e output from join) are copied ? Not the entire R & S is copied ?
 
  • #7
momentum said:
"blocks are copied into memory in order " ---------> what does it mean by in order here ? Is not they are copied separately

First the first block of R is read into memory. Once it's clear that there are no more mathches with S possible for this block, the next block is read from the file.

"records are scanned ... each for matching with the other file" -------> does it mean only the matching records (i.e output from join) are copied ? Not the entire R & S is copied ?

Only the matching records are copied. Thats is the idea with an equi-join.

The whole description of a merge-join looks like something of 50 years ago, with tape drives and very small memories. The only thing that seems to be relevant for the runtime, is the time to read or write a block. Nowadays you try to read as much as possible of the files into memory while sorting them. A temporary index will likely be created instead of sorting the files themselves, because only the index column would have to be loaded into memory.
 
  • #8
momentum said:
"blocks are copied into memory in order " ---------> what does it mean by in order here ?
It probably means "in sequence". That is, blocks are read from each file in the same (linear) sequence in which they are stored: record #1, record #2, record #3, etc.
 
  • #9
Thanks . That was very much helpful.

Please see this below.

KAqzdDC.jpg
 

Attachments

  • KAqzdDC.jpg
    KAqzdDC.jpg
    60.4 KB · Views: 234

1. What is query processing in DBMS?

Query processing in DBMS refers to the process of executing a user's query or request for data retrieval from a database. It involves several steps such as parsing the query, creating an execution plan, and retrieving the requested data from the database.

2. What is the role of a query optimizer in query processing?

A query optimizer is an important component of query processing in DBMS. Its role is to analyze the user's query and determine the most efficient way to retrieve the requested data from the database. It takes into account factors such as available indexes, data distribution, and query statistics to generate the best execution plan for the query.

3. What are the different stages of query processing?

Query processing in DBMS involves four main stages: parsing, optimization, code generation, and execution. In the parsing stage, the query is checked for syntax and semantics. The optimization stage involves creating an optimal execution plan for the query. The generated code is then executed in the code generation stage, and the results are retrieved in the execution stage.

4. How does indexing impact query processing?

Indexing is a technique used to improve the performance of query processing in DBMS. It creates a data structure that allows for faster data retrieval by providing a direct path to the requested data. This reduces the need for full-table scans and can significantly improve the speed of query processing.

5. What are the common challenges in query processing in DBMS?

Some of the common challenges in query processing in DBMS include handling complex queries, dealing with large datasets, and optimizing performance for multiple users accessing the same database simultaneously. Query processing also requires careful resource management to ensure efficient use of system resources such as memory and processing power.

Similar threads

  • Biology and Medical
Replies
13
Views
1K
  • Introductory Physics Homework Help
Replies
9
Views
1K
  • Introductory Physics Homework Help
Replies
2
Views
725
  • Introductory Physics Homework Help
Replies
3
Views
3K
  • Precalculus Mathematics Homework Help
Replies
4
Views
2K
  • Electrical Engineering
Replies
5
Views
1K
  • Programming and Computer Science
Replies
6
Views
3K
  • Programming and Computer Science
Replies
1
Views
3K
  • Introductory Physics Homework Help
Replies
3
Views
2K
  • Programming and Computer Science
Replies
2
Views
3K
Back
Top