SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
Network Database System

            Prepared by Sir Gio
Network Model
   Another widely used in data model
   Many-to-Many relationship
   Owner – parent record
   Member – child record
   Links – collection of records which are connected to
    one another
Concept of Owner-Member Relationship


                   DEPARTMENT



             FACULTY              MAJORS



       CLASSES

                                 STUDENTS


                 OWNER-MEMBER
                  RELATIONSHIP
OCCURRENCE DIAGRAMS

   Used to illustrate the distribution of owner and member
    records within a network database
   Helps in navigation of the database
An Occurrence Diagram
                                                         Dr. Jao                    Faculty
                                    BSIT                                            records




             Department                                             Dr.
             records                                               Ramiro
                                                  BSCS



                              DIT
Faculty                                                    Dr.
records
              Dr.                                        Flavier            Dr. J
             Belen                          Dr.
                                           Cruz
                            Dr.                                 Dr.
                          Holmes                               Rizal
    Dr. No
                                           Faculty
                                           records
CODASYL-DBTG Model
   Conference On Data System Languages, Data Base
    Task Group
   Original network model presented in a report by
    CODASYL-DBTG
   Collection of set types, owner record types, and
    member record types
Characteristics of CODASYL Network Model
1.       There must be one-to-many relationship between
         pairs of record types related with respect to an
         owner-with-member relationship
2.       A given owner instance must posses a unique set
         of member instances
3.       A given record type cannot be both the owner and
         member of the same set type
          Records and their fields are represented as record type
         type   customer = record                type     account = record
                customer-name: string;           account-number: integer;
                customer-street: string;         balance: integer;
                customer-city: string;
DBTG Model
   Simplified by limiting the link options to one-to-one or
    one-to-many
   Entity relationship is referred to as DBTG set
                                    The arrowhead is used to
                        Segment A
                                    denote: ownership

                                    Records or segments are
                                    represented as boxes

                                    Links are represented as
                        Segment B
                                    lines
DBTG Model
      Just like in hierarchical databases, a particular set
       can have any number of set occurrences
         CUSTOMER A                      CUSTOMER B          CUSTOMER C



 ACCOUNT 1   ACCOUNT 2   ACCOUNT 3   ACCOUNT 4   ACCOUNT 5     ACCOUNT 6




A descriptive                    CUSTACCT SET OCCURRENCES
way of
naming a
DBTG
database is
by
combining
the names of
the owner
and member
segments
DBTG Model
   Another way of illustrating a set occurrence is similar
    to the one used in mathematical sets

        CUSTOMER A       CUSTOMER B    CUSTOMER C    CUSTOMER D


          ACCOUNT 1        ACCOUNT 4     ACCOUNT 6


          ACCOUNT 1        ACCOUNT 5



          ACCOUNT 1




                      CUSTACCT SET OCCURRENCES
DBTG Model
     A set of occurrence can be represented as a link list


 CUSTOMER A        ACCOUNT 1       ACCOUNT 2       ACCOUNT 3


 CUSTOMER B        ACCOUNT 4       ACCOUNT 5


 CUSTOMER C        ACCOUNT 6



Illustrates
that the
member        LINKED REPRESENTATION OF A SET OCCURRENCES
segments
are
ordered
DBTG Model


                 CUSTOMER             BRANCH



Let us add
another owner
segment and                 ACCOUNT
call it BRANCH

This segment
is also an
owner of the
ACCOUNT
segment
DBTG Model
   The Data Structure Diagram below shows the
    inclusion of segment BRANCH and fields of each
    segment
    CUSTOMER                       BRANCH
    name street city               name assets city




                       ACCOUNT
                       number balance
DBTG Model
   A populated representation will help further
    understanding the existing owner-member
    relationship in set CUSTACCT and BRNACCT
                     ACCOUNT 1

CUSTOMER             ACCOUNT 2          BRANCH 1
    A
CUSTOMER             ACCOUNT 3
                                        BRANCH 2
    B
CUSTOMER             ACCOUNT 4
    C
                     ACCOUNT 5

                     ACCOUNT 6

      CUSTACCT AND BRNACCT OWNER-MEMBER RELATIONSHIP
DBTG Model

              OWNERS                                     MEMBERS
