【CSCI3170学习笔记】Storage and Index

/*This is a study note written by Edward HUANG 

* in order to study CSCI3170 introduction to database better.

* Many of the content are from professor Wong's lecture notes.

*/

1. What is the time for accessing a disk block?
  • time = seek time + rotational delay + transfer time
  • Most of the contribution are fromseek time and rotational delay.
2. What are 'disk block' & 'disk Sector'
  • Data are stored and retrieved in units called disk blocks or pages
  • Block size is multiple of sector size.
  • A sector is a sequence of bytes.
3. What is 'Page'?

Each page has a fixed size. It contains a sequences of record.

4. Concept of 'Buffer Management'
  • Occurs when the page is requested for operation and it is not yet in the buffer.
  • Replacement Policy
  • Dirty Bit
------------------------------------------------------------------------------------
5. What is the format of a record?
There are two kinds of formats of a record.
  • Fixed length Record
    • Information about field types are same for all records in a file.
    • Information about field types are stored insystem catalogs.
  • Variable length Record (number of field is fixed)
    • Either fields are delimited by special symbols
      • Number of fields|field 1$ field 2$ field 3$ field 4 
    • Or Record begins with array of field (byte) offsets
      • |byte1|byte2|byte3|byte4|byte5|byte6|byte7|byte8|byte9|byte10 |byte11 |
      • |0x5  |0x7  |0x9  |0xA  |0xB  |0x1  |0x2  |0x3  |0x3  |0x1    |0x2    |
      •                               |   field1  |  field 2  |filed 3|filed 4| 

6. What is the format for a Page?

  • Fixed length

|Slot    1|  or unpacked   |Slot    1|

|Slot    2|                |Free Slot|

|Slot    3|         |Slot    3|

|Slot    4|         |Slot    4|

|Free Slot|                |Free Slot|

Record id = <page id, slot#>

  • Variable length


*Pages or block is okay when doing I/O, but higher levels of DBMS operate on records, and files of records.

------------------------------------------------------------------------------------

7.What is File? 
  • It's a collection of pages, each containing a collection of record.
  • File should support insertion, deletion, modification.
  • File should be able to read a particular record.
  • File should be able to scan all records (in every pages).
8.Three kinds of file format
Heap File
  • Using List
    • Header page and data page
  • Using page directory
    • Much smaller than linked list of all Heap File pages.
Sorted Files

Best if records must be retrieved in some order, or only a 'range' of records is needed.

Indexes

  • Data structures to organize records via trees or hashing.
  • They speed up searches for a subset of records, based on values in certain fields.
  • Updates are much faster than in sorted files.

Functionality: An index on a file speeds up selections on the search key fields for the index.

Index must support efficient retrieval of data entries k* with a given key value k.

Structure: Anindex contains a collection of 'data entries'.

What is data entry? Adata entry is denoted ask*, wherek is a search key value and* tells where to find the record containingk.

Structure of data entry

  • <k, data record with search key value k>
  • <k, record id of date record with search key value k>
  • <k, list of record id with search key value k>
Primary VS Secondary
If search key contains primary key, then the index is called primary index, otherwise it is called secondary index.
Clustered VS Unclustered
If order of data records is the same as, or 'close to', order of data entries, then the index is called clustered index.

 

Generally speaking,file contains pages, and page contains records.

  • file = {page 1, page 2, page 3, .....page N}.
  • page1 = {record 1, record 2, record 3, ......record M}.




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值