Chapter 11 storage and file structure
1 / 31

Chapter 11: Storage and File Structure - PowerPoint PPT Presentation

  • Uploaded on

Chapter 11: Storage and File Structure. Hankz Hankui Zhuo. What factors we care about. Speed Cost Reliability data loss: power failure, or system crash physical failure. Classification of Physical Storage Media. volatile storage loses contents when power is switched off

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Chapter 11: Storage and File Structure' - amara

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

What factors we care about
What factors we care about

  • Speed

  • Cost

  • Reliability

    • data loss: power failure, or system crash

    • physical failure

Classification of physical storage media
Classification of Physical Storage Media

  • volatile storage

    • loses contents when power is switched off

    • non-volatile storage

    • Contents persist even when power is switched off

Physical storage media
Physical Storage Media

  • Cache

    • Fastest

    • Most costly

    • Volatile

  • Main memory

    • Fast

    • Too small/expensive to store entire DB

    • Volatile

Physical storage media1
Physical Storage Media

  • Flash memory

    • Non-volatile

    • Reads roughly as fast as main memory

    • Writes/erases are slow

    • Cost similar to main memory

    • Widely used in embedded devices, e.g., digital cameras

Physical storage media2
Physical Storage Media

  • Magnetic-disk

    • Stored on spinning disk

    • Primary medium for DB

    • Slower than main memory

    • Non-volatile

    • Large capacity

Physical storage media3
Physical Storage Media

  • Optical storage

    • non-volatile

    • Read from a spinning disk using a laser

    • Examples: DVD, CD-ROM

    • Slower than magnetic disk

Physical storage media4
Physical Storage Media

  • Tape storage

    • Non-volatile

    • Sequential-access

    • Much slower than disk

    • Storage costs much cheaper than disk, but drives are expensive

Storage hierarchy1
Storage Hierarchy

Primary storage

Secondary storage

Tertiary storage

Performance measures of disks
Performance Measures of Disks

  • Access time

    • Seek time

      • time it takes to reposition the arm over the correct track.

    • Rotational latency

      • time it takes for the sector to be accessed to appear under the head.

  • Data-transfer rate

    • ?MB per second

Performance measures of disks1
Performance Measures of Disks

  • Mean time to failure (MTTF)

    • the average time the disk is expected to run continuously without any failure.

      • Typically 3 to 5 years

      • MTTF decreases as disk ages

Optimization of disk block access
Optimization of Disk-Block Access

  • Block – a contiguous sequence of sectors from a single track

    • data is transferred in blocks

    • sizes range from 512 bytes to several kilobytes

      • Smaller blocks: more transfers from disk

      • Larger blocks: more space wasted due to partially filled blocks

      • Typical block sizes today range from 4 to 16 kilobytes

Optimization of disk block access1
Optimization of Disk-Block Access

  • Disk-arm-scheduling

    • order pending accesses to tracks, so that disk arm movement is minimized

    • Elevator algorithm

      • Move in one direction

      • Process requests in that direction till no more requests in that direction

      • Then reverse direction and repeat

Raid redundant arrays of independent disks
RAID: Redundant Arrays of Independent Disks

  • Easy to fail when using lots of disks

    • Cause data loss

  • Using redundancy

    • To avoid data loss

Improvement of reliability via redundancy
Improvement of Reliability via Redundancy

  • Redundancy

    • Store extra information: used to rebuild information lost in a disk failure

    • E.g., mirroring

      • Duplicate every disk

      • Write on both disks

      • Read from either disk

      • If a disk fails, data is still available in the other

  • Mean time to data loss depends on:

    • Mean time to failure, and

    • Mean time to repair

Buffer manager1
Buffer Manager

  • Programs call on the buffer manager when they need a block from disk.

    • If the block is already in the buffer, buffer manager returns the address of the block in main memory

Buffer manager2
Buffer Manager

2. If the block is not in the buffer, the buffer manager allocates space in the buffer for the block

A. Replacing (throwing out) some other block, if required, to make space for the new block.

B. Replaced block written back to disk only if it was modified since the most recent time that it was written to/fetched from the disk.

Buffer replacement policies
Buffer-Replacement Policies

  • Most operating systems replace the block least recently used (LRU strategy)

  • You can design many policies to replace blocks

    • To minimize time cost of transferring data

    • E.g., statistical methods?

File organization1
File Organization

  • Database is stored as

    • A collection of files

    • A file is a sequence of records

    • A record is a sequence of attributes

Fixed length records
Fixed-Length Records

  • Simple approach:

    • Store record i starting from byte n  (i – 1), where n is the size of each record.

    • Record access is simple but records may cross blocks

    • Deletion of record i:

      • move records i + 1, . . ., m

        to i, . . . , m – 1, or

      • move record m to i

      • link all free records on a

        free list

Variable length records
Variable-Length Records

  • More complicated than fixed-length records

  • Please refer to the text book

Organization of records in files
Organization of Records in Files

  • Heap– a record can be placed anywhere in the file where there is space

  • Sequential – store records in sequential order, based on the value of the search key of each record

  • Hashing – a hash function computed on some attribute of each record; the result specifies in which block of the file the record should be placed

Sequential file organization
Sequential File Organization

  • Suitable for applications that require sequential processing of the entire file

  • The records in the file are ordered by a search-key

Sequential file organization1
Sequential File Organization

  • Deletion – use pointer chains

  • Insertion –locate the position where the record is to be inserted

    • if there is free space insert there

    • if no free space, insert the

      record in an overflow block

    • In either case, pointer chain

      must be updated

Sequential file organization2
Sequential File Organization

  • For example:

  • Need to reorganize the file from time to time to restore sequential order