DBMS 4
DBMS 4
&
HIERARCHICAL
MODEL
UNIT-IV
NETWORK MODEL:BASIC CONCEPTS
• Replace entity sets account, customer, and branch with record types
account, customer, and branch, respectively.
• Create a new record type Rlink (referred to as a dummy record type).
• Create the following many-to-one links:
o CustRlink from Rlink record type to customer record type
o AcctRlnk from Rlink record type to account record type
o BrncRlnk from Rlink record type to branch record type
DBTG CODASYL MODEL
o All links are treated as many-to-one relationships.
o To model many-to-many relationships, a record type is defined to
represent the relationship and two links are used.
• The structure consisting of two record types that are linked together is referred to
in the DBTG model as a DBTG set.
• In each DBTG set, one record type is designated as the owner, and the other is
designated as the member, of the set.
• Each DBTG set can have any number of set occurrences (actual instances of
linked records).
• No member record of a set can participate in more than one occurrence of the set
at any point.
• A member record can participate simultaneously in several set occurrences of
different DBTG sets.
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
get account
if account.balance > 10000 then count := count + 1;
find next account within account-branch
DBTG UPDATE FACILITY
DBTG mechanisms are available to update information in the database.
• To create a new record of type
-- insert the appropriate values in the corresponding template
--add this new record to the database by executing store
-- Can create and add new records only one at a time
• 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
MAPPING FILES TO NETWORK
• We implement links by adding pointer fields to records that are associated via a
link
--Each record must have one pointer field for each link with which it is
associated.
--Example data-structure diagram and corresponding database.
• Diagram showing the sample instance with pointer fields to represent the links.
Each link is replaced by two pointer
This database model organizes data into a tree-like-structure, with a single root,
to which all the other data is linked. The hierarchy starts from the Root data, and
expands like a tree, adding child nodes to the parent nodes.
• In this model, a child node will only have a single parent node.
• This model efficiently describes many real-world relationships like index of a
book, recipes etc.
• In hierarchical model, data is organized into tree-like structure with one one-to
many relationship between two different types of data, for example, one
department can have many courses, many professors and of-course many
students.
***It is somehow similar to the data structure in the network model, the
difference is that network model records are organized in the graph form
whereas in the hierarchical model records are organized in tree structure.
A parent may have an arrow pointing to child ,but a child must have an
arrow pointing to its parent
• Database schema is represented as a collection of tree-structure
diagrams.
› single instance of a database tree
The root of this tree is a dummy node
› The children of that node are actual instances of the
appropriate record type
• When transforming E-R diagrams to corresponding tree-structure
diagrams, we must ensure that the resulting diagrams are in the form
of rooted trees.
• Example E-R diagram with two entity sets, customer and account,
related through a binary, one-to-many relationship depositor.
• Corresponding tree-structure diagram has
•• the record type customer with three fields: customer-name,
customer-street, and customer-city.
• the record type account with two fields: account-number and
balance
› the link depositor, with an arrow pointing to customer
• If the relationship depositor is one to one, then the link depositor has
two arrows.
• Only one-to-many and one-to-one relationships can be directly
represented in the hierarchical mode.
DATA RETRIEVAL IN HIERARCHICAL MODEL
• We present querying of hierarchical databases via a simplified version of
DL/I(data language/1), the data-manipulation language of
IMS(Information Management System by IBM.
• Example schema:
customer-account-branch
--A branch can have several customers, each of which can have several
accounts.
--An account may belong to only one customer, and a customer can
belong to only one branch.