Hierarchical Model


A forest of rooted trees. We show the tree structure as follows:

Each parent-child link is a one-many relationship. So each parent has many children of each type. This can be shown as:

CSMC 508

CMSC 401

CMSC 312

Fall 2005, Room 105

Dr. Parker

J. Smith

K.Peters

Spring 2006, Room 104

Dr. Ames

Dr. Parker

J. Smith

C. Student

So we do a pre-order traversal to get the list. First we list the parent, then the children in order from left to right doing all children of a given type. I have used indenting to try and show the levels of the trees.

Notice the redundancy in this scheme. Teacher records are repeated every time they teach another class (as one example). We can use a virtual record to fix this.

IMS

Information Management System - developed by IBM to work with the OS/VS system. It is designed for batch applications.

The "physical database" is a collection of hierarchical trees. The DBD (database description) describes a physical database.

DDL - Data Definition Language

Used to define the Physical Database. The statements that can be used are:

DBD NAME=name This is the name of the "database". All names are limited to 8 characters
SEGM NAME=name, BYTES=length, PARENT=segname, VIRTUAL segname IN dbdname NAME is the name of the segment. A segment is a node of the tree. You can think of it as a record.
BYTES gives the length of the segment.
PARENT is required for all segments except the root segment. It gives the name of the segments parent in the tree structure.
VIRTUAL is optional. It refers to the fact that this segment is really just a dummy pointing to the real segment (name given) in another tree (dbdname given).
FIELD NAME=name, BYTES=length, START=position
NAME=(name,SEQ)
NAME=(name,SEQ,M)
NAME is the name of the field within the current segment.
SEQ means that this field is to be used to order the segments. Only one field can be marked SEQ. You do not have to mark any field SEQ. Sequence fields are unique in value unless M is used.
M means that multiple occurrences of the same value are allowed.
BYTES gives the length of the field.
START gives the position at which the field starts. It is allowable to have overlapping fields defined.

These statements must be in the correct order. Segments must be defined starting at the top of the tree, and children of a segment are defined from left to right. Field statements must follow immediately after the segment statement.

Here is a sample DBD:

DBD NAME=EDUCPDBD

SEGM NAME=COURSE,BYTES=256

FIELD NAME=(COURSE#,SEQ),BYTES=3,START=1

FIELD NAME=TITLE,BYTES=33,START=4

FIELD NAME=DESCRIPN,BYTES=220,START=37

SEGM NAME=PREREQ,PARENT=COURSE,BYTES=36

FIELD NAME=(COURSE#,SEQ),BYTES=3,START=1

FIELD NAME=TITLE,BYTES=33,START=4

SEGM NAME=OFFERING,PARENT=COURSE,BYTES=20

FIELD NAME=(DATE,SEQ,M),BYTES=6,START=1

FIELD NAME=LOCATION,BYTES=12,START=7

FIELD NAME=FORMAT,BYTES=2,START=19

SEGM NAME=TEACHER,PARENT=OFFERING,BYTES=24

FIELD NAME=(EMP#,SEQ),BYTES=6,START=1

FIELD NAME=NAME,BYTES=18,START=7

SEGM NAME=STUDENT,PARENT=OFFERING,BYTES=25

FIELD NAME=(EMP#,SEQ),BYTES=6,START=1

FIELD NAME=NAME,BYTES=18,START=7

FIELD NAME=GRADE,BYTES=1,START=25

--------------------------------------------------------------------

The user's view is the LDB logical database. To create the Logical Database, we define a PCB (Program Communication Block). This is done by defining which portions of a DBD are to be made "sensitive" or accessible to a user. The statements used to do this are:

PCB TYPE=DB, DBDNAME=dbdname, KEYLEN=size DBDNAME specifies the corresponding DBD.
KEYLEN reserves an area to be the "key feedback area". Whenever a segment is accessed this area contains a fully concatenated key.
SENSEG NAME=segname, PROOPT= x where x is one of K G I R D NAME identifies the name of the segment to be included in the Logical Database. Not all segments in the DBD need to occur in the PCB.
The PROOPT (processing option) gives the type of access that is allowed. G is Get (read only), I is Insert, R is Replace, and D is Delete. K stands for Key sensitivity, and means that you do not need to access this segment, but you do need to be allowed to pass through it to get to its children.
SENFLD NAME=fieldname If no SENSFLD statements are given, all fields are assumed to be sensitive. If PROOPT=K was used for segment, no fields can be sensitive.

A PCB for a user who only needed to find out information about which students took which classes (no need to know which section or grade) would look like:

PCB TYPE=DB, DBDNAME=EDUCPDBD,KEYLEN=15

SENSEG NAME=COURSE,PROOPT=G

SENFLD NAME=TITLE

SENSEG NAME=OFFERING,PROOPT=K

SENSEG NAME=STUDENT,PROOPT=G

SENFLD NAME=NAME


DL/I - Data Language I - Query Language

The following statements would be embedded in some language (such as PL/I) to manipulate the database:

1) GU - Get Unique

GU course offering (Location='Stockholm')


2) GN - Get Next


                       GN student

 

3)GNP - Get Next within Parent

GNP student

 

4) GHU, GHN, GHNP - as above but HOLD the result (this allows update and deletion)

 

5) DLET - Delete

 

6) REPL - Replace

 

7) ISRT - Insert - will insert at current location

 

The GET HOLD commands copy the information you reach into a local data area. To replace (or insert) you change the data in the local area, and then issue the command to write to the database. The condition for the GET can be complex but can only refer to one record.