SlideShare uma empresa Scribd logo
1 de 46
Introduction to Data Access Methods

Objectives
In this lesson, you will learn to:
 Describe the different methods by which data records
  can be accessed from disk files, and state the
  advantages and disadvantages of each method
 List the pros and cons of various data structures to
  store an index
 Implement insertion and deletion of records in a data
  file
 Implement insertion and deletion of fields in a
  database structure file


                      Introduction to Data Access Methods/Lesson 7/Slide 1 of 46
  ©NIIT
Introduction to Data Access Methods

 Access Methods
  Data on disk files is usually organised as records
   containing several fields, one of which is often used
   as a key field.
  There are several methods employed to access such
   data records from disk files.
  Each of the access methods requires a particular type
   of organisation of the disk file as well.




                  Introduction to Data Access Methods/Lesson 7/Slide 2 of 46
  ©NIIT
Introduction to Data Access Methods

 Sequential Access
  Sequential access is the simplest but the least
   efficient access method employed.
  Sequential access requires reading of all data from a
   file until the desired record is arrived at.
  As per this method, if a couple of million records were
   involved in the processing, an average of a million
   records would be read every time a single record was
   required.




                   Introduction to Data Access Methods/Lesson 7/Slide 3 of 46
  ©NIIT
Introduction to Data Access Methods

 Random Access
  According to this access method, in a data file
   containing fixed length records, it is possible to access
   any particular record whose relative position in the file
   is known.
  In random access, the record number is used to
   calculate the offset address. Access on key field value
   is not possible.




                   Introduction to Data Access Methods/Lesson 7/Slide 4 of 46
  ©NIIT
Introduction to Data Access Methods

 Indexed Access
  In a real life application, the user would seldom know
   the record number, therefore a table containing a list
   of all key fields of each record in the data file should
   be created along with the offset positions of the
   beginning of the records in the file.
          Key Field                  Offset
          A123                       0
          A124                       200
          A135                       400
          A146                       600
          R259                       800
          R624                       1000
                      Introduction to Data Access Methods/Lesson 7/Slide 5 of 46
  ©NIIT
Introduction to Data Access Methods

 Indexed Access (Contd..)
  The indexed table should be sorted in ascending
   order of the key field values.
  This method is slower, as the number of records
   increase, the overhead of the time taken to search the
   index also increases.
  Indexed access is the most commonly used access
   method on database applications.
  The loss in access speed can be minimized by the
   use of carefully selected algorithms and data
   structures.


                   Introduction to Data Access Methods/Lesson 7/Slide 6 of 46
  ©NIIT
Introduction to Data Access Methods

 Representing an Index
  A key factor of this method is the quick and efficient
   way to access the elements of the index itself.
  The ways to store the index are as follows:
      Using Arrays
      Using Linked List
      Using Binary Trees




                      Introduction to Data Access Methods/Lesson 7/Slide 7 of 46
  ©NIIT
Introduction to Data Access Methods

 Using Arrays to Store an Index
  This is the simplest way to store the index.
  Each element of an array could contain two parts:
       The key value of a record in a data file
       The offset position of this record from the
        beginning of the file.
  The problems that arise are the following:
       Finding the required element normally involves a
        sequential search through the array
       For use as an index, the array would first have to
        be sorted on the key values.
                     Introduction to Data Access Methods/Lesson 7/Slide 8 of 46
  ©NIIT
Introduction to Data Access Methods

 Using Arrays to Store an Index (Contd..)
       Corresponding insertions or deletions are not easy
        to handle in an array.




                    Introduction to Data Access Methods/Lesson 7/Slide 9 of 46
  ©NIIT
Introduction to Data Access Methods

  Using Linked List to Store an Index
   The Linked List helps to store the index in the sorted
    order.
   The insertion and deletion in a Linked list involves
    only the routine processing.
   In order to get the required node, the Linked List
    needs to be searched sequentially.
   A figure representing the linked list is as follows:




                      Introduction to Data Access Methods/Lesson 7/Slide 10 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Using Binary Trees to Store an Index
  Use of Binary Tree to store an index is much more
   efficient than the use of Linked List.
  It contains the data in sorted order.
  All left child-nodes contain data less than, and right
   child-nodes contain data greater than that of their
   parent-nodes.
  Consider the following figure:




                     Introduction to Data Access Methods/Lesson 7/Slide 11 of
  ©NIIT
                                                                          46
Introduction to Data Access Methods

 Using Binary Trees to Store an Index (Contd..)
  In the previous figure, there are several nodes at
   different levels of the tree which have NULL left or
   right pointers.




                   Introduction to Data Access Methods/Lesson 7/Slide 12 of
  ©NIIT
                                                                        46
Introduction to Data Access Methods

 Problem Statement 7.P.1
 Referring to the following figures, specify the number of
 comparisons made in the search of the linked list and
 binary tree for the following key values.




                     Introduction to Data Access Methods/Lesson 7/Slide 13 of
  ©NIIT
                                                                          46
Introduction to Data Access Methods

 Problem Statement 7.P.1(Contd..)
 key values are :
 7
 1
 6
 4




                    Introduction to Data Access Methods/Lesson 7/Slide 14 of
  ©NIIT
                                                                         46
Introduction to Data Access Methods

 An Exercise in Data Structures
  The assumptions made regarding the database files
   are:
      1. The records are stored in a data file in the
         sequence in which they are encountered.
      2. This data file has been created by a simple data
         entry program, which accepts the field values,
         validates them and stores them in the data file.
      3. The structure of the data file is stored in another
         file. This file stores information about each field of
         the data file- the field name, type of the field and
         width of the field.

                      Introduction to Data Access Methods/Lesson 7/Slide 15 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Creating an Index for a Data File
  An index can be created containing key value and
   offset pairs for each record in a database.
  The keys in the index must be inserted in sorted
   order.
  The index is not supposed to contain all of the data in
   the data record.
  The data items required in the index are as follows:
       key field value
       position at which each record begins in the data
        file

                      Introduction to Data Access Methods/Lesson 7/Slide 16 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Creating an Index for a Data File (Contd..)
  A class to store this information can be declared as
   follows:
      class record_data
      {
      char key [5];
      long offset;
      };
  A pointer to an element of this type of structure can be
   declared as follows:
      record_data *rec_ptr;

                     Introduction to Data Access Methods/Lesson 7/Slide 17 of
  ©NIIT
                                                                          46
Introduction to Data Access Methods

 Creating an Index for a Data File (Contd..)
  The key value can be read directly from the file and
   offset position can be find out through tellg() function.
  Now write the data in the index file using following:
    fileobj.write((char*)rec_ptr,sizeof(rec_ptr));
  Later on data need to be stored in a linked list.




                      Introduction to Data Access Methods/Lesson 7/Slide 18 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Creating an Index for a Data File (Contd..)
  The declaration of a node of this linked list can be
   made as shown below:
    class list
    {
    record_data *rec;
    list *next;
    }
  To access the node from the linked list, object of
   linked list need to be declared as:
    list *data_ptr;

                      Introduction to Data Access Methods/Lesson 7/Slide 19 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Just a Minute:
 2. Identify the fastest and slowest access methods out of
    those, given below:
      a. Indexed
      b. Random
      c. Sequential
 3. Which access method is likely to be used in a
    database access program dealing with a large
    number of records?




                      Introduction to Data Access Methods/Lesson 7/Slide 20 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Just a Minute (Contd..):
 2. Of the following, which are used in indexed access
    and which are used in random access?
      a. Offset addresses.
      b. Key field values.




                      Introduction to Data Access Methods/Lesson 7/Slide 21 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Problem Statement 7.P.2
     Complete the makenode() function given below:
     list *makenode ()
     {
     list *newnode;
     :
     :
     return newnode; /* Return a pointer to the newly
         allocated linked list node *l
     }

                      Introduction to Data Access Methods/Lesson 7/Slide 22 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Creation of a Linked List Index
  The first step to be taken is to make all the required
   class declarations.
  The steps involved in the creation of the index are:
       Sequential reading of records from the database
        file.
       Allocation of memory for a node of the linked list
        index .
       Assignment of key and offset values of the
        database record to the appropriate elements in the
        structure of the linked list node.

                      Introduction to Data Access Methods/Lesson 7/Slide 23 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Creation of a Linked List Index (Contd..)
       Insertion of the node into the appropriate position
        in the linked list so as to keep it sorted in order of
        the key values
  These steps can be repeated until there are no more
   data records in the database file.




                       Introduction to Data Access Methods/Lesson 7/Slide 24 of
  ©NIIT
                                                                            46
Introduction to Data Access Methods

 Problem Statement 7.P.3
  Complete the write_index() function given below to
   write the linked list index to an index file oil disk.
      /* Function to write the linked list index sequentially to
         an index file on disk */
      void write index ()
      {
      fstream *fw;
      list *cur
      char off [11];
      cur = start; /* Designate the current node as start*/

                       Introduction to Data Access Methods/Lesson 7/Slide 25 of
  ©NIIT
                                                                            46
Introduction to Data Access Methods

 Problem Statement 7.P.3 (Contd..)
      fw.fopen (index, ios::app);
      if (start) /* If the linked list index is not empty */
      {
      while (cur) /* Keep doing the following steps until the
        pointer to the next node is WILL */
      {
      :
      }
      }

                        Introduction to Data Access Methods/Lesson 7/Slide 26 of
  ©NIIT
                                                                             46
Introduction to Data Access Methods

 Problem Statement 7.P.3(Contd..)
      else
      {
      cout“nnThe list is emptyn”;
      fclose(fw);
      }




                      Introduction to Data Access Methods/Lesson 7/Slide 27 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Allocating Memory for a Linked List Node
  Whenever a new entry is required in the index,
   rnake_index() function is used to allocate memory for
   a linked list node.
  The make_index() function returns a pointer to a
   linked list node.
  A single node of the Linked List can be represented
   as shown in the following figure:




                    Introduction to Data Access Methods/Lesson 7/Slide 28 of
  ©NIIT
                                                                         46
Introduction to Data Access Methods

 Allocating Memory for a Linked List Node
   (Contd..)
  Every linked list node has a data node associated with
   it, and memory for that has to be allocated as well.




                    Introduction to Data Access Methods/Lesson 7/Slide 29 of
  ©NIIT
                                                                         46
Introduction to Data Access Methods

 Assigning Data to the New Node
  When the getdata() function is used in make_index()
   function, the following assumptions are made:
       Two arguments are passed to getdata()
          ®A   pointer to the new node
          ®A   pointer to the database file stream
       The key occupies 4 bytes and the rest of the
        record occupies 18 bytes.




                       Introduction to Data Access Methods/Lesson 7/Slide 30 of
  ©NIIT
                                                                            46
Introduction to Data Access Methods

 Writing Linked List Index to Disk
  A copy of the index data is written to an index file on
   the disk.
  Writing the linked list index to an index file involves
   sequentially accessing successive nodes of the linked
   list and dumping the key and offset to a file.




                    Introduction to Data Access Methods/Lesson 7/Slide 31 of
  ©NIIT
                                                                         46
Introduction to Data Access Methods

 Inserting and Deleting Records from a Database
 Handling Insertions
  The data file has to be modified each time an insertion
   takes place.
  Data does not physically have to be inserted in the
   data file.
  Data is just appended to the file and the appropriate
   insertion is made in the linked list along with the new
   key and offset values.
  After the data for a new record is input from the
   keyboard, the data values have to be used in two
   ways:
       The new record has to be written at the end of the
        database file. Introduction to Data Access Methods/Lesson 7/Slide 32 of
  ©NIIT
                                                                            46
Introduction to Data Access Methods

 Inserting and Deleting Records from a
   Database (Contd..)
       The key value and the offset position of the
        beginning of the new record have to be stored in
        the linked list node.




                     Introduction to Data Access Methods/Lesson 7/Slide 33 of
  ©NIIT
                                                                          46
Introduction to Data Access Methods

 Problem Statement 7.P.4
  Specify the order in which the following steps should
   be carried out to create a linked list containing field
   details from the database structure file:
      a. Attach node at the end of the linked list.
      b. Read details of a field from the database structure
         file.
      c. Declare the structures for the linked list node.
      d. Allocate memory for a node.
      e. Copy field contents into the node.


                      Introduction to Data Access Methods/Lesson 7/Slide 34 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

 Problem Statement 7.P.4 (Contd..)
     After the data for a new record is input from the
     keyboard, the data values have to be used in two
     ways:
       The new record has to be written at the end of the
        database file.
       The key value and the offset position of the
        beginning of the new record have to be stored in
        the linked list node.




                     Introduction to Data Access Methods/Lesson 7/Slide 35 of
  ©NIIT
                                                                          46
Introduction to Data Access Methods

 Problem Statement 7.P.5
 State whether True or False
    Once the database structure is changed, it is not
    possible to meaningfully maintain the data contained
    in the database.




                    Introduction to Data Access Methods/Lesson 7/Slide 36 of
  ©NIIT
                                                                         46
Introduction to Data Access Methods

 Handling Deletions
  In order to delete the records from the database,
   delete the record reference from the linked list and,
   thus, from the index.




                     Introduction to Data Access Methods/Lesson 7/Slide 37 of
  ©NIIT
                                                                          46
Introduction to Data Access Methods

 Problem Statement 7.D.1
  Write a program to perform insertion and deletion of
   records from a database file
      The assumptions need to be made regarding the
      database file are:
  2. The records are stored in a data file in the sequence
     in which they are entered.
  3. This data file has been created by a simple data
     entry program, which accepts the field values,
     validates them and stores them in the data file.
  4. Now make the index file using this database file.

                    Introduction to Data Access Methods/Lesson 7/Slide 38 of
  ©NIIT
                                                                         46
Introduction to Data Access Methods

 Binary Tree Indexes
 Binary Trees are special form of Linked Lists.
 The code to declare the binary tree node is as follows:
          class data
          {
          char key [5];
          long offset;
          };




                          Introduction to Data Access Methods/Lesson 7/Slide 39 of
  ©NIIT
                                                                               46
Introduction to Data Access Methods

 Binary Tree Indexes (Contd..)
          class tree_node
          {
          data *dat;
          tree_node *left;
          tree_node *right;
          };




                       Introduction to Data Access Methods/Lesson 7/Slide 40 of
  ©NIIT
                                                                            46
Introduction to Data Access Methods

 Handling Insertions
 The way through which the key value and offset were
 read from a data file and inserted into a position in a
 linked list, can be followed to insert a node, whose
 structure declarations are given, into the binary tree in
 the correct (sorted) position.




                     Introduction to Data Access Methods/Lesson 7/Slide 41 of
  ©NIIT
                                                                          46
Introduction to Data Access Methods

 Reading a Binary Tree Index
  inorder() traversal algorithm can be used to read the
   data sequentially from the index.
  Data can be searched for in the index using a
   minimum of comparisons which are characteristic of
   binary tree usage.




                    Introduction to Data Access Methods/Lesson 7/Slide 42 of
  ©NIIT
                                                                         46
Introduction to Data Access Methods

 Problem Statement 7.P.5
  As part of a team developing a database application,
   you have been asked to do the following:
      a. Accept a filename as command line parameter
      b. Create the structure of the data file as per user
         requirement.
      c. Accept data as per the defined structure.




                      Introduction to Data Access Methods/Lesson 7/Slide 43 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

Summary
In this lesson, you learned that:
 There are several methods by which data on disk can
  be accessed, three of which are:
      Sequential access
      Random access
      Indexed access
 Linked lists and binary trees are ideal data structures
  to store an index. The advantages of using these
  structures are: efficient insertions, deletions and
  searches

                      Introduction to Data Access Methods/Lesson 7/Slide 44 of
  ©NIIT
                                                                           46
Introduction to Data Access Methods

Summary (Contd..)
 To create an index file, given a data file:
    Create a node to store the key offset pair of a
     record.
    Store the offset of the first byte of the record in the
     offset part of the INFO of the node. The offset is
     found using the tellg() function.
    Read a record and store the key value of the
     record in the key part of the INFO of the node
    Insert the node in the appropriate position of the
     linked list so that it remains sorted
  The above steps have to repeated till there are no
  more records in the file

                        Introduction to Data Access Methods/Lesson 7/Slide 45 of
    ©NIIT
                                                                             46
Introduction to Data Access Methods
Summary (Contd..)
 To insert a record in the data file:
     Accept the data for the new record, and append it
      at the end of the data file
     Create a node containing the key and offset of
      this record and insert it in the linked list.
 To delete a record from the data file:
     Change the first byte of the record to ‘D’ to
      indicate that the record has been marked for
      deletion.
     Delete the corresponding node from the linked
      list. Physical deletion of the record in the data file
      is not necessary.

                      Introduction to Data Access Methods/Lesson 7/Slide 46 of
  ©NIIT
                                                                           46

Mais conteúdo relacionado

Mais procurados

Data structure-questions
Data structure-questionsData structure-questions
Data structure-questionsShekhar Chander
 
Abstract data types
Abstract data typesAbstract data types
Abstract data typesHoang Nguyen
 
Ii pu cs practical viva voce questions
Ii pu cs  practical viva voce questionsIi pu cs  practical viva voce questions
Ii pu cs practical viva voce questionsProf. Dr. K. Adisesha
 
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesProgramming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesFellowBuddy.com
 
Data and File Structure Lecture Notes
Data and File Structure Lecture NotesData and File Structure Lecture Notes
Data and File Structure Lecture NotesFellowBuddy.com
 
Data Structure Question Bank(2 marks)
Data Structure Question Bank(2 marks)Data Structure Question Bank(2 marks)
Data Structure Question Bank(2 marks)pushpalathakrishnan
 
Lecture4b dynamic data_structure
Lecture4b dynamic data_structureLecture4b dynamic data_structure
Lecture4b dynamic data_structurembadhi barnabas
 
Lecture4a dynamic data_structure
Lecture4a dynamic data_structureLecture4a dynamic data_structure
Lecture4a dynamic data_structurembadhi barnabas
 
An Efficient Approach for Enhancing the Security of Amazigh Text using Binary...
An Efficient Approach for Enhancing the Security of Amazigh Text using Binary...An Efficient Approach for Enhancing the Security of Amazigh Text using Binary...
An Efficient Approach for Enhancing the Security of Amazigh Text using Binary...Editor IJCATR
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueGhaffar Khan
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST Kathirvel Ayyaswamy
 

Mais procurados (20)

Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
 
B03606010
B03606010B03606010
B03606010
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Data structure-questions
Data structure-questionsData structure-questions
Data structure-questions
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Tree
TreeTree
Tree
 
Ii pu cs practical viva voce questions
Ii pu cs  practical viva voce questionsIi pu cs  practical viva voce questions
Ii pu cs practical viva voce questions
 
Programming & Data Structure Lecture Notes
Programming & Data Structure Lecture NotesProgramming & Data Structure Lecture Notes
Programming & Data Structure Lecture Notes
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Ds 1
Ds 1Ds 1
Ds 1
 
Data and File Structure Lecture Notes
Data and File Structure Lecture NotesData and File Structure Lecture Notes
Data and File Structure Lecture Notes
 
Lesson 2.2 abstraction
Lesson 2.2   abstractionLesson 2.2   abstraction
Lesson 2.2 abstraction
 
Ds 2
Ds 2Ds 2
Ds 2
 
Data Structure Question Bank(2 marks)
Data Structure Question Bank(2 marks)Data Structure Question Bank(2 marks)
Data Structure Question Bank(2 marks)
 
Lecture4b dynamic data_structure
Lecture4b dynamic data_structureLecture4b dynamic data_structure
Lecture4b dynamic data_structure
 
Lecture4a dynamic data_structure
Lecture4a dynamic data_structureLecture4a dynamic data_structure
Lecture4a dynamic data_structure
 
Data strucer
Data strucerData strucer
Data strucer
 
An Efficient Approach for Enhancing the Security of Amazigh Text using Binary...
An Efficient Approach for Enhancing the Security of Amazigh Text using Binary...An Efficient Approach for Enhancing the Security of Amazigh Text using Binary...
An Efficient Approach for Enhancing the Security of Amazigh Text using Binary...
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
 
UNIT I LINEAR DATA STRUCTURES – LIST
UNIT I 	LINEAR DATA STRUCTURES – LIST 	UNIT I 	LINEAR DATA STRUCTURES – LIST
UNIT I LINEAR DATA STRUCTURES – LIST
 

Destaque

Grafico diario del dax perfomance index para el 15 06-2012
Grafico diario del dax perfomance index para el 15 06-2012Grafico diario del dax perfomance index para el 15 06-2012
Grafico diario del dax perfomance index para el 15 06-2012Experiencia Trading
 
03 qmds2005 session03
03 qmds2005 session0303 qmds2005 session03
03 qmds2005 session03Niit Care
 
Diapositivas yurbis
Diapositivas yurbisDiapositivas yurbis
Diapositivas yurbisyurbisveliz
 
DrupalCamp Campinas 2016 - Auditando performance, conteúdo e boas práticas em...
DrupalCamp Campinas 2016 - Auditando performance, conteúdo e boas práticas em...DrupalCamp Campinas 2016 - Auditando performance, conteúdo e boas práticas em...
DrupalCamp Campinas 2016 - Auditando performance, conteúdo e boas práticas em...Erick Bonnemasou Jaccoud
 
Internacionalización de marcas (Resumen tomado del libro: Administración Estr...
Internacionalización de marcas (Resumen tomado del libro: Administración Estr...Internacionalización de marcas (Resumen tomado del libro: Administración Estr...
Internacionalización de marcas (Resumen tomado del libro: Administración Estr...NilssonRivas
 
eCommerce internacional: 20 claves para crecer.
eCommerce internacional: 20 claves para crecer. eCommerce internacional: 20 claves para crecer.
eCommerce internacional: 20 claves para crecer. Carmen Urbano
 
Serenity sky affrètement congo
Serenity sky affrètement congoSerenity sky affrètement congo
Serenity sky affrètement congoFabrice Lambion
 

Destaque (12)

Informe de Comite de Reasentamiento julio agosto de 2015
Informe de Comite de Reasentamiento julio agosto de 2015Informe de Comite de Reasentamiento julio agosto de 2015
Informe de Comite de Reasentamiento julio agosto de 2015
 
Apokalipsa już niebawem
Apokalipsa już niebawemApokalipsa już niebawem
Apokalipsa już niebawem
 
Grafico diario del dax perfomance index para el 15 06-2012
Grafico diario del dax perfomance index para el 15 06-2012Grafico diario del dax perfomance index para el 15 06-2012
Grafico diario del dax perfomance index para el 15 06-2012
 
03 qmds2005 session03
03 qmds2005 session0303 qmds2005 session03
03 qmds2005 session03
 
Diapositivas yurbis
Diapositivas yurbisDiapositivas yurbis
Diapositivas yurbis
 
Dany
DanyDany
Dany
 
Como empezó todo.odp
Como empezó todo.odpComo empezó todo.odp
Como empezó todo.odp
 
DrupalCamp Campinas 2016 - Auditando performance, conteúdo e boas práticas em...
DrupalCamp Campinas 2016 - Auditando performance, conteúdo e boas práticas em...DrupalCamp Campinas 2016 - Auditando performance, conteúdo e boas práticas em...
DrupalCamp Campinas 2016 - Auditando performance, conteúdo e boas práticas em...
 
2010 02 SEO Business Rodrigo Miranda Mib
2010 02 SEO Business Rodrigo Miranda Mib2010 02 SEO Business Rodrigo Miranda Mib
2010 02 SEO Business Rodrigo Miranda Mib
 
Internacionalización de marcas (Resumen tomado del libro: Administración Estr...
Internacionalización de marcas (Resumen tomado del libro: Administración Estr...Internacionalización de marcas (Resumen tomado del libro: Administración Estr...
Internacionalización de marcas (Resumen tomado del libro: Administración Estr...
 
eCommerce internacional: 20 claves para crecer.
eCommerce internacional: 20 claves para crecer. eCommerce internacional: 20 claves para crecer.
eCommerce internacional: 20 claves para crecer.
 
Serenity sky affrètement congo
Serenity sky affrètement congoSerenity sky affrètement congo
Serenity sky affrètement congo
 

Semelhante a Ds 7

A Survey: Enhanced Block Level Message Locked Encryption for data Deduplication
A Survey:  Enhanced Block Level Message Locked Encryption for data DeduplicationA Survey:  Enhanced Block Level Message Locked Encryption for data Deduplication
A Survey: Enhanced Block Level Message Locked Encryption for data DeduplicationIRJET Journal
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2RajSingh734307
 
Cross Domain Data Fusion
Cross Domain Data FusionCross Domain Data Fusion
Cross Domain Data FusionIRJET Journal
 
Analysis of Bayes, Neural Network and Tree Classifier of Classification Techn...
Analysis of Bayes, Neural Network and Tree Classifier of Classification Techn...Analysis of Bayes, Neural Network and Tree Classifier of Classification Techn...
Analysis of Bayes, Neural Network and Tree Classifier of Classification Techn...cscpconf
 
Iaetsd a survey on one class clustering
Iaetsd a survey on one class clusteringIaetsd a survey on one class clustering
Iaetsd a survey on one class clusteringIaetsd Iaetsd
 
Data Security In Relational Database Management System
Data Security In Relational Database Management SystemData Security In Relational Database Management System
Data Security In Relational Database Management SystemCSCJournals
 
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdfBahria University Islamabad, Pakistan
 
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...Bahria University Islamabad, Pakistan
 
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdfBahria University Islamabad, Pakistan
 
Week 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental ConceptsWeek 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental Conceptsoudesign
 
Paper id 252014139
Paper id 252014139Paper id 252014139
Paper id 252014139IJRAT
 
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...IRJET Journal
 

Semelhante a Ds 7 (20)

A Survey: Enhanced Block Level Message Locked Encryption for data Deduplication
A Survey:  Enhanced Block Level Message Locked Encryption for data DeduplicationA Survey:  Enhanced Block Level Message Locked Encryption for data Deduplication
A Survey: Enhanced Block Level Message Locked Encryption for data Deduplication
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
 
Cross Domain Data Fusion
Cross Domain Data FusionCross Domain Data Fusion
Cross Domain Data Fusion
 
Ijetcas14 338
Ijetcas14 338Ijetcas14 338
Ijetcas14 338
 
Analysis of Bayes, Neural Network and Tree Classifier of Classification Techn...
Analysis of Bayes, Neural Network and Tree Classifier of Classification Techn...Analysis of Bayes, Neural Network and Tree Classifier of Classification Techn...
Analysis of Bayes, Neural Network and Tree Classifier of Classification Techn...
 
Iaetsd a survey on one class clustering
Iaetsd a survey on one class clusteringIaetsd a survey on one class clustering
Iaetsd a survey on one class clustering
 
Data Security In Relational Database Management System
Data Security In Relational Database Management SystemData Security In Relational Database Management System
Data Security In Relational Database Management System
 
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
 
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
DBA book sql rdbms 4rth Complete book Database systems Handbook dbms rdbms by...
 
Database system Handbook 3rd DONE Complete DBMS book Full book.pdf
Database system Handbook 3rd DONE Complete DBMS book Full book.pdfDatabase system Handbook 3rd DONE Complete DBMS book Full book.pdf
Database system Handbook 3rd DONE Complete DBMS book Full book.pdf
 
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
4rth Complete book Database systems Handbook dbms rdbms by Muhammad Sharif.pdf
 
Database system Handbook 3rd DONE Complete DBMS book Full book.pdf
Database system Handbook 3rd DONE Complete DBMS book Full book.pdfDatabase system Handbook 3rd DONE Complete DBMS book Full book.pdf
Database system Handbook 3rd DONE Complete DBMS book Full book.pdf
 
Database system Handbook 3rd DONE Complete DBMS book Full book.pdf
Database system Handbook 3rd DONE Complete DBMS book Full book.pdfDatabase system Handbook 3rd DONE Complete DBMS book Full book.pdf
Database system Handbook 3rd DONE Complete DBMS book Full book.pdf
 
Week 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental ConceptsWeek 1 Before the Advent of Database Systems & Fundamental Concepts
Week 1 Before the Advent of Database Systems & Fundamental Concepts
 
IT6701-Information management question bank
IT6701-Information management question bankIT6701-Information management question bank
IT6701-Information management question bank
 
Database system Handbook.docx
Database system Handbook.docxDatabase system Handbook.docx
Database system Handbook.docx
 
Paper id 252014139
Paper id 252014139Paper id 252014139
Paper id 252014139
 
G045033841
G045033841G045033841
G045033841
 
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
A Robust Keywords Based Document Retrieval by Utilizing Advanced Encryption S...
 
rdbms-notes
rdbms-notesrdbms-notes
rdbms-notes
 

Mais de Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Último

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Ds 7

  • 1. Introduction to Data Access Methods Objectives In this lesson, you will learn to: Describe the different methods by which data records can be accessed from disk files, and state the advantages and disadvantages of each method List the pros and cons of various data structures to store an index Implement insertion and deletion of records in a data file Implement insertion and deletion of fields in a database structure file Introduction to Data Access Methods/Lesson 7/Slide 1 of 46 ©NIIT
  • 2. Introduction to Data Access Methods Access Methods Data on disk files is usually organised as records containing several fields, one of which is often used as a key field. There are several methods employed to access such data records from disk files. Each of the access methods requires a particular type of organisation of the disk file as well. Introduction to Data Access Methods/Lesson 7/Slide 2 of 46 ©NIIT
  • 3. Introduction to Data Access Methods Sequential Access Sequential access is the simplest but the least efficient access method employed. Sequential access requires reading of all data from a file until the desired record is arrived at. As per this method, if a couple of million records were involved in the processing, an average of a million records would be read every time a single record was required. Introduction to Data Access Methods/Lesson 7/Slide 3 of 46 ©NIIT
  • 4. Introduction to Data Access Methods Random Access According to this access method, in a data file containing fixed length records, it is possible to access any particular record whose relative position in the file is known. In random access, the record number is used to calculate the offset address. Access on key field value is not possible. Introduction to Data Access Methods/Lesson 7/Slide 4 of 46 ©NIIT
  • 5. Introduction to Data Access Methods Indexed Access In a real life application, the user would seldom know the record number, therefore a table containing a list of all key fields of each record in the data file should be created along with the offset positions of the beginning of the records in the file. Key Field Offset A123 0 A124 200 A135 400 A146 600 R259 800 R624 1000 Introduction to Data Access Methods/Lesson 7/Slide 5 of 46 ©NIIT
  • 6. Introduction to Data Access Methods Indexed Access (Contd..) The indexed table should be sorted in ascending order of the key field values. This method is slower, as the number of records increase, the overhead of the time taken to search the index also increases. Indexed access is the most commonly used access method on database applications. The loss in access speed can be minimized by the use of carefully selected algorithms and data structures. Introduction to Data Access Methods/Lesson 7/Slide 6 of 46 ©NIIT
  • 7. Introduction to Data Access Methods Representing an Index A key factor of this method is the quick and efficient way to access the elements of the index itself. The ways to store the index are as follows: Using Arrays Using Linked List Using Binary Trees Introduction to Data Access Methods/Lesson 7/Slide 7 of 46 ©NIIT
  • 8. Introduction to Data Access Methods Using Arrays to Store an Index This is the simplest way to store the index. Each element of an array could contain two parts: The key value of a record in a data file The offset position of this record from the beginning of the file. The problems that arise are the following: Finding the required element normally involves a sequential search through the array For use as an index, the array would first have to be sorted on the key values. Introduction to Data Access Methods/Lesson 7/Slide 8 of 46 ©NIIT
  • 9. Introduction to Data Access Methods Using Arrays to Store an Index (Contd..) Corresponding insertions or deletions are not easy to handle in an array. Introduction to Data Access Methods/Lesson 7/Slide 9 of 46 ©NIIT
  • 10. Introduction to Data Access Methods Using Linked List to Store an Index The Linked List helps to store the index in the sorted order. The insertion and deletion in a Linked list involves only the routine processing. In order to get the required node, the Linked List needs to be searched sequentially. A figure representing the linked list is as follows: Introduction to Data Access Methods/Lesson 7/Slide 10 of ©NIIT 46
  • 11. Introduction to Data Access Methods Using Binary Trees to Store an Index Use of Binary Tree to store an index is much more efficient than the use of Linked List. It contains the data in sorted order. All left child-nodes contain data less than, and right child-nodes contain data greater than that of their parent-nodes. Consider the following figure: Introduction to Data Access Methods/Lesson 7/Slide 11 of ©NIIT 46
  • 12. Introduction to Data Access Methods Using Binary Trees to Store an Index (Contd..) In the previous figure, there are several nodes at different levels of the tree which have NULL left or right pointers. Introduction to Data Access Methods/Lesson 7/Slide 12 of ©NIIT 46
  • 13. Introduction to Data Access Methods Problem Statement 7.P.1 Referring to the following figures, specify the number of comparisons made in the search of the linked list and binary tree for the following key values. Introduction to Data Access Methods/Lesson 7/Slide 13 of ©NIIT 46
  • 14. Introduction to Data Access Methods Problem Statement 7.P.1(Contd..) key values are : 7 1 6 4 Introduction to Data Access Methods/Lesson 7/Slide 14 of ©NIIT 46
  • 15. Introduction to Data Access Methods An Exercise in Data Structures The assumptions made regarding the database files are: 1. The records are stored in a data file in the sequence in which they are encountered. 2. This data file has been created by a simple data entry program, which accepts the field values, validates them and stores them in the data file. 3. The structure of the data file is stored in another file. This file stores information about each field of the data file- the field name, type of the field and width of the field. Introduction to Data Access Methods/Lesson 7/Slide 15 of ©NIIT 46
  • 16. Introduction to Data Access Methods Creating an Index for a Data File An index can be created containing key value and offset pairs for each record in a database. The keys in the index must be inserted in sorted order. The index is not supposed to contain all of the data in the data record. The data items required in the index are as follows: key field value position at which each record begins in the data file Introduction to Data Access Methods/Lesson 7/Slide 16 of ©NIIT 46
  • 17. Introduction to Data Access Methods Creating an Index for a Data File (Contd..) A class to store this information can be declared as follows: class record_data { char key [5]; long offset; }; A pointer to an element of this type of structure can be declared as follows: record_data *rec_ptr; Introduction to Data Access Methods/Lesson 7/Slide 17 of ©NIIT 46
  • 18. Introduction to Data Access Methods Creating an Index for a Data File (Contd..) The key value can be read directly from the file and offset position can be find out through tellg() function. Now write the data in the index file using following: fileobj.write((char*)rec_ptr,sizeof(rec_ptr)); Later on data need to be stored in a linked list. Introduction to Data Access Methods/Lesson 7/Slide 18 of ©NIIT 46
  • 19. Introduction to Data Access Methods Creating an Index for a Data File (Contd..) The declaration of a node of this linked list can be made as shown below: class list { record_data *rec; list *next; } To access the node from the linked list, object of linked list need to be declared as: list *data_ptr; Introduction to Data Access Methods/Lesson 7/Slide 19 of ©NIIT 46
  • 20. Introduction to Data Access Methods Just a Minute: 2. Identify the fastest and slowest access methods out of those, given below: a. Indexed b. Random c. Sequential 3. Which access method is likely to be used in a database access program dealing with a large number of records? Introduction to Data Access Methods/Lesson 7/Slide 20 of ©NIIT 46
  • 21. Introduction to Data Access Methods Just a Minute (Contd..): 2. Of the following, which are used in indexed access and which are used in random access? a. Offset addresses. b. Key field values. Introduction to Data Access Methods/Lesson 7/Slide 21 of ©NIIT 46
  • 22. Introduction to Data Access Methods Problem Statement 7.P.2 Complete the makenode() function given below: list *makenode () { list *newnode; : : return newnode; /* Return a pointer to the newly allocated linked list node *l } Introduction to Data Access Methods/Lesson 7/Slide 22 of ©NIIT 46
  • 23. Introduction to Data Access Methods Creation of a Linked List Index The first step to be taken is to make all the required class declarations. The steps involved in the creation of the index are: Sequential reading of records from the database file. Allocation of memory for a node of the linked list index . Assignment of key and offset values of the database record to the appropriate elements in the structure of the linked list node. Introduction to Data Access Methods/Lesson 7/Slide 23 of ©NIIT 46
  • 24. Introduction to Data Access Methods Creation of a Linked List Index (Contd..) Insertion of the node into the appropriate position in the linked list so as to keep it sorted in order of the key values These steps can be repeated until there are no more data records in the database file. Introduction to Data Access Methods/Lesson 7/Slide 24 of ©NIIT 46
  • 25. Introduction to Data Access Methods Problem Statement 7.P.3 Complete the write_index() function given below to write the linked list index to an index file oil disk. /* Function to write the linked list index sequentially to an index file on disk */ void write index () { fstream *fw; list *cur char off [11]; cur = start; /* Designate the current node as start*/ Introduction to Data Access Methods/Lesson 7/Slide 25 of ©NIIT 46
  • 26. Introduction to Data Access Methods Problem Statement 7.P.3 (Contd..) fw.fopen (index, ios::app); if (start) /* If the linked list index is not empty */ { while (cur) /* Keep doing the following steps until the pointer to the next node is WILL */ { : } } Introduction to Data Access Methods/Lesson 7/Slide 26 of ©NIIT 46
  • 27. Introduction to Data Access Methods Problem Statement 7.P.3(Contd..) else { cout“nnThe list is emptyn”; fclose(fw); } Introduction to Data Access Methods/Lesson 7/Slide 27 of ©NIIT 46
  • 28. Introduction to Data Access Methods Allocating Memory for a Linked List Node Whenever a new entry is required in the index, rnake_index() function is used to allocate memory for a linked list node. The make_index() function returns a pointer to a linked list node. A single node of the Linked List can be represented as shown in the following figure: Introduction to Data Access Methods/Lesson 7/Slide 28 of ©NIIT 46
  • 29. Introduction to Data Access Methods Allocating Memory for a Linked List Node (Contd..) Every linked list node has a data node associated with it, and memory for that has to be allocated as well. Introduction to Data Access Methods/Lesson 7/Slide 29 of ©NIIT 46
  • 30. Introduction to Data Access Methods Assigning Data to the New Node When the getdata() function is used in make_index() function, the following assumptions are made: Two arguments are passed to getdata() ®A pointer to the new node ®A pointer to the database file stream The key occupies 4 bytes and the rest of the record occupies 18 bytes. Introduction to Data Access Methods/Lesson 7/Slide 30 of ©NIIT 46
  • 31. Introduction to Data Access Methods Writing Linked List Index to Disk A copy of the index data is written to an index file on the disk. Writing the linked list index to an index file involves sequentially accessing successive nodes of the linked list and dumping the key and offset to a file. Introduction to Data Access Methods/Lesson 7/Slide 31 of ©NIIT 46
  • 32. Introduction to Data Access Methods Inserting and Deleting Records from a Database Handling Insertions The data file has to be modified each time an insertion takes place. Data does not physically have to be inserted in the data file. Data is just appended to the file and the appropriate insertion is made in the linked list along with the new key and offset values. After the data for a new record is input from the keyboard, the data values have to be used in two ways: The new record has to be written at the end of the database file. Introduction to Data Access Methods/Lesson 7/Slide 32 of ©NIIT 46
  • 33. Introduction to Data Access Methods Inserting and Deleting Records from a Database (Contd..) The key value and the offset position of the beginning of the new record have to be stored in the linked list node. Introduction to Data Access Methods/Lesson 7/Slide 33 of ©NIIT 46
  • 34. Introduction to Data Access Methods Problem Statement 7.P.4 Specify the order in which the following steps should be carried out to create a linked list containing field details from the database structure file: a. Attach node at the end of the linked list. b. Read details of a field from the database structure file. c. Declare the structures for the linked list node. d. Allocate memory for a node. e. Copy field contents into the node. Introduction to Data Access Methods/Lesson 7/Slide 34 of ©NIIT 46
  • 35. Introduction to Data Access Methods Problem Statement 7.P.4 (Contd..) After the data for a new record is input from the keyboard, the data values have to be used in two ways: The new record has to be written at the end of the database file. The key value and the offset position of the beginning of the new record have to be stored in the linked list node. Introduction to Data Access Methods/Lesson 7/Slide 35 of ©NIIT 46
  • 36. Introduction to Data Access Methods Problem Statement 7.P.5 State whether True or False Once the database structure is changed, it is not possible to meaningfully maintain the data contained in the database. Introduction to Data Access Methods/Lesson 7/Slide 36 of ©NIIT 46
  • 37. Introduction to Data Access Methods Handling Deletions In order to delete the records from the database, delete the record reference from the linked list and, thus, from the index. Introduction to Data Access Methods/Lesson 7/Slide 37 of ©NIIT 46
  • 38. Introduction to Data Access Methods Problem Statement 7.D.1 Write a program to perform insertion and deletion of records from a database file The assumptions need to be made regarding the database file are: 2. The records are stored in a data file in the sequence in which they are entered. 3. This data file has been created by a simple data entry program, which accepts the field values, validates them and stores them in the data file. 4. Now make the index file using this database file. Introduction to Data Access Methods/Lesson 7/Slide 38 of ©NIIT 46
  • 39. Introduction to Data Access Methods Binary Tree Indexes Binary Trees are special form of Linked Lists. The code to declare the binary tree node is as follows: class data { char key [5]; long offset; }; Introduction to Data Access Methods/Lesson 7/Slide 39 of ©NIIT 46
  • 40. Introduction to Data Access Methods Binary Tree Indexes (Contd..) class tree_node { data *dat; tree_node *left; tree_node *right; }; Introduction to Data Access Methods/Lesson 7/Slide 40 of ©NIIT 46
  • 41. Introduction to Data Access Methods Handling Insertions The way through which the key value and offset were read from a data file and inserted into a position in a linked list, can be followed to insert a node, whose structure declarations are given, into the binary tree in the correct (sorted) position. Introduction to Data Access Methods/Lesson 7/Slide 41 of ©NIIT 46
  • 42. Introduction to Data Access Methods Reading a Binary Tree Index inorder() traversal algorithm can be used to read the data sequentially from the index. Data can be searched for in the index using a minimum of comparisons which are characteristic of binary tree usage. Introduction to Data Access Methods/Lesson 7/Slide 42 of ©NIIT 46
  • 43. Introduction to Data Access Methods Problem Statement 7.P.5 As part of a team developing a database application, you have been asked to do the following: a. Accept a filename as command line parameter b. Create the structure of the data file as per user requirement. c. Accept data as per the defined structure. Introduction to Data Access Methods/Lesson 7/Slide 43 of ©NIIT 46
  • 44. Introduction to Data Access Methods Summary In this lesson, you learned that: There are several methods by which data on disk can be accessed, three of which are: Sequential access Random access Indexed access Linked lists and binary trees are ideal data structures to store an index. The advantages of using these structures are: efficient insertions, deletions and searches Introduction to Data Access Methods/Lesson 7/Slide 44 of ©NIIT 46
  • 45. Introduction to Data Access Methods Summary (Contd..) To create an index file, given a data file: Create a node to store the key offset pair of a record. Store the offset of the first byte of the record in the offset part of the INFO of the node. The offset is found using the tellg() function. Read a record and store the key value of the record in the key part of the INFO of the node Insert the node in the appropriate position of the linked list so that it remains sorted The above steps have to repeated till there are no more records in the file Introduction to Data Access Methods/Lesson 7/Slide 45 of ©NIIT 46
  • 46. Introduction to Data Access Methods Summary (Contd..) To insert a record in the data file: Accept the data for the new record, and append it at the end of the data file Create a node containing the key and offset of this record and insert it in the linked list. To delete a record from the data file: Change the first byte of the record to ‘D’ to indicate that the record has been marked for deletion. Delete the corresponding node from the linked list. Physical deletion of the record in the data file is not necessary. Introduction to Data Access Methods/Lesson 7/Slide 46 of ©NIIT 46

Notas do Editor

  1. Lower Bound and Upper Bound to denote the first element number and the last element number respectively
  2. Lower Bound and Upper Bound to denote the first element number and the last element number respectively
  3. Lower Bound and Upper Bound to denote the first element number and the last element number respectively
  4. Lower Bound and Upper Bound to denote the first element number and the last element number respectively