THE NETWORK DATA MODEL
In the network data model, the database consists of
a collection of set-type occurrences.
Each set-type
occurrence has one occurrence of OWNER RECORD,
with zero or more occurrences of MEMBER RECORDS.
The member sets belonging to different owners are
disjoint.
To define a network database one needs to define:
(a) the database record types which
consist of data items, and
(b) the set-types.
Network Set-Type Occurence
CONCEPT OF CURRENCY
For the network approach, since the
application programmer must
navigate through the database, the concept of
CURRENCY
is used to determine the current run-unit
record occurrences, and
set-type occurrences.
suppose the commands are:
MOVE 'S4' to SNO IN S
FIND S RECORD
FIND FIRST SP RECORD OF S-SP SET
FIND OWNER IN P-SP OF CURRENT OF S-SP SET
At the end of execution of the
above commands, we have:
Current of run-unit: P 'P2'
Current S occurrence: S 'S4'
Current P occurrence: P 'P2'
Current SP occurrence: SP 'S4, P2, 2'
Current of set S-SP: SP 'S4, P2, 2'
Current of set P-SP: P 'P2'
Current S-SP occurrence: owned by S 'S4'
Current P-SP occurrence: owned by P 'P2'
Current of Basic-Data-Area: P 'P2'
Current of Link-Data-Area: SP 'S4, P2, 2'
Example Supplier-Parts Database
USER WORK AREA (UWA)
A set of program variables, declared in the
host program, to communicate the contents
of individual records between the DBMX
and the host program.
For each record type in the database schema,
a corresponding program variable with the
same format should be declared in the
host program.
NETWORK DATABASE MANIPULATION LANGUAGE
The major commands are: FIND, GET,
MODIFY, INSERT, REMOVE, DELETE, and STORE.
(1) FIND command is used to locate an existing record occurrence, and
establish it as the current of the run-unit, and also the current of
the appropriate area, appropriate record type, and all sets in which
it participates. The simplest form of the FIND command is as follows.
MOVE 'S4' TO SNO IN S.
FIND S RECORD.
The first statement constructs
a prototype S record in the user's work area, which is then used to
find the S record in the database.
DML Commands
(2) GET command is used to retrieve the current of run-unit. For
example, the commands
MOVE 'S4' TO SNO IN S.
FIND S RECORD.
GET S; SNAME, CITY.
retrieve details of supplier 'S4'. The first two
commands are the same as in previous example. The last command retrieves
the current of the run-unit (the S record for 'S4') into the UWA.
DML Commands
(3) MODIFY command is used to update the current of run-unit, as
illustrated in the follow example.
MOVE 'S4' TO SNO IN S.
FIND S RECORD.
GET S; STATUS.
ADD 10 TO STATUS IN S.
MODIFY S; STATUS.
DML Commands
(4) INSERT command inserts current of run-unit into one or more
set occurrences. For example, the following commands insert
the EMP record occurrence for employee 'E6' as a member into the
DEPT-EMP occurrence owned by DEPT occurrence 'D1'.
MOVE 'D1' TO DNO IN DEPT.
FIND DEPT RECORD.
MOVE 'E6' TO ENO IN EMP.
FIND EMP RECORD.
INSERT EMP INTO DEPT-EMP.
DML Commands
(5) REMOVE command removes current of run-unit from one or more set
occurrences.
An example follows.
MOVE 'D1' TO DNO IN DEPT.
FIND DEPT RECORD.
MOVE 'E6' TO ENO IN EMP.
FIND EMP RECORD.
REMOVE EMP FROM DEPT-EMP.
DML Commands
(6) DELETE command deletes the current of run-unit, which may be owner
records.
MOVE 'S4' TO SNO IN S.
FIND S RECORD.
DELETE S [ONLY, SELECTIVE, ALL].
The keyword after the DELETE S clause specifies the side effects of
the deletion command. If no keyword is specified, then S is deleted only
if S is not owner of any nonempty set occurrences. If "ONLY" is specified,
then S is deleted together with all MANDATORY member occurrences.
If "SELECTIVE" is specified, S is deleted together with all MANDATORY
member occurrences and other member occurrences that are not in any
other set occurrences. IF "ALL" is specified, then S is deleted together
with all of its members.
DML Commands
(7) STORE command creates a new record occurrence which could be
a link record, and establishes it as the current of the run-unit.
For example, to crate a new SP record 'S5, P6, 7', the commands are:
MOVE 'S5' TO SNO IN SP.
MOVE 'P6' TO PNO IN SP.
MOVE '7' TO QTY IN SP.
MOVE 'S5' TO SNO IN S.
MOVE 'P6' TO PNO IN P.
STORE SP.
MEMBERSHIP CLASS
It specifies the semantics of database
operations.
MANDATORY:
Record can only be removed when
its owner is removed (i.e., the
REMOVE command may not be used
the DELETE command must be used).
OPTIONAL:
The record can be removed or deleted.
AUTOMATIC:
It can be added to a set with the correct
owner using the STORE command.
MANUAL:
It will not be automatically added
to the set with the correct owner,
and the INSERT command is necessary.
LOCATION MODE
In defining a network database, one has to define both the record types
and the set types. When the record types are defined, one can also
define the
location mode,
which specifies the access strategy for a record (an owner record or a
member record). For example, in define the S record, the following
clause may be added:
LOCATION MODE IS DIRECT S-KEY
and S-KEY is used as database key for addressing S records.
The following clause,
LOCATION MODE IS CALC HASH-SNO USING SNO IN S
will establish SNO as the hash key for the hashing procedure HASH-SNO
supplied by the application programmer.
INDIRECT ACCESS
DEPT record is accessed via DIV record and
DIV-DEPT set-type.
The hierarchical relations among DIV, DEPT and
EMP are as follows:
DIV ------------------>DEPT------------------->EMP
DIV-DEPT set-type DEPT-EMP set-type
The location mode for DEPT record can be specified as
LOCATION MODE IS VIA DIV-DEPT SET.
LOCATION MODE SPECIFIES ACCESS STRATGEY:
(a) direct
(b) calculated by hashing or indexing
(c) indirect via another set
RETRIEVAL EXAMPLES
(a) Find a record using a key.
Suppose for record EMP, in its
definition, ENO is defined as a key,
USAGE IS DATABASE-KEY.
Then to find EMP record, we can say
FIND EMP USING ENO.
RETRIEVAL EXAMPLES
(b) Find a record by a translation
algorithm. Suppose EMP record
has a LOCATION MODE in its definition,
LOCATION MODE IS CALC HASH-ENO
USING ENO IN EMP
DUPLICATES ARE NOT ALLOWED.
Then one can access an EMP record by
setting up ENO, and issuing a FIND
command.
MOVE 'E2' TO ENO IN EMP.
FIND EMP RECORD.
RETRIEVAL EXAMPLES
(c) Find next (first, last, prior) record for sequential processing.
Suppose the desired DEPT record is found. To process EMP records, one
can say,
FIND FIRST EMP RECORD OF DEPT-EMP SET.
FIND NEXT EMP RECORD OF DEPT-EMP SET.
FIND PRIOR EMP RECORD OF DEPT-EMP SET.
(d) Find owner of a record. For particular EMP record, one can find its owner
record.
FIND OWNER IN DEPT-EMP OF CURRENT
OF DEPT-EMP SET.