0% found this document useful (0 votes)
43 views11 pages

Week 9-10 Managing Control and Redo Log File

This document discusses several topics related to database management including: 1. Maintaining control and log files, which record database modifications to enable rolling back transactions if failures occur. 2. Indexed file organization, including how indexes can locate information fast by sorting data and assigning IDs to rows. 3. Transaction logs that record all database modifications in a separate log file to prevent data corruption during failures or restores. 4. Virtual log files that the transaction log is split into for efficient logging as the files fill up.

Uploaded by

Hamza Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views11 pages

Week 9-10 Managing Control and Redo Log File

This document discusses several topics related to database management including: 1. Maintaining control and log files, which record database modifications to enable rolling back transactions if failures occur. 2. Indexed file organization, including how indexes can locate information fast by sorting data and assigning IDs to rows. 3. Transaction logs that record all database modifications in a separate log file to prevent data corruption during failures or restores. 4. Virtual log files that the transaction log is split into for efficient logging as the files fill up.

Uploaded by

Hamza Hassan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Week 9-10 Managing

Control and Redo Log file


Maintaining the control and log files
Managing Tables and indexes
Maintaining data integrity constraints
Indexed file organization
• The SQL INDEX does the following :
• INDEXES can locate information within a database very fast.
• An INDEX makes a catalog of rows of a database table as row can be pointed within a fraction of the
time with a minimum effort.
• A table INDEX is a database structure which arranges the values of one or more columns in a
specific order.
• The performance of an INDEX can not be recognized much when dealing with relatively small
tables.
• INDEX can work properly and quickly for the columns that have many different values.
• It takes a long time to find an information for one or combination of columns from a table when there
are thousands of records in the table. In that case, if indexes are created on that column, which are
accessed frequently, the information can be retrieved quickly.
• The INDEX first sorts the data and then it assigns an identification for each row.
• The INDEX table having only two columns, one is a rowid and another is indexed-column (ordered).
• When data is retrieved from a database table based on the indexed column, the index pointer searches
the rowid and quickly locates that position.in the actual table and display, the rows sought for.
Indexed File Organization

 To access a record in a file randomly,


you need to know the address of the record.
 An index file can relate the key to the record address.
Indexed files
• An index file is made of a data file, which is a sequential file, and
an index.
• Index – a small file with only two fields:
• The key of the sequential file
• The address of the corresponding record on the disk.
• To access a record in the file :
1. Load the entire index file into main memory.
2. Search the index file to find the desired key.
3. Retrieve the address the record.
4. Retrieve the data record. (using the address)

• Inverted file –
you can have more than one index, each with a different key.
Inverted file
• A file that reorganizes the structure of an existing data file to enable a rapid search
to be made for all records having one field falling within set limits.

• For example, a file used by an estate agent might store records on each house for
sale, using a reference number as the key field for sorting. One field in each
record would be the asking price of the house. To speed up the process of drawing
up lists of houses falling within certain price ranges, an inverted file might be
created in which the records are rearranged according to price. Each record would
consist of an asking price, followed by the reference numbers of all the houses
offered for sale at this approximate price.
Figure 13-6 Logical view of an indexed file
File Organization and Indexing

Index:
 An alphabetical list of names,
subjects, etc. with reference to their
page(s) number

7
File Organization and Indexing

8
Log files
• The transaction log is an integral part of SQL Server. Every database
has a transaction log that is stored within the log file that is separate
from the data file. A transaction log basically records all database
modifications. When a user issues an INSERT, for example, it is logged
in the transaction log. This enables the database to roll back or
restore the transaction if a failure were to occur and prevents data
corruption.
• For example, let’s say Ahmad is using an application and inserts 2000
rows of data.
• While SQL Server is processing this data let’s say someone pulls the
plug on the server.
• Because the INSERT statement was writing to the transaction log and
it knows a failure occurred it will roll back the statement.
• this wasn’t put in place, could you imagine having to sift through the
data to see how many rows it inserted and then change the code to
insert the remaining rows? Or even better, what if the application
inserted random columns in no order and you had to determine what
data was inserted and what data was left out? This could take forever!
• Log entries are sequential in nature. The transaction log is split up into
small chunks called virtual log files, which we will discuss in a later
section. When a virtual log file is full, transactions automatically move
to the next virtual log file. As long as the log records at the beginning
of the transaction log have been truncated when logging reaches the
end of the log, it will circle back around to the start and will overwrite
what was there before:

This MinLSN is called Minimum transaction log Sequence Number, LSN or MinLSN.

You might also like