CUSTOMER A                                ACCOUNT 1, 2 AND 3
CUSTOMER B                                ACCOUNT 4 AND 5
CUSTOMER C                                ACCOUNT 6
BRANCH 1                                  ACCOUNT 1, 2 AND 4
BRANCH 2                                  ACCOUNT 3, 5 AND 6

                        SET COMPOSITION SUMMARY

  •Segments are owned by more than one owner segment
  •This illustrates the fact that entity relationships within a DBTG set is
  limited to one –to-one or one-to-many
  •This avoids the need to deal with complicated many-to-many
  relationships
DBTG Model
        CUSTOMER SEGMENT                    BRANCH SEGMENT

NAME       ADDRESS    CITY     NAME           ASSETS       CITY
Hagar      Kalayaan   Quezon   Grace Park     1000000000   Caloocan
                                              1
Ana        Avenida    Manila
                               Cervantes      1233333455   Manila
Carlo      Forbes     Manila                  6

 ACCOUNTS SEGMENT

NUMBER     BALANCE
12340      1000
12341      100020
12342      10006
12343      123222
12344      21233
12345      123433
                        SAMPLE RECORDS OF THE THREE SAMPLE SEGMENT
Sample Schema
DBTG Data-Retrieval Facility
   The DBTG data manipulation language consists of a
    number of commands that are embedded in a host
    language
   Run unit
       System application program consisting of a sequence of
        host language and DBTG command statements
       Statements access and manipulate database items as
        well as locally declared variables
   Program work-area (or user work area)
       A buffer storage area the system maintains for each
        application program
DBTG Variables
   Record Templates
   Currency pointers
       Current of record type
       Current of set type
       Current of run unit
   Status flags
       DB-status is most frequently used
       Additional variables: DB-set-name, DB-record-name,
        and
        DB-data-name
Example Program Work Area
   Templates for three record types:
       customer
       Account
       branch
   Six currency pointers
       Three pointers for record types: one each tot he most recently
        accessed customer, account, and branch record
       Two pointers for set types: one to the most recently accessed
        record in an occurrence of the set depositor, one to the most
        recently accessed record in an occurrence of the set account-
        branch
       One run-unit pointer
   Status flags: four variables defined previously
   Following diagram shows an example program work area
    state
Example Program Work Area
The Find and Get Commands
   find
       Locates a record in the database and sets the appropriate
        currency pointers
   get
       Copies of the record to which the current of run-unit points from
        the database to the appropriate program work area template
   Example: Executing a find command to locate the
    customer record belonging to Johnson causes the
    following changes to occur in the state of the program
    work area.
       The current of the record type customer now points to the
        record of Johnson
       The current of set type depositor now points to the set owned
        by Johnson
       The current of run unit now points to customer record Johnson
Access of Individual Records
   find any <record type> using <record-field>
       Locates a record of type <record type> whose <record-
        field>
        value is the same as the value of <record-field> in the
        <record type> template in the program work area.
   Once such a record is found, the following currency
    pointers are set to point to that record:
       The current of run-unit pointer
       The record-type currency pointer for <record type>
       For each set in which that record belongs, the appropriate
        set currency pointer
   find duplicate <record type> using <record-field>
       Locates (according to a system-dependent ordering) the
        next record that matches the <record-field>
Access of Records Within a Set
   Other find commands locate records in the DBTG
    set that is pointed to by the <set-type> currency
    pointer
   find first <record type> within <set-type>
    Locates the first database record of type <record
    type>
    belonging to the current <set-type>
   find next <record type> within <set-type>
       which finds the next element in the set <set-type>
   find owner within <set-type>
       Locates the owner of a particular DBTG set
Predicates
   For queries in which a field value must be matched
    with a specified range of values, rather than to only
    one, we need to:
       get the appropriate records into memory
       examine each one separately for a match
       determine whether each is the; target of our find
        statement
Example DBTG Query
   Print the total number of accounts in the
    Perryridge branch with a balance greater than
    $10,000
    count := 0;
    branch.branch-name := “Perryridge”;
    find any branch using branch-name;
    find first account within account-branch;
    while DB-status = 0 do
              begin
                       get account
                       if account.balance > 10000 then count := count +
    1;
                       find next account within account-branch;
              end
    print (count);
DBTG Update Facility
   DBTG mechanisms are available to update
    information in the database.
   To create a new record of type <record type>
       insert the appropriate values in the corresponding
        <record type> template
       add this new record to the database by executing
                       store <record type>
   Can create and add new records only one at a time
DBTG Update Facility
   To modify an existing record of type <record type>
       find that record in the database
       get that record into memory
       change the desired fields in the template of <record type>
       reflect the changes to the record to which the currency
        point of <record type> points by executing

                    modify <record type>
DBTG Update Facility
   To delete an existing record of type <record type>
       make the currency pointer of that type point to the record in the
        database to be deleted
       delete that record by executing
                   erase <record type>

   Delete an entire set occurrence by finding the owner of
    the set and executing
                  erase all <record type>

       Deletes the owner of the set, as well as all the set’s members.
       If a member of the set is an owner of another set, the members
        of that second set also will be deleted
       erase all is recursive
DBTG Set-Processing Facility
   Mechanisms are provided for inserting records into
    and removing records from a particular set
    occurrence
   Insert a new record into a set by executing the
    connect statement
         connect <record type> to <set-type>

   Remove a record from a set by executing the
    disconnect statement
      disconnect <record type> from <set-type>
Example disconnect Query
   Close account A-201, that is, delete the relationship between
    account A-201 and its customer, but archive the record of account A-
    201
   The following program removes account A-201 from the set
    occurrence of type depositor.
    The account will still be accessible in the database for record-
    keeping purposes
           account.account-number := “A-201”;
                   find for update any account using account-number.
                   get account,
                   find owner within depositor,
                   disconnect account from depositor.
DBTG Set-Processing Facility (Cont.)
   To move a record of type <record type> from one set
    occurrence to another set occurrence of type <set-
    type>
       Find the appropriate record and the owner of the set
        occurrences to which that record is to be moved.
       Move the record by executing

                reconnect <record type> to <set-type>

   Example: Move all accounts of Hayes that are
    currently at the Perryridge branch to the Downtown
    branch.
Example reconnect Query

 customer.customer-name := “Hayes”;
 find any customer using customer-name;
 find first account within depositor;
 while DB-status = 0 do
    begin
        find owner within account-branch;
        get branch;
        if branch.branch-name = “Perryridge” then
           begin
             branch.branch-name := “Downtown”;
             find any branch using branch-name;
             reconnect account to account-branch;
           end
        find next account within depositor,
    end
DBTG Set-Processing Facility (Cont.)
   A newly created member record of type <record
    type> of a set type <set-type> can be added to a set
    occurrence either explicitly (manually) or implicitly
    (automatically).
   Specify the insert mode at set-definition time via
    insertion is <insert mode>

       manual:    connect <record type> to <set-type>

       automatic: store <record type>
Set Insertion Example
   Create account A535 for customer Hayes at the
    Downtown branch.
   Set insertion is manual for set type depositor and is
    automatic for set type account-branch.
          branch.branch-name := “Downtown”;
                find any branch using branch-name;
                account.account-number := “A-535”;
                account.balance := 0;
                store account;
                customer.customer-name := “Hayes”;
                find any customer using customer-name;
                connect account to depositor;

Contenu connexe

Tendances

Slide 2 data models
Slide 2 data modelsSlide 2 data models
Slide 2 data modelsVisakh V
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database DesignArchit Saxena
 
Database management system
Database management systemDatabase management system
Database management systemSayed Ahmed
 
Physical architecture of sql server
Physical architecture of sql serverPhysical architecture of sql server
Physical architecture of sql serverDivya Sharma
 
Database Presentation
Database PresentationDatabase Presentation
Database Presentationa9oolq8
 
Fundamentals of Database ppt ch03
Fundamentals of Database ppt ch03Fundamentals of Database ppt ch03
Fundamentals of Database ppt ch03Jotham Gadot
 
Non relational databases-no sql
Non relational databases-no sqlNon relational databases-no sql
Non relational databases-no sqlRam kumar
 
Object Storage Overview
Object Storage OverviewObject Storage Overview
Object Storage OverviewCloudian
 
Database basics
Database basicsDatabase basics
Database basicsprachin514
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database SystemSulemang
 
Relational database
Relational database Relational database
Relational database Megha Sharma
 

Tendances (20)

Slide 2 data models
Slide 2 data modelsSlide 2 data models
Slide 2 data models
 
Relational Database Design
Relational Database DesignRelational Database Design
Relational Database Design
 
Database management system
Database management systemDatabase management system
Database management system
 
Oracle
OracleOracle
Oracle
 
Data models
Data modelsData models
Data models
 
Physical architecture of sql server
Physical architecture of sql serverPhysical architecture of sql server
Physical architecture of sql server
 
Database Presentation
Database PresentationDatabase Presentation
Database Presentation
 
Fundamentals of Database ppt ch03
Fundamentals of Database ppt ch03Fundamentals of Database ppt ch03
Fundamentals of Database ppt ch03
 
ORACLE ARCHITECTURE
ORACLE ARCHITECTUREORACLE ARCHITECTURE
ORACLE ARCHITECTURE
 
Object oriented databases
Object oriented databasesObject oriented databases
Object oriented databases
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Database
DatabaseDatabase
Database
 
Object oriented database
Object oriented databaseObject oriented database
Object oriented database
 
Metadata ppt
Metadata pptMetadata ppt
Metadata ppt
 
Database design
Database designDatabase design
Database design
 
Non relational databases-no sql
Non relational databases-no sqlNon relational databases-no sql
Non relational databases-no sql
 
Object Storage Overview
Object Storage OverviewObject Storage Overview
Object Storage Overview
 
Database basics
Database basicsDatabase basics
Database basics
 
Distributed Database System
Distributed Database SystemDistributed Database System
Distributed Database System
 
Relational database
Relational database Relational database
Relational database
 

En vedette

VNSISPL_DBMS_Concepts_appA
VNSISPL_DBMS_Concepts_appAVNSISPL_DBMS_Concepts_appA
VNSISPL_DBMS_Concepts_appAsriprasoon
 
Top 5 performance and capacity challenges for z/OS
Top 5 performance and capacity challenges for z/OS Top 5 performance and capacity challenges for z/OS
Top 5 performance and capacity challenges for z/OS Metron
 
Mainframe Optimization in 2017
Mainframe Optimization in 2017Mainframe Optimization in 2017
Mainframe Optimization in 2017Precisely
 
CA IDMS Database Navigation
CA IDMS Database NavigationCA IDMS Database Navigation
CA IDMS Database NavigationCA Technologies
 
Indexing and-hashing
Indexing and-hashingIndexing and-hashing
Indexing and-hashingAmi Ranjit
 
Artificial neural network model & hidden layers in multilayer artificial neur...
Artificial neural network model & hidden layers in multilayer artificial neur...Artificial neural network model & hidden layers in multilayer artificial neur...
Artificial neural network model & hidden layers in multilayer artificial neur...Muhammad Ishaq
 
Indexing and hashing
Indexing and hashingIndexing and hashing
Indexing and hashingJeet Poria
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMSkoolkampus
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data StructuresSHAKOOR AB
 

En vedette (15)

VNSISPL_DBMS_Concepts_appA
VNSISPL_DBMS_Concepts_appAVNSISPL_DBMS_Concepts_appA
VNSISPL_DBMS_Concepts_appA
 
MCPS_IDMS_to_Oracle_Conversion
MCPS_IDMS_to_Oracle_ConversionMCPS_IDMS_to_Oracle_Conversion
MCPS_IDMS_to_Oracle_Conversion
 
Top 5 performance and capacity challenges for z/OS
Top 5 performance and capacity challenges for z/OS Top 5 performance and capacity challenges for z/OS
Top 5 performance and capacity challenges for z/OS
 
Database model BY ME
Database model BY MEDatabase model BY ME
Database model BY ME
 
Mainframe Optimization in 2017
Mainframe Optimization in 2017Mainframe Optimization in 2017
Mainframe Optimization in 2017
 
CA IDMS Database Navigation
CA IDMS Database NavigationCA IDMS Database Navigation
CA IDMS Database Navigation
 
Huffman codes
Huffman codesHuffman codes
Huffman codes
 
Indexing and-hashing
Indexing and-hashingIndexing and-hashing
Indexing and-hashing
 
Artificial neural network model & hidden layers in multilayer artificial neur...
Artificial neural network model & hidden layers in multilayer artificial neur...Artificial neural network model & hidden layers in multilayer artificial neur...
Artificial neural network model & hidden layers in multilayer artificial neur...
 
Indexing and hashing
Indexing and hashingIndexing and hashing
Indexing and hashing
 
Database and different types of databases available in market
Database and different types of databases available in marketDatabase and different types of databases available in market
Database and different types of databases available in market
 
Indexing Data Structure
Indexing Data StructureIndexing Data Structure
Indexing Data Structure
 
12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS12. Indexing and Hashing in DBMS
12. Indexing and Hashing in DBMS
 
Dbms models
Dbms modelsDbms models
Dbms models
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 

Similaire à Network Database System Overview

Database-management-system-dbms-ppt.pptx
Database-management-system-dbms-ppt.pptxDatabase-management-system-dbms-ppt.pptx
Database-management-system-dbms-ppt.pptxsqlserver4
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbmsAnjaan Gajendra
 
Introduction to DBMS and SQL Overview
Introduction to DBMS and SQL OverviewIntroduction to DBMS and SQL Overview
Introduction to DBMS and SQL OverviewPrabu U
 
Introduction to Database, Purpose of Data, Data models, Components of Database
Introduction to Database, Purpose of Data, Data models, Components of DatabaseIntroduction to Database, Purpose of Data, Data models, Components of Database
Introduction to Database, Purpose of Data, Data models, Components of Databasekasthurimukila
 
Mi0034 – database management system
Mi0034 – database management systemMi0034 – database management system
Mi0034 – database management systemsmumbahelp
 
data base management system (DBMS)
data base management system (DBMS)data base management system (DBMS)
data base management system (DBMS)Varish Bajaj
 

Similaire à Network Database System Overview (20)

App A
App AApp A
App A
 
App A
App AApp A
App A
 
App a
App aApp a
App a
 
Network model.ppt
Network model.pptNetwork model.ppt
Network model.ppt
 
Database-management-system-dbms-ppt.pptx
Database-management-system-dbms-ppt.pptxDatabase-management-system-dbms-ppt.pptx
Database-management-system-dbms-ppt.pptx
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbms
 
Introduction to DBMS and SQL Overview
Introduction to DBMS and SQL OverviewIntroduction to DBMS and SQL Overview
Introduction to DBMS and SQL Overview
 
database
databasedatabase
database
 
Week 1
Week 1Week 1
Week 1
 
Nosql
NosqlNosql
Nosql
 
Nosql
NosqlNosql
Nosql
 
Dbms
DbmsDbms
Dbms
 
App B
App BApp B
App B
 
Introduction to Database, Purpose of Data, Data models, Components of Database
Introduction to Database, Purpose of Data, Data models, Components of DatabaseIntroduction to Database, Purpose of Data, Data models, Components of Database
Introduction to Database, Purpose of Data, Data models, Components of Database
 
Mi0034 – database management system
Mi0034 – database management systemMi0034 – database management system
Mi0034 – database management system
 
data base management system (DBMS)
data base management system (DBMS)data base management system (DBMS)
data base management system (DBMS)
 
Bt0066 dbms
Bt0066 dbmsBt0066 dbms
Bt0066 dbms
 
dbms-1.pptx
dbms-1.pptxdbms-1.pptx
dbms-1.pptx
 
ORDBMS.pptx
ORDBMS.pptxORDBMS.pptx
ORDBMS.pptx
 
Unit01 dbms
Unit01 dbmsUnit01 dbms
Unit01 dbms
 

Network Database System Overview

  • 1. Network Database System Prepared by Sir Gio
  • 2. Network Model  Another widely used in data model  Many-to-Many relationship  Owner – parent record  Member – child record  Links – collection of records which are connected to one another
  • 3. Concept of Owner-Member Relationship DEPARTMENT FACULTY MAJORS CLASSES STUDENTS OWNER-MEMBER RELATIONSHIP
  • 4. OCCURRENCE DIAGRAMS  Used to illustrate the distribution of owner and member records within a network database  Helps in navigation of the database
  • 5. An Occurrence Diagram Dr. Jao Faculty BSIT records Department Dr. records Ramiro BSCS DIT Faculty Dr. records Dr. Flavier Dr. J Belen Dr. Cruz Dr. Dr. Holmes Rizal Dr. No Faculty records
  • 6. CODASYL-DBTG Model  Conference On Data System Languages, Data Base Task Group  Original network model presented in a report by CODASYL-DBTG  Collection of set types, owner record types, and member record types
  • 7. Characteristics of CODASYL Network Model 1. There must be one-to-many relationship between pairs of record types related with respect to an owner-with-member relationship 2. A given owner instance must posses a unique set of member instances 3. A given record type cannot be both the owner and member of the same set type  Records and their fields are represented as record type type customer = record type account = record customer-name: string; account-number: integer; customer-street: string; balance: integer; customer-city: string;
  • 8. DBTG Model  Simplified by limiting the link options to one-to-one or one-to-many  Entity relationship is referred to as DBTG set The arrowhead is used to Segment A denote: ownership Records or segments are represented as boxes Links are represented as Segment B lines
  • 9. DBTG Model  Just like in hierarchical databases, a particular set can have any number of set occurrences CUSTOMER A CUSTOMER B CUSTOMER C ACCOUNT 1 ACCOUNT 2 ACCOUNT 3 ACCOUNT 4 ACCOUNT 5 ACCOUNT 6 A descriptive CUSTACCT SET OCCURRENCES way of naming a DBTG database is by combining the names of the owner and member segments
  • 10. DBTG Model  Another way of illustrating a set occurrence is similar to the one used in mathematical sets CUSTOMER A CUSTOMER B CUSTOMER C CUSTOMER D ACCOUNT 1 ACCOUNT 4 ACCOUNT 6 ACCOUNT 1 ACCOUNT 5 ACCOUNT 1 CUSTACCT SET OCCURRENCES
  • 11. DBTG Model  A set of occurrence can be represented as a link list CUSTOMER A ACCOUNT 1 ACCOUNT 2 ACCOUNT 3 CUSTOMER B ACCOUNT 4 ACCOUNT 5 CUSTOMER C ACCOUNT 6 Illustrates that the member LINKED REPRESENTATION OF A SET OCCURRENCES segments are ordered
  • 12. DBTG Model CUSTOMER BRANCH Let us add another owner segment and ACCOUNT call it BRANCH This segment is also an owner of the ACCOUNT segment
  • 13. DBTG Model  The Data Structure Diagram below shows the inclusion of segment BRANCH and fields of each segment CUSTOMER BRANCH name street city name assets city ACCOUNT number balance
  • 14. DBTG Model  A populated representation will help further understanding the existing owner-member relationship in set CUSTACCT and BRNACCT ACCOUNT 1 CUSTOMER ACCOUNT 2 BRANCH 1 A CUSTOMER ACCOUNT 3 BRANCH 2 B CUSTOMER ACCOUNT 4 C ACCOUNT 5 ACCOUNT 6 CUSTACCT AND BRNACCT OWNER-MEMBER RELATIONSHIP
  • 15. DBTG Model OWNERS MEMBERS CUSTOMER A ACCOUNT 1, 2 AND 3 CUSTOMER B ACCOUNT 4 AND 5 CUSTOMER C ACCOUNT 6 BRANCH 1 ACCOUNT 1, 2 AND 4 BRANCH 2 ACCOUNT 3, 5 AND 6 SET COMPOSITION SUMMARY •Segments are owned by more than one owner segment •This illustrates the fact that entity relationships within a DBTG set is limited to one –to-one or one-to-many •This avoids the need to deal with complicated many-to-many relationships
  • 16. DBTG Model CUSTOMER SEGMENT BRANCH SEGMENT NAME ADDRESS CITY NAME ASSETS CITY Hagar Kalayaan Quezon Grace Park 1000000000 Caloocan 1 Ana Avenida Manila Cervantes 1233333455 Manila Carlo Forbes Manila 6 ACCOUNTS SEGMENT NUMBER BALANCE 12340 1000 12341 100020 12342 10006 12343 123222 12344 21233 12345 123433 SAMPLE RECORDS OF THE THREE SAMPLE SEGMENT
  • 18. DBTG Data-Retrieval Facility  The DBTG data manipulation language consists of a number of commands that are embedded in a host language  Run unit  System application program consisting of a sequence of host language and DBTG command statements  Statements access and manipulate database items as well as locally declared variables  Program work-area (or user work area)  A buffer storage area the system maintains for each application program
  • 19. DBTG Variables  Record Templates  Currency pointers  Current of record type  Current of set type  Current of run unit  Status flags  DB-status is most frequently used  Additional variables: DB-set-name, DB-record-name, and DB-data-name
  • 20. Example Program Work Area  Templates for three record types:  customer  Account  branch  Six currency pointers  Three pointers for record types: one each tot he most recently accessed customer, account, and branch record  Two pointers for set types: one to the most recently accessed record in an occurrence of the set depositor, one to the most recently accessed record in an occurrence of the set account- branch  One run-unit pointer  Status flags: four variables defined previously  Following diagram shows an example program work area state
  • 22. The Find and Get Commands  find  Locates a record in the database and sets the appropriate currency pointers  get  Copies of the record to which the current of run-unit points from the database to the appropriate program work area template  Example: Executing a find command to locate the customer record belonging to Johnson causes the following changes to occur in the state of the program work area.  The current of the record type customer now points to the record of Johnson  The current of set type depositor now points to the set owned by Johnson  The current of run unit now points to customer record Johnson
  • 23. Access of Individual Records  find any <record type> using <record-field>  Locates a record of type <record type> whose <record- field> value is the same as the value of <record-field> in the <record type> template in the program work area.  Once such a record is found, the following currency pointers are set to point to that record:  The current of run-unit pointer  The record-type currency pointer for <record type>  For each set in which that record belongs, the appropriate set currency pointer  find duplicate <record type> using <record-field>  Locates (according to a system-dependent ordering) the next record that matches the <record-field>
  • 24. Access of Records Within a Set  Other find commands locate records in the DBTG set that is pointed to by the <set-type> currency pointer  find first <record type> within <set-type> Locates the first database record of type <record type> belonging to the current <set-type>  find next <record type> within <set-type>  which finds the next element in the set <set-type>  find owner within <set-type>  Locates the owner of a particular DBTG set
  • 25. Predicates  For queries in which a field value must be matched with a specified range of values, rather than to only one, we need to:  get the appropriate records into memory  examine each one separately for a match  determine whether each is the; target of our find statement
  • 26. Example DBTG Query  Print the total number of accounts in the Perryridge branch with a balance greater than $10,000 count := 0; branch.branch-name := “Perryridge”; find any branch using branch-name; find first account within account-branch; while DB-status = 0 do begin get account if account.balance > 10000 then count := count + 1; find next account within account-branch; end print (count);
  • 27. DBTG Update Facility  DBTG mechanisms are available to update information in the database.  To create a new record of type <record type>  insert the appropriate values in the corresponding <record type> template  add this new record to the database by executing store <record type>  Can create and add new records only one at a time
  • 28. DBTG Update Facility  To modify an existing record of type <record type>  find that record in the database  get that record into memory  change the desired fields in the template of <record type>  reflect the changes to the record to which the currency point of <record type> points by executing modify <record type>
  • 29. DBTG Update Facility  To delete an existing record of type <record type>  make the currency pointer of that type point to the record in the database to be deleted  delete that record by executing erase <record type>  Delete an entire set occurrence by finding the owner of the set and executing erase all <record type>  Deletes the owner of the set, as well as all the set’s members.  If a member of the set is an owner of another set, the members of that second set also will be deleted  erase all is recursive
  • 30. DBTG Set-Processing Facility  Mechanisms are provided for inserting records into and removing records from a particular set occurrence  Insert a new record into a set by executing the connect statement connect <record type> to <set-type>  Remove a record from a set by executing the disconnect statement disconnect <record type> from <set-type>
  • 31. Example disconnect Query  Close account A-201, that is, delete the relationship between account A-201 and its customer, but archive the record of account A- 201  The following program removes account A-201 from the set occurrence of type depositor. The account will still be accessible in the database for record- keeping purposes account.account-number := “A-201”; find for update any account using account-number. get account, find owner within depositor, disconnect account from depositor.
  • 32. DBTG Set-Processing Facility (Cont.)  To move a record of type <record type> from one set occurrence to another set occurrence of type <set- type>  Find the appropriate record and the owner of the set occurrences to which that record is to be moved.  Move the record by executing reconnect <record type> to <set-type>  Example: Move all accounts of Hayes that are currently at the Perryridge branch to the Downtown branch.
  • 33. Example reconnect Query customer.customer-name := “Hayes”; find any customer using customer-name; find first account within depositor; while DB-status = 0 do begin find owner within account-branch; get branch; if branch.branch-name = “Perryridge” then begin branch.branch-name := “Downtown”; find any branch using branch-name; reconnect account to account-branch; end find next account within depositor, end
  • 34. DBTG Set-Processing Facility (Cont.)  A newly created member record of type <record type> of a set type <set-type> can be added to a set occurrence either explicitly (manually) or implicitly (automatically).  Specify the insert mode at set-definition time via insertion is <insert mode>  manual: connect <record type> to <set-type>  automatic: store <record type>
  • 35. Set Insertion Example  Create account A535 for customer Hayes at the Downtown branch.  Set insertion is manual for set type depositor and is automatic for set type account-branch. branch.branch-name := “Downtown”; find any branch using branch-name; account.account-number := “A-535”; account.balance := 0; store account; customer.customer-name := “Hayes”; find any customer using customer-name; connect account to depositor;