1 / 17

File Organization

File Organization. Lec4 Dr Emad Nabil. File types. A file can be treated as a stream of bytes , ex: image file , sound files a collection of records with fields. Filed and Record organization. Field : a data value, smallest unit of data with logical meaning

patrica
Download Presentation

File Organization

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. File Organization Lec4 Dr Emad Nabil

  2. File types A file can be treated as • a stream of bytes , ex: image file , sound files • a collection of records with fields ..

  3. Filed and Record organization • Field: a data value, smallest unit of data with logical meaning ► Record: A group of fields that forms a logical unit ►Key: a subset of the fields in a record used to uniquely identify the record 87358CARROLLALICE IN WONDERLAND 03818FOLK FILE STRUCTURES 79733KNUTH THE ART OF COMPUTER PROGRAMMING 86683KNUTH SURREAL NUMBERS 18395TOLKIEN THE HOBITT Field Record key Each line of the file is a record. ►Fields in each record: – ISBN Number, – Author Name, – Book Title

  4. Primary and secondary keys ►Primary Key : A key that uniquelyidentifies a record. ►Secondary Key: Other keys that may be used for search ►Note that • In general not every field is a key • Keys correspond to fields, or combinationof fields, that may be used in a search

  5. Method of field organization • Fixed length • Begin each field with its Lengthindicator • Delimitersto separate fields • “keyword=value” identifies each field and its content

  6. Methods of field organization 1- Fixed length fields • Like in our file of books (field lengths are 5,7, and25). • 87358CARROLL ALICE IN WONDERLAND--------- • 03818FOLK - - - FILE STRUCTURES------------------ • 86683KNUTH- - SURREAL NUMBERS--------------- • 18395TOLKIEN THE HOBITT-------------------------- spaces

  7. Methods of field organization 2-Length indicator Filed length • 058735807CARROLL19ALICE IN WONDERLAND • 050381804FOLK15FILE STRUCTURES • 058668305KNUTH15SURREAL NUMBERS • 051839507TOLKIEN10THE HOBITT Record

  8. Methods of field organization 3-using delimiters • Add delimiter at the end of each field • 87358|CARROLL|ALICE IN WONDERLAND| • 03818|FOLK|FILE STRUCTURES| • 86683|KNUTH|SURREAL NUMBERS| • 18395|TOLKIEN|THE HOBITT|

  9. Methods of field organization 4-using (key=value) • ISBN=87358|AU=CARROLL|TI=ALICE IN WONDERLAND| • ISBN=03818|AU=FOLK|TI=FILE STRUCTURES| • ISBN=86683|AU=KNUTH|TI=SURREAL NUMBERS| • ISBN=18395|AU=TOLKIEN|TI=THE HOBITT|

  10. Field structures: advantages and disadvantages

  11. Record Organization Fixed length record • Fixed length record • Records with fixed number of fields • Begin record field with its Length indicator • Using Delimiters to separate records • Use an indexto keep records addresses Variable length record

  12. Record Organization1-Fixed length record • Internal organization may be • Fixed length field • Delimited fields • Using length indicator

  13. Record Organization2-Fixed number of fields • Internal organization may be • Delimited fields • Using length indicator

  14. Record Organization3-Begin record field with its Length indicator • Internal organization may be • Delimited fields • Using length indicator 33

  15. Record Organization4- Using Delimiters to separate records * The common delimiter in the end of line, as it make the file readable *any other character can be used as a delimiter.

  16. Record Organization5-using index to keep track of records. Keys are sorted

  17. Fixed length vs. variable length records

More Related