Presentation is loading. Please wait.

Presentation is loading. Please wait.

File Processing - Introduction MVNC1 File Processing BASIC CONCEPTS & TERMINOLOGY.

Similar presentations


Presentation on theme: "File Processing - Introduction MVNC1 File Processing BASIC CONCEPTS & TERMINOLOGY."— Presentation transcript:

1 File Processing - Introduction MVNC1 File Processing BASIC CONCEPTS & TERMINOLOGY

2 File Processing - Introduction MVNC2

3 3 File Processing l What is it? l Why Learn It?

4 File Processing - Introduction MVNC4 Files & Data Bases - Differences Database File Access routines User App Database User App File Access routines Schema File

5 File Processing - Introduction MVNC5 Files & Data Bases - Differences l File System »Lower level, application specific. »collection of files along with programs for manipulating them »Physical organization & access techniques of data known to programmer

6 File Processing - Introduction MVNC6 Files & Data Bases - Differences l Database »generalized system for storage and retrieval of information »Generic, configurable »System configured with a database schema »Very flexible, but less efficient »physical organization and access technique hidden from application programmer. »A database uses a file system to actually store and retrieve physical data.

7 File Processing - Introduction MVNC7 Basic Terms l File, Record, Field l File »Collection of (homogenous) records l Record »element of a file (tuple) »contains information about a single entity »Consists of fields of information about entity

8 File Processing - Introduction MVNC8 Basic Terms l Field »attribute of an entity »May be of many "types" –string - “254 Niagra Street” –numeric value - 345 –logical value - True or False –structure (e.g. date) - 12/5/96

9 File Processing - Introduction MVNC9 Files, Records, and Fields Record Field File

10 File Processing - Introduction MVNC10 Example files: l consider records for: »real estate listings »student files »Books in library

11 File Processing - Introduction MVNC11 Records l Record type »record definition or template l Record instance »a particular record with specific data. ID FIRST LAST BOX 3241 Alice Smith 23-546 3755 William Butler 62-819

12 File Processing - Introduction MVNC12 File access and file organization l file access - technique used to store and retrieve particular records in a file. l file organization - characteristics of how a file is structured or actually stored on the disk.

13 File Processing - Introduction MVNC13 File access and file organization l Example: »Library (books are like records) –what is the file access? –what is the file organization? »file cabinet –what is the file access? –what is the file organization?

14 File Processing - Introduction MVNC14 File organizations l Two major underlying file organizations l Direct files »works like an array of records in memory »user selects records directly by its position in the file. l Sequential files »must be accessed in the order the records appear in the file. »"tape" metaphore.

15 File Processing - Introduction MVNC15 File access techniques l Two major underlying file access techniques l Direct access »can be used with direct files to randomly select records. »cannot be used with sequential file organization. l Sequential access »can be used with either direct or sequential organizations.

16 File Processing - Introduction MVNC16 File organization & access techniques l These techniques are basic, since directly supported by hardware. l All other (more complex) techniques built using direct & sequential. »Tree »Hashed »Indexed

17 File Processing - Introduction MVNC17 Primary vs. Secondary storage l Primary »Semiconductor memory »fast, but small, temporary, expensive »memory, registers l Secondary »Disks, Tapes »slow, but large, permanent, inexpensive »orders of magnitude slower then memory

18 File Processing - Introduction MVNC18 Motivation for File Structures l Primary Memory (RAM) »Small - 10 6 bytes to 10 8 bytes (1 - 100 megabytes) »Fast - 120* 10 -9 seconds (120 nanoseconds) access time l Secondary Memory »Large - 10 9 bytes to 10 10 bytes (1 - 10 gigabytes) »Slow - 3*10 -3 seconds (30 millisecond) access time

19 File Processing - Introduction MVNC19 Motivation for File Structures l Consider a comparison with a bookself verses a library: »Bookshelf holds 100 books »Access time is 20 seconds l How many books does library hold? l How long does it take to get to library?

20 File Processing - Introduction MVNC20 Primary vs. Secondary storage l Tradeoffs - where should files and programs be kept? »primary - limited in size, loss occurs if power fails »secondary - much slower but nonvolatile

21 File Processing - Introduction MVNC21 Primary vs. Secondary storage l Balance »Consider the top of your desk vs. a file cabinet »keep what is likely to be needed soon in primary memory »keep in secondary memory information which hasn't been accessed recently, and isn't like to be needed soon. »Principles of temporal and spatial locality.

22 File Processing - Introduction MVNC22 Virtual Memory l some operating systems have built-in support to balance between primary and secondary storage. »They allow programs to be much larger then memory, and automatically "shuttle" information as needed between primary and secondary storage. »Keep recently accessed areas of code and data in primary memory »off-load segments not used for a while to secondary storage (or never load in the first place!) »Thus memory appears to be bigger then it actually is

23 File Processing - Introduction MVNC23 C++ Objects and File Processing l One of our goals is to use C++ objects to represent our file components. l Consider the following C++ class: class Person { public: // data members char LastName[20], FirstName[20], Address[16] char City[16], State[3], ZipCode[10]; // methods Person (); //Default constructor Person (const char *); // Construct from string Person (const Person&); // Copy constructor };

24 File Processing - Introduction MVNC24 C++ Objects and File Processing l “public” members are accessible by users of the object l “private” members are accessible from within the object only. Person p; // Automatic creation Person * p1_ptr = new person; // dynamic creation Person * p2_ptr = new person(“Smith”); cout << p.Lastname << “,“ << p.FirstName << endl; p_ptr->FirstName = p.FirstName; Person p2(p);

25 File Processing - Introduction MVNC25 C++ Objects and File Processing l Member functions Person::Person () { // set each field to an empty string LastName[0]= 0; FirstName[0]= 0; Address[0]= 0; City[0]= 0; State[0]= 0; ZipCode[0]= 0; } Person::Person (const char *LN) { // Make a Person with the Last name set strcpy(LastName,LN); FirstName[0]=0; Address[0]=0; City[0]=0; State[0]=0; ZipCode[0]=0; }

26 File Processing - Introduction MVNC26 C++ Objects and File Processing l Member functions Person::Person (const Person& p); // copy constuctor { // Make a Person with the Last name set strcpy(LastName,p.LastName); strcpy(FirstName,p.FirstName; strcpy(Address,p.Address; strcpy(City,p.City; strcpy(State,p.State; strcpy(ZipCode,p.ZipCode; }


Download ppt "File Processing - Introduction MVNC1 File Processing BASIC CONCEPTS & TERMINOLOGY."

Similar presentations


Ads by Google