GoConqr has a new look! Let us know what you think.

Flashcards

SCC 201 - Physcial Access: Files

Ayo Olutobi English 74 cards

Cards in this deck (74)

  1. 1Why are most databases stored on secondary storage devices such as magnetic disks?– Generally too large to fit entirely in main memory
    – Less frequent loss of stored data
    – Cost of storage per unit of data,
    less for disks compared to primary storage devices such as main memory
  2. 2State some physical storage media?DVDs,
    Blu-ray,
  3. 3Where is data stored using magnetic tapes and what does it require?• Data stored is offline
    • Requires intervention by an operator or a loading device to load tape before data can be used
  4. 4What does process of physical database design involve?Process of physical database design involves choosing between different physical data organisation techniques to
    select most suitable for particular application requirements
  5. 5What do DBMS designers need to do to ensure efficient storage of data and how is data organised?DBMS designers must provide efficient implementations of physical data organisation techniques for database designers and administrators to choose from.
    Data is organised on disk into files of records
  6. 6What is a record?A form for storing data
  7. 7What does a form consist of?Consists of:
    – A collection of related data values,
    each formed of one or more bytes
    – Each data value corresponds to a particular field of the record
  8. 8What is a record type?A record type is:
    – Collection of field names and their corresponding data types
  9. 9State some types of standard data types?integer, float, string of characters, date,
  10. 10Number of bytes required to store data of each particular type is?– Number of bytes required to store data of each particular type is fixed
    for a given computer system
  11. 11What are Blobs?Binary Large Objects (BLObs)
    – Large unstructured objects that represent
    image, video, audio data, or free text
  12. 12How are Blobs stored?– Typically stored separately from its record in a pool of disk blocks.
    – Pointer to BLOb is included in record
  13. 13All records in file are of what record type?Sequence of records
    – In many cases all records in file are of same record type
  14. 14Every record in a file has what sort of bytes and what does this enable?Fixed-length records
    – Every record in file has exactly same size in bytes
    Starting byte position of each field can be identified relative to start of record
  15. 15Describe a repeating field?– All records in file are of same type but one or more fields are of variable length,
    for example, variable length strings
    – All records in file are of same type but one or more fields have multiple values for individual records
    • Such a field is called a repeating field, and
    • Group of values is called a repeating group
  16. 16What are group of values called?Group of values is called a repeating group.
  17. 17Complete this statement "All records in file are of same type but" what? Why do files contain records of different types clustered together?All records in file are of same type but one or more fields are optional
    – Values for some records but not all
    File contains records of different types
    clustered together for performance and
    retrieval purposes
  18. 18It is possible to represent a file that logically has variable length records as a fixed length file, what effect would this have on optional field?– Optional fields can still be included in
    every record
    • NULL values stored if no value exists for field for a particular record
    Space is wasted
  19. 19It is possible to represent a file that logically has variable length records as a fixed length file, what effect would this have on repeating field?– Repeating fields can be allocated as many spaces as maximum number of values record can take
    Space is wasted
  20. 20How can variable length field be terminated?– Can be terminated by a special separator character, or
    – Field length in bytes can be stored preceding field value
  21. 21How can optional fields be formatted?Optional fields can be formatted by storing each entry in record as
    pair.
  22. 22What is an alternative way to format optional fields?Alternatively, short field type code can be assigned to each field and used instead of field name in pair
    – Useful if number of fields in record is large but number of actual fields appearing is small.
  23. 23How are records of a file allocated?Records of a file must be allocated in disk blocks
  24. 24What is a block?Block is a data transfer unit between disk and memory.
  25. 25Two possibilities of how a block might handle several records?– A block may contain several records
    • Block size is larger than record size
    – A block may contain only part of a record
    • Some records may be unusually large and not fit in one block
  26. 26Suppose block size is B bytes and file contains fixed-length records of size R bytes – If B >= R, how many records can we fit per block?we can fit bfr = | B / R |records per block
    The function, floor, | (x) | rounds the number x down to an integer
    – Value bfr is called the blocking factor of the file
  27. 27Equation to find the number of unused spaces per block?In general R may not divide B exactly Þ
    there will be unused space in each block equal to
    B – (bfr * R) bytes
  28. 28Describe the spanned records process?• Store part of record in unused space with pointer to block containing remainder
    – Two blocks may not be consecutive!
  29. 29Describe the unspanned records process?records are not allowed to cross block
    boundaries
  30. 30What are the three different file allocation block types?Continous allocation
    Linked allocation
    Cluster
    Indexed allocation
  31. 31Describe the continuous allocation process and list advantages and disadvantages?– File blocks are allocated to consecutive disk blocks
    • (+ve): Very fast reading of whole file
    • (–ve): File expansion is difficult because there's not space between the blocks
  32. 32Describe the linked allocation process and it's advantages and disdvantages?– Each file block contains a pointer to next file block
    • (+ve): File expansion is easy
    • (–ve): Slower reading of file
  33. 33Main aim of cluster and how it achieves this?trying to get the best of both worlds?
    – Allocate clusters of consecutive disk blocks and link the clusters
  34. 34Describe the indexed allocation process and advantages and disadvantages?– One or more index blocks contain pointers to actual file blocks
    – Speeds up access to records partway through file
  35. 35What are file headers also known as?Also known as file descriptor
  36. 36What information do file header contain?Contains information needed by programs
    accessing records in file
    – Information to determine disk addresses of file blocks
    – Record format descriptions
  37. 37What information will be required for fixed length, unspanned records?– Field lengths
    – Order of fields within record
  38. 38What information will be required for variable-length records?– Field type codes
    – Separator characters
    – Record type codes
  39. 39State all the typical file operations? record at a timeOpen
    Reset
    Find/Locate
    Read/Get
    FindNext
    Delete
    Modify
    Insert
    Close
    Scan
  40. 40State all typical file operations? set at a timeFindAll
    FindOrdered
    Reorganise
  41. 41What is the primary organisation aim?– How records of a file are physically placed on disk
    Þ How can records be accessed
  42. 42What is the secondary organisation aim?– Efficient access to records of a file based on fields other than those used for primary organisation
    – Example: index structures
  43. 43What are files of unordered records known as?Known as heap files
    Simplest and most basic type of organisation
  44. 44How are records placed in heap files?Records are placed in file in order they are inserted
    – New records are placed at end of file
  45. 45Can you describe the process of inserting a new record in an unordered file?: Inserting a new record is very efficient
    – Address of last file block kept in file header
    – Last file block is copied into a buffer
    – New record is added
    – Block is written back to disk
  46. 46Advantages and disadvantages of unordered file types?• (+ve): Inserting a new record is very efficient
    (–ve): Searching for record
    – Requires a linear search
    (–ve): Deleting record is very expensive
  47. 47Can you describe the record deletion process?– Find block containing record to be deleted (linear search!)
    – Copy block into a buffer
    – Delete record from buffer
    – Rewrite block back to disk
    -> unused space left in disk block
    • Large number of deleted records lead to large amounts of wasted space
  48. 48Can you describe the alternative deletion approach using a deletion marker?– Use a deletion marker
    • An extra byte or bit stored with each record
    • A record is deleted by setting deletion marker to a certain value
    • Search operations only consider valid records in a block
  49. 49What does deletion approach require?– Deletion marker approach requires periodic physical re-organisation to reclaim unused space.
    • File blocks are accessed consecutively
    • Existing records take the place of deleted records
  50. 50What is the alternative to physical re-organisation when inserting new records?– Alternative to physical re-organisation is to use space of deleted records when inserting new records
    • Overhead of keeping track of reclaimable locations
  51. 51What is called ordering file?Physically order records of a file based on values of one of their fields (called ordering field)
    – Ordering field is called ordering key if it is a key field of file
  52. 52Adavnatges of files of ordered record?(+ve): Reading records in order defined by key is extremely efficient as compared to unordered files
    – No sorting is required
    (+ve): Finding next record from current one in order defined by key requires no additional block access
    – Unless current record is the last in block
    (+ve): Using search condition based on ordering key results in faster access
    – Binary search can be used
    (in contrast with linear search in unordered files)
  53. 53Disadvantages of files of ordered records?ve): No advantage for random or ordered access based on values of non-ordering fields.
    (-ve): Insertion and deletion of records is
    expensive
    – Records must remain physically ordered!
  54. 54Explain using an example how inserting a new record can be very expensive?– Find correct position in file
    (based on its ordering field value)
    – Make space in file and insert record
    – Very time consuming and expensive for large files!
  55. 55How can inserting a record be made more efficient?– Keeping unused space in each block
    • Back to square one when unused space runs out!
    - Create temporary unordered overflow file to store new records
  56. 56Effects off creating a temporary unordered overflow file to store new records?• Actual ordered file is called main or master file
    • Periodic reorganisation involves sorting and merging overflow file with master file
    • Search algorithm becomes more complex as it needs to perform linear search on records in overflow
    file
  57. 57How can deleting a record be made more efficient?– Can be made more efficient by using deletion markers and periodic reorganisation
  58. 58How is modification of record achieved when value of ordering field is modified?– If value of ordering field is modified
    -> record might need to change its position in file
    • Requires deletion of old record...
    followed by insertion of modified record!
  59. 59Describe operation open?– Prepares file for reading or writing
    – Allocates appropriate buffers (typically at least two) to hold file
    blocks from disk
    – Retrieves file header
    – Sets file pointer to beginning of file
  60. 60Describe operation reset?– Sets file pointer of an open file to beginning of file
  61. 61Describe operation find/locate?– Searches for first record that satisfies a search condition
    – Transfers block containing matched record into main memory
    buffer (if it is not already there)
    – Points file pointer to fetched record in file
  62. 62Describe operation findNext?– Same as Find except that this operation searches for next record
    in file matching the search condition
  63. 63Describe operation Read/Get?– Copies current record from buffer to a program variable
    – May also advance file pointer to the next record in file
    • May necessitate reading the next file block from disk
  64. 64Describe operation delete?– Deletes current record
    – Updates file on disk to reflect deletion
  65. 65Describe operation modify?– Modifies some field values for current record
    – Updates file on disk to reflect change
  66. 66Describe operation insert?– Locates block where record is to be inserted
    – Transfers block to a main memory buffer
    (if it is not already there)
    – Writes record into the buffer
    – Writes buffer to disk
  67. 67Describe operation close?– Releases the buffers
    – Performs any other cleanup operations required
  68. 68State all record-at-time operations?Reset
    Find/Locate
    Read/Get
    FindNext
    Delete
    Modify
    Insert
    Scan
    *Open and Close have been removed
  69. 69Describe scan operations?Combines Find, FindNext and Read into one operation
    – Returns first record if file has just been opened or reset
    – Returns the next record otherwise
    – If a search condition is specified returned record is
    first or next record satisfying condition
  70. 70Describe findAll operation?• Locates all records in a file that satisfy a search condition
  71. 71Describe findOrdered operation?• Retrieves all records in the file in some specified order
  72. 72Describe re-organise operation?• For example reorder file records based on a specified field value
  73. 73What does Primary file organisation solve?– How records of a file are physically placed on disk
    -> How can records be accessed
  74. 74What does secondary file organisation solve?– Efficient access to records of a file based on fields other than those used for primary organisation
    – Example: index structures

Information

Description
Flashcards on SCC 201 - Physcial Access: Files, created by Ayo Olutobi on 31/03/2017.
Created by
Ayo Olutobi
Views
2
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?