SlideShare a Scribd company logo
1 of 58
Chapter B: Hierarchical Model
Basic Concepts
Tree-Structure Diagrams
Data-Retrieval Facility
Update Facility
Virtual Records
Mapping of Hierarchies to Files
The IMS Database System

Database System Concepts

B.1

©Silberschatz, Korth and Sudarshan
Basic Concepts
A hierarchical database consists of a collection of records which
are connected to one another through links.
a record is a collection of fields, each of which contains only one
data value.
A link is an association between precisely two records.
The hierarchical model differs from the network model in that the
records are organized as collections of trees rather than as
arbitrary graphs.

Database System Concepts

B.2

©Silberschatz, Korth and Sudarshan
Tree-Structure Diagrams
The schema for a hierarchical database consists of
 boxes, which correspond to record types
 lines, which correspond to links

Record types are organized in the form of a rooted tree.
 No cycles in the underlying graph.
 Relationships formed in the graph must be such that only
one-to-many or one-to-one relationships exist between a parent and
a child.

Database System Concepts

B.3

©Silberschatz, Korth and Sudarshan
General Structure

A parent may have an arrow pointing to a child, but a child must
have an arrow pointing to its parent.

Database System Concepts

B.4

©Silberschatz, Korth and Sudarshan
Tree-Structure Diagrams (Cont.)
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.

Database System Concepts

B.5

©Silberschatz, Korth and Sudarshan
Single Relationships

Database System Concepts

B.6

©Silberschatz, Korth and Sudarshan
Single relationships (Cont.)
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

Database System Concepts

B.7

©Silberschatz, Korth and Sudarshan
Single Relationships (Cont.)
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.

Database System Concepts

B.8

©Silberschatz, Korth and Sudarshan
Transforming Many-To-Many
Relationships
Must consider the type of queries expected and the degree to
which the database schema fits the given E-R diagram.
In all versions of this transformation, the underlying database
tree (or trees) will have replicated records.

Database System Concepts

B.9

©Silberschatz, Korth and Sudarshan
Many-To Many Relationships (Cont.)

Database System Concepts

B.10

©Silberschatz, Korth and Sudarshan
Many-To-Many Relationships (Cont.)
Create two tree-structure diagrams, T1, with the root customer,
and T2, with the root account.
In T1, create depositor, a many-to-one link from account to
customer.
In T2, create account-customer, a many-to-one link from
customer to account.

Database System Concepts

B.11

©Silberschatz, Korth and Sudarshan
Sample Database

Database System Concepts

B.12

©Silberschatz, Korth and Sudarshan
General Relationships
Example ternary E-R diagram and corresponding tree-structure
diagrams are shown on the following page.

Database System Concepts

B.13

©Silberschatz, Korth and Sudarshan
Sample Ternary Databases. (a) T 1
(b) T 2

Database System Concepts

B.14

©Silberschatz, Korth and Sudarshan
Several Relationships
To correctly transform an E-R diagram with several relationships,
split the unrooted tree structure diagrams into several diagrams,
each of which is a rooted tree.
Example E-R diagram and transformation leading to diagram
that is not a rooted tree:

Database System Concepts

B.15

©Silberschatz, Korth and Sudarshan
Several Relationships (Cont.)

Database System Concepts

B.16

©Silberschatz, Korth and Sudarshan
Several Relationships (Cont.)
Corresponding diagrams in the form of rooted trees.

Database System Concepts

B.17

©Silberschatz, Korth and Sudarshan
Several Relationships (2nd Example)

Diagram (b) contains a cycle.
Replicate all three record types, and create two separate
diagrams.
Database System Concepts

B.18

©Silberschatz, Korth and Sudarshan
Several Relationships (2nd Example)
Each diagram is now a rooted tree.

Database System Concepts

B.19

©Silberschatz, Korth and Sudarshan
Data Retrieval Facility
We present querying of hierarchical databases via a simplified
version of DL/I, the data-manipulation language of IMS.
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.

Database System Concepts

B.20

©Silberschatz, Korth and Sudarshan
Example Schema

Database System Concepts

B.21

©Silberschatz, Korth and Sudarshan
Program Work Area
A buffer storage area that contains these variables
 Record templates
 Currency pointers
 Status flag

A particular program work area is associated with precisely one
application program.
Example program work area:
 Templates for three record types: customer, account, and branch.
 Currency pointer to the most recently accessed record of branch,
customer, or account type.
 One status variable.

Database System Concepts

B.22

©Silberschatz, Korth and Sudarshan
The get Command
Data items are retrieved through the get command
 locates a record in the database and sets the currency pointer to
point to it
 copies that record from the database to the appropriate program
work-area template

The get command must specify which of the database trees is to
be searched.
State of the program work area after executing get command to
locate the customer record belonging to Freeman
 The currency pointer points now to the record of Freeman.
 The information pertaining to Freeman is copied into the customer
record work-area template.
 DB-status is set to the value 0.

Database System Concepts

B.23

©Silberschatz, Korth and Sudarshan
The get Command (Cont.)
To scan all records in a consistent manner, we must impose an
ordering on the records.
Preorder search starts at the root, and then searches the
subtrees of the root from left to right, recursively.
 Starts at the root, visits the leftmost child, visits its leftmost child, and
so on, until a leaf (childless) node is reached.
 Move back to the parent of the leaf and visit the leftmost unvisited
child.
 Proceed in this manner until the entire three is visited.

Preordered listing of the records in the example database three:
Parkview, Fleming, A-522, A-561, Freeman, A533,
Seashore, Boyd, A-409, A-622

Database System Concepts

B.24

©Silberschatz, Korth and Sudarshan
Access Within A Database Tree
Locates the first record (in preorder), of type <record type> that
satisfies the <condition> of the where clause.
The where clause is optional <condition> is a predicate that
involves either an ancestor of <record type> or the <record type>
itself.
If where is omitted, locate the first record of type
<record-type>
 Set currency pointer to that record
 Copy its contents into the appropriate work-area template.

If no such record exists in the tree, then the search fails, and
DB-status is set to an appropriate error message.

Database System Concepts

B.25

©Silberschatz, Korth and Sudarshan
Example Queries
Print the address of customer Fleming:
get first customer
where customer.customer-name = “Fleming”;
print (customer.customer-address);
Print an account belonging to Fleming that has a balance greater
than $10,000.
get first account
where customer.customer-name = “Fleming”;
and account.balance > 10000;
if DB-status = 0 then print (account.account-number);

Database System Concepts

B.26

©Silberschatz, Korth and Sudarshan
Access Within a Database Tree
(Cont.)
get next <record type>
where <condition>
Locates the next record (in preorder) that satisfies
<condition>.
If the where clause is omitted, then the next record of type
<record type> is located.
The currency pointer is used by the system to determine where
to resume the search.
As before, the currency pointer, the work-area template of type
<record-type>, and DB-status are affected.

Database System Concepts

B.27

©Silberschatz, Korth and Sudarshan
Example Query
Print the account number of all the accounts that have a balance
greater than $500
get first account
where account.balance > 500;
while DB-status = 0 do
begin
print (account.account-number);
get next account
where account.balance > 500;
end
When while loop returns DB-status ≠ 0, we exhausted all
account records with account.balance > 500.

Database System Concepts

B.28

©Silberschatz, Korth and Sudarshan
Access Within a Database Tree
(Cont.)
get next within parent <record type>
where <condition>
Searches only the specific subtree whose root is the most recent
record that was located with either get first or get next.
Locates the next record (in preorder) that satisfies <condition> in
the subtree whose root is the parent of current of <record type>.
If the where clause is omitted, then the next record of type
<record type> within the designated subtree to resume search.
Use currency pointer to determine where to resume search.
DB-status is set to a nonzero value if no such record exists in the
designated subtree (rather than if none exists in the entire tree).

Database System Concepts

B.29

©Silberschatz, Korth and Sudarshan
Example Query
Print the total balance of all accounts belonging to Boyd:
sum := 0;
get first customer
where customer.customer-name = “Boyd”;
get next within parent account;
while DB-status = 0 do
begin
sum = sum + account.balance;
get next within parent account;
end
print (sum);
We exit from the while loop and print out the value of sum only
when the DB-status is set to a value not equal to 0. This value
exists after the get next within parent operation fails.

Database System Concepts

B.30

©Silberschatz, Korth and Sudarshan
Update Facility
Various mechanisms are available for updating information in the
database.
Creation and deletion of records (via the insert and delete
operations).
Modification (via the replace operation) of the content of
existing records.

Database System Concepts

B.31

©Silberschatz, Korth and Sudarshan
Creation of New Records
To insert <record type> into the database, first set the
appropriate values in the corresponding <record type> work-area
template. Then execute
insert <record type>
where <condition>
If the where clause is included, the system searches the
database three (in preorder) for a record that satisfies the
<condition> in the where clause.
Once such a record — say, X — is found, the newly created
record is inserted in the tree as the leftmost child of X.
If where is omitted, the record is inserted in the first position (in
preorder) in the tree where <record type> can be inserted in
accordance with the specified schema.

Database System Concepts

B.32

©Silberschatz, Korth and Sudarshan
Example Queries
Add a new customer, Jackson, to the Seashore branch:
customer.customer-name := “Jackson”;
customer.customer-street := “Old Road”;
customer.customer-city := “Queens”;
insert customer
where branch.branch-name = “Seashore”;
Create a new account numbered A-655 that belongs to customer
“Jackson”;
account.account-number := “A-655”;
account.balance := 100;
insert account
where customer.customer-name = “Jackson”;

Database System Concepts

B.33

©Silberschatz, Korth and Sudarshan
Modification of an Existing Record
To modify an existing record of type <record type>, we must get
that record into the work-area template for <record type>, and
change the desired fields in that template.
Reflect the changes in the database by executing
replace
replace dies not have <record type> as an argument; the record
that is affected is the one to which the currency pointer points.
DL/I requires that, prior to a record being modified, the get
command must have the additional clause hold, so that the
system is aware that a record is to be modified.

Database System Concepts

B.34

©Silberschatz, Korth and Sudarshan
Example Query
Change the street address of Boyd to Northview:
get hold first customer
where customer.customer-name = “Boyd”;
customer.customer-street := “Northview”;
replace;
If there were more than one record containing Boyd’s address,
the program would have included a loop to search all Boyd
records.

Database System Concepts

B.35

©Silberschatz, Korth and Sudarshan
Deletion of a Record
To delete a record of type <record type>, set the currency pointer
to point to that record and execute delete.
As a record modification, the get command must have the
attribute hold attached to it. Example: Delete account A-561:
get hold first account
where account.account-number = “A-561”;
delete;
A delete operation deletes not only the record in question, but
also the entire subtree rooted by that record. Thus, to delete
customer Boyd and all his accounts, we write
get gold first customer
where customer.customer-name = “Boyd”;
delete;

Database System Concepts

B.36

©Silberschatz, Korth and Sudarshan
Virtual Records
For many-to-many relationships, record replication is necessary
to preserve the tree-structure organization of the database.
 Data inconsistency may result when updating takes place
 Waste of space is unavoidable

Virtual record — contains no data value, only a logical pointer to
a particular physical record.
When a record is to be replicated in several database trees, a
single copy of that record is kept in one of the trees and all other
records are replaced with a virtual record.
Let R be a record type that is replicated in T1, T2, . . ., Tn. Create a
new virtual record type virtual-R and replace R in each of the
n – 1 trees with a record of type virtual-R.

Database System Concepts

B.37

©Silberschatz, Korth and Sudarshan
Virtual Records (Cont.)
Eliminate data replication in the diagram shown on page B.11;
create virtual-customer and virtual-account.
Replace account with virtual-account in the first tree, and replace
customer with virtual-customer in the second tree.
Add a dashed line from virtual-customer to customer, and from
virtual-account to account, to specify the association between a
virtual record and its corresponding physical record.

Database System Concepts

B.38

©Silberschatz, Korth and Sudarshan
Sample Database

Database System Concepts

B.39

©Silberschatz, Korth and Sudarshan
Mapping Hierarchies to Files
Implementations of hierarchical databases do not use
parent-to-child pointers, since these would require the use of
variable-length records.
Can use leftmost-child and next-sibling pointers which allow
each record to contain exactly two pointers.
 The leftmost-child pointer points to one child.
 The next-sibling pointer points to another child of the same parent.

Database System Concepts

B.40

©Silberschatz, Korth and Sudarshan
Mapping Hierarchies to Files (Cont.)
Implementation with parent-child pointers.

Implementation with leftmost child and next-sibling pointers.

Database System Concepts

B.41

©Silberschatz, Korth and Sudarshan
Mapping Hierarchies to Files (Cont.)
In general, the final child of a parent has no next sibling; rather
than setting the next-sibling filed to null, place a pointer (or
preorder thread) that points to the next record in preorder.
Using preorder threads allows us to process a tree instance in
preorder simply by following pointers.

Database System Concepts

B.42

©Silberschatz, Korth and Sudarshan
Mapping Hierarchies to Files (Cont.)
May add a third child-to-parent pointer which facilitates the
processing of queries that give a value for a child record and
request a value from the corresponding parent record.
the parent-child relationship within a hierarchy is analogous to
the owner-member relationship within a DBTG set.
 A one-to-many relationship is being represented.
 Store together the members and the owners of a set occurrence.
 Store physically close on disk the child records and their parent.
 Such storage allows a sequence of get first, get next, and
get next within parent statements to e executed with a minimal
number of block accesses.

Database System Concepts

B.43

©Silberschatz, Korth and Sudarshan
The IMS Database System
IBM Information Management System — first developed in the
late 1960s; historically among the largest databases.
Issue queries through embedded calls which are part of the IMS
database language DL/I.
Allows the database designer a broad number of options in the
data-definition language.
 Designer defines a physically hierarchy as the database schema.
 Can define several subschemas (or view) by constructing a logical
hierarchy from the record types constituting the schema.
 Options such as block sizes, special pointer fields, and so on, allow
the database administrator to tune the system.

Database System Concepts

B.44

©Silberschatz, Korth and Sudarshan
Record Access Schemes
Hierarchical sequential-access method (HSAM) — used for
physically sequential files (such as tape files). Records are
stored physically in preorder.
Hierarchical indexed-sequential-access method (HISAM) — an
index-sequential organization at the root level of the hierarchy.
Hierarchical indexed-direct-access method (HIDAM) — index
organization at the root level with pointers to child records.
Hierarchical direct-access method (HDAM) — similar to HIDAM,
but with hashed access at the root level.

Database System Concepts

B.45

©Silberschatz, Korth and Sudarshan
IMS Concurrency Control
Early versions handled concurrency control by permitting only
one update application program to run at a time. Read-only
applications could run concurrent with updates.
Later versions included a program-isolation feature
 Allowed for improved concurrency control
 Offered more sophisticated transaction-recovery techniques (such
as logging); important to online transactions.

The need for high-performance transaction processing led to the
introduction of IMS Fast Path.

Database System Concepts

B.46

©Silberschatz, Korth and Sudarshan
IMS Fast Path
Uses an alternative physical data organization that allows the
most active parts of the database to reside in main memory.
Instead of updates to disk being forced at the end of a
transaction, update is deferred until a checkpoint or
synchronization point.
In the event of a crash, the recovery subsystem must redo all
committed transactions whose updates were not forced to disk.
Allows for extremely high rates of transaction throughput.
Forerunner of main-memory database systems.

Database System Concepts

B.47

©Silberschatz, Korth and Sudarshan
Sample Database

Database System Concepts

B.48

©Silberschatz, Korth and Sudarshan
Sample Database Corresponding to
Diagram of Figure B.4

Database System Concepts

B.49

©Silberschatz, Korth and Sudarshan
Sample Database Corresponding To
Diagram of Figure B.8b

Database System Concepts

B.50

©Silberschatz, Korth and Sudarshan
Tree-Structure Diagram With
Many-To-Many Relationships

Database System Concepts

B.51

©Silberschatz, Korth and Sudarshan
E-R Diagram and Its Corresponding
Tree-Structure Diagrams

Database System Concepts

B.52

©Silberschatz, Korth and Sudarshan
Sample Database Corresponding To
Diagram of Figure B.12b

Database System Concepts

B.53

©Silberschatz, Korth and Sudarshan
New Database Tree

Database System Concepts

B.54

©Silberschatz, Korth and Sudarshan
New Database Tree

Database System Concepts

B.55

©Silberschatz, Korth and Sudarshan
Class-enrollment E-R Diagram

Database System Concepts

B.56

©Silberschatz, Korth and Sudarshan
Parent–Child E-R Diagram

Database System Concepts

B.57

©Silberschatz, Korth and Sudarshan
Car-insurance E-R Diagram

Database System Concepts

B.58

©Silberschatz, Korth and Sudarshan

More Related Content

Viewers also liked (16)

Peubah acak
Peubah acakPeubah acak
Peubah acak
 
E3 chap-04
E3 chap-04E3 chap-04
E3 chap-04
 
Ch2 another design
Ch2 another designCh2 another design
Ch2 another design
 
Ch16
Ch16Ch16
Ch16
 
Ch1 introduction
Ch1   introductionCh1   introduction
Ch1 introduction
 
E3 chap-18
E3 chap-18E3 chap-18
E3 chap-18
 
E3 chap-09
E3 chap-09E3 chap-09
E3 chap-09
 
Ddl
DdlDdl
Ddl
 
Ch9
Ch9Ch9
Ch9
 
Soal kombinatorik
Soal kombinatorikSoal kombinatorik
Soal kombinatorik
 
E3 chap-12
E3 chap-12E3 chap-12
E3 chap-12
 
App a
App aApp a
App a
 
Uji hipotesis
Uji hipotesisUji hipotesis
Uji hipotesis
 
Imk pertemuan-4
Imk pertemuan-4Imk pertemuan-4
Imk pertemuan-4
 
E3 chap-14
E3 chap-14E3 chap-14
E3 chap-14
 
Aries
AriesAries
Aries
 

Similar to App b (20)

Network model.ppt
Network model.pptNetwork model.ppt
Network model.ppt
 
Ch5
Ch5Ch5
Ch5
 
Relational algebra.pptx
Relational algebra.pptxRelational algebra.pptx
Relational algebra.pptx
 
databasemanagementsystempptforbeginners.ppt
databasemanagementsystempptforbeginners.pptdatabasemanagementsystempptforbeginners.ppt
databasemanagementsystempptforbeginners.ppt
 
ch2.ppt
ch2.pptch2.ppt
ch2.ppt
 
ER.ppt
ER.pptER.ppt
ER.ppt
 
E-r Model.ppt
E-r Model.pptE-r Model.ppt
E-r Model.ppt
 
DBA
DBADBA
DBA
 
Lecture_W9_Normalization.ppt
Lecture_W9_Normalization.pptLecture_W9_Normalization.ppt
Lecture_W9_Normalization.ppt
 
relational algebra and calculus queries .ppt
relational algebra and calculus queries .pptrelational algebra and calculus queries .ppt
relational algebra and calculus queries .ppt
 
Ch2
Ch2Ch2
Ch2
 
Basic er diagram
Basic er diagramBasic er diagram
Basic er diagram
 
RDBMS, theory class - 1 (UIU CSI 221)
RDBMS, theory class - 1 (UIU CSI 221)RDBMS, theory class - 1 (UIU CSI 221)
RDBMS, theory class - 1 (UIU CSI 221)
 
Ch1
Ch1Ch1
Ch1
 
Introduction to Database System Concepts
Introduction to Database System ConceptsIntroduction to Database System Concepts
Introduction to Database System Concepts
 
PPT demo
PPT demoPPT demo
PPT demo
 
ch3[1].ppt
ch3[1].pptch3[1].ppt
ch3[1].ppt
 
DBMS PPT 3.pptx
DBMS PPT 3.pptxDBMS PPT 3.pptx
DBMS PPT 3.pptx
 
ch1.ppt
ch1.pptch1.ppt
ch1.ppt
 
PPT (2).ppt
PPT (2).pptPPT (2).ppt
PPT (2).ppt
 

Recently uploaded

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

App b

  • 1. Chapter B: Hierarchical Model Basic Concepts Tree-Structure Diagrams Data-Retrieval Facility Update Facility Virtual Records Mapping of Hierarchies to Files The IMS Database System Database System Concepts B.1 ©Silberschatz, Korth and Sudarshan
  • 2. Basic Concepts A hierarchical database consists of a collection of records which are connected to one another through links. a record is a collection of fields, each of which contains only one data value. A link is an association between precisely two records. The hierarchical model differs from the network model in that the records are organized as collections of trees rather than as arbitrary graphs. Database System Concepts B.2 ©Silberschatz, Korth and Sudarshan
  • 3. Tree-Structure Diagrams The schema for a hierarchical database consists of  boxes, which correspond to record types  lines, which correspond to links Record types are organized in the form of a rooted tree.  No cycles in the underlying graph.  Relationships formed in the graph must be such that only one-to-many or one-to-one relationships exist between a parent and a child. Database System Concepts B.3 ©Silberschatz, Korth and Sudarshan
  • 4. General Structure A parent may have an arrow pointing to a child, but a child must have an arrow pointing to its parent. Database System Concepts B.4 ©Silberschatz, Korth and Sudarshan
  • 5. Tree-Structure Diagrams (Cont.) 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. Database System Concepts B.5 ©Silberschatz, Korth and Sudarshan
  • 6. Single Relationships Database System Concepts B.6 ©Silberschatz, Korth and Sudarshan
  • 7. Single relationships (Cont.) 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 Database System Concepts B.7 ©Silberschatz, Korth and Sudarshan
  • 8. Single Relationships (Cont.) 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. Database System Concepts B.8 ©Silberschatz, Korth and Sudarshan
  • 9. Transforming Many-To-Many Relationships Must consider the type of queries expected and the degree to which the database schema fits the given E-R diagram. In all versions of this transformation, the underlying database tree (or trees) will have replicated records. Database System Concepts B.9 ©Silberschatz, Korth and Sudarshan
  • 10. Many-To Many Relationships (Cont.) Database System Concepts B.10 ©Silberschatz, Korth and Sudarshan
  • 11. Many-To-Many Relationships (Cont.) Create two tree-structure diagrams, T1, with the root customer, and T2, with the root account. In T1, create depositor, a many-to-one link from account to customer. In T2, create account-customer, a many-to-one link from customer to account. Database System Concepts B.11 ©Silberschatz, Korth and Sudarshan
  • 12. Sample Database Database System Concepts B.12 ©Silberschatz, Korth and Sudarshan
  • 13. General Relationships Example ternary E-R diagram and corresponding tree-structure diagrams are shown on the following page. Database System Concepts B.13 ©Silberschatz, Korth and Sudarshan
  • 14. Sample Ternary Databases. (a) T 1 (b) T 2 Database System Concepts B.14 ©Silberschatz, Korth and Sudarshan
  • 15. Several Relationships To correctly transform an E-R diagram with several relationships, split the unrooted tree structure diagrams into several diagrams, each of which is a rooted tree. Example E-R diagram and transformation leading to diagram that is not a rooted tree: Database System Concepts B.15 ©Silberschatz, Korth and Sudarshan
  • 16. Several Relationships (Cont.) Database System Concepts B.16 ©Silberschatz, Korth and Sudarshan
  • 17. Several Relationships (Cont.) Corresponding diagrams in the form of rooted trees. Database System Concepts B.17 ©Silberschatz, Korth and Sudarshan
  • 18. Several Relationships (2nd Example) Diagram (b) contains a cycle. Replicate all three record types, and create two separate diagrams. Database System Concepts B.18 ©Silberschatz, Korth and Sudarshan
  • 19. Several Relationships (2nd Example) Each diagram is now a rooted tree. Database System Concepts B.19 ©Silberschatz, Korth and Sudarshan
  • 20. Data Retrieval Facility We present querying of hierarchical databases via a simplified version of DL/I, the data-manipulation language of IMS. 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. Database System Concepts B.20 ©Silberschatz, Korth and Sudarshan
  • 21. Example Schema Database System Concepts B.21 ©Silberschatz, Korth and Sudarshan
  • 22. Program Work Area A buffer storage area that contains these variables  Record templates  Currency pointers  Status flag A particular program work area is associated with precisely one application program. Example program work area:  Templates for three record types: customer, account, and branch.  Currency pointer to the most recently accessed record of branch, customer, or account type.  One status variable. Database System Concepts B.22 ©Silberschatz, Korth and Sudarshan
  • 23. The get Command Data items are retrieved through the get command  locates a record in the database and sets the currency pointer to point to it  copies that record from the database to the appropriate program work-area template The get command must specify which of the database trees is to be searched. State of the program work area after executing get command to locate the customer record belonging to Freeman  The currency pointer points now to the record of Freeman.  The information pertaining to Freeman is copied into the customer record work-area template.  DB-status is set to the value 0. Database System Concepts B.23 ©Silberschatz, Korth and Sudarshan
  • 24. The get Command (Cont.) To scan all records in a consistent manner, we must impose an ordering on the records. Preorder search starts at the root, and then searches the subtrees of the root from left to right, recursively.  Starts at the root, visits the leftmost child, visits its leftmost child, and so on, until a leaf (childless) node is reached.  Move back to the parent of the leaf and visit the leftmost unvisited child.  Proceed in this manner until the entire three is visited. Preordered listing of the records in the example database three: Parkview, Fleming, A-522, A-561, Freeman, A533, Seashore, Boyd, A-409, A-622 Database System Concepts B.24 ©Silberschatz, Korth and Sudarshan
  • 25. Access Within A Database Tree Locates the first record (in preorder), of type <record type> that satisfies the <condition> of the where clause. The where clause is optional <condition> is a predicate that involves either an ancestor of <record type> or the <record type> itself. If where is omitted, locate the first record of type <record-type>  Set currency pointer to that record  Copy its contents into the appropriate work-area template. If no such record exists in the tree, then the search fails, and DB-status is set to an appropriate error message. Database System Concepts B.25 ©Silberschatz, Korth and Sudarshan
  • 26. Example Queries Print the address of customer Fleming: get first customer where customer.customer-name = “Fleming”; print (customer.customer-address); Print an account belonging to Fleming that has a balance greater than $10,000. get first account where customer.customer-name = “Fleming”; and account.balance > 10000; if DB-status = 0 then print (account.account-number); Database System Concepts B.26 ©Silberschatz, Korth and Sudarshan
  • 27. Access Within a Database Tree (Cont.) get next <record type> where <condition> Locates the next record (in preorder) that satisfies <condition>. If the where clause is omitted, then the next record of type <record type> is located. The currency pointer is used by the system to determine where to resume the search. As before, the currency pointer, the work-area template of type <record-type>, and DB-status are affected. Database System Concepts B.27 ©Silberschatz, Korth and Sudarshan
  • 28. Example Query Print the account number of all the accounts that have a balance greater than $500 get first account where account.balance > 500; while DB-status = 0 do begin print (account.account-number); get next account where account.balance > 500; end When while loop returns DB-status ≠ 0, we exhausted all account records with account.balance > 500. Database System Concepts B.28 ©Silberschatz, Korth and Sudarshan
  • 29. Access Within a Database Tree (Cont.) get next within parent <record type> where <condition> Searches only the specific subtree whose root is the most recent record that was located with either get first or get next. Locates the next record (in preorder) that satisfies <condition> in the subtree whose root is the parent of current of <record type>. If the where clause is omitted, then the next record of type <record type> within the designated subtree to resume search. Use currency pointer to determine where to resume search. DB-status is set to a nonzero value if no such record exists in the designated subtree (rather than if none exists in the entire tree). Database System Concepts B.29 ©Silberschatz, Korth and Sudarshan
  • 30. Example Query Print the total balance of all accounts belonging to Boyd: sum := 0; get first customer where customer.customer-name = “Boyd”; get next within parent account; while DB-status = 0 do begin sum = sum + account.balance; get next within parent account; end print (sum); We exit from the while loop and print out the value of sum only when the DB-status is set to a value not equal to 0. This value exists after the get next within parent operation fails. Database System Concepts B.30 ©Silberschatz, Korth and Sudarshan
  • 31. Update Facility Various mechanisms are available for updating information in the database. Creation and deletion of records (via the insert and delete operations). Modification (via the replace operation) of the content of existing records. Database System Concepts B.31 ©Silberschatz, Korth and Sudarshan
  • 32. Creation of New Records To insert <record type> into the database, first set the appropriate values in the corresponding <record type> work-area template. Then execute insert <record type> where <condition> If the where clause is included, the system searches the database three (in preorder) for a record that satisfies the <condition> in the where clause. Once such a record — say, X — is found, the newly created record is inserted in the tree as the leftmost child of X. If where is omitted, the record is inserted in the first position (in preorder) in the tree where <record type> can be inserted in accordance with the specified schema. Database System Concepts B.32 ©Silberschatz, Korth and Sudarshan
  • 33. Example Queries Add a new customer, Jackson, to the Seashore branch: customer.customer-name := “Jackson”; customer.customer-street := “Old Road”; customer.customer-city := “Queens”; insert customer where branch.branch-name = “Seashore”; Create a new account numbered A-655 that belongs to customer “Jackson”; account.account-number := “A-655”; account.balance := 100; insert account where customer.customer-name = “Jackson”; Database System Concepts B.33 ©Silberschatz, Korth and Sudarshan
  • 34. Modification of an Existing Record To modify an existing record of type <record type>, we must get that record into the work-area template for <record type>, and change the desired fields in that template. Reflect the changes in the database by executing replace replace dies not have <record type> as an argument; the record that is affected is the one to which the currency pointer points. DL/I requires that, prior to a record being modified, the get command must have the additional clause hold, so that the system is aware that a record is to be modified. Database System Concepts B.34 ©Silberschatz, Korth and Sudarshan
  • 35. Example Query Change the street address of Boyd to Northview: get hold first customer where customer.customer-name = “Boyd”; customer.customer-street := “Northview”; replace; If there were more than one record containing Boyd’s address, the program would have included a loop to search all Boyd records. Database System Concepts B.35 ©Silberschatz, Korth and Sudarshan
  • 36. Deletion of a Record To delete a record of type <record type>, set the currency pointer to point to that record and execute delete. As a record modification, the get command must have the attribute hold attached to it. Example: Delete account A-561: get hold first account where account.account-number = “A-561”; delete; A delete operation deletes not only the record in question, but also the entire subtree rooted by that record. Thus, to delete customer Boyd and all his accounts, we write get gold first customer where customer.customer-name = “Boyd”; delete; Database System Concepts B.36 ©Silberschatz, Korth and Sudarshan
  • 37. Virtual Records For many-to-many relationships, record replication is necessary to preserve the tree-structure organization of the database.  Data inconsistency may result when updating takes place  Waste of space is unavoidable Virtual record — contains no data value, only a logical pointer to a particular physical record. When a record is to be replicated in several database trees, a single copy of that record is kept in one of the trees and all other records are replaced with a virtual record. Let R be a record type that is replicated in T1, T2, . . ., Tn. Create a new virtual record type virtual-R and replace R in each of the n – 1 trees with a record of type virtual-R. Database System Concepts B.37 ©Silberschatz, Korth and Sudarshan
  • 38. Virtual Records (Cont.) Eliminate data replication in the diagram shown on page B.11; create virtual-customer and virtual-account. Replace account with virtual-account in the first tree, and replace customer with virtual-customer in the second tree. Add a dashed line from virtual-customer to customer, and from virtual-account to account, to specify the association between a virtual record and its corresponding physical record. Database System Concepts B.38 ©Silberschatz, Korth and Sudarshan
  • 39. Sample Database Database System Concepts B.39 ©Silberschatz, Korth and Sudarshan
  • 40. Mapping Hierarchies to Files Implementations of hierarchical databases do not use parent-to-child pointers, since these would require the use of variable-length records. Can use leftmost-child and next-sibling pointers which allow each record to contain exactly two pointers.  The leftmost-child pointer points to one child.  The next-sibling pointer points to another child of the same parent. Database System Concepts B.40 ©Silberschatz, Korth and Sudarshan
  • 41. Mapping Hierarchies to Files (Cont.) Implementation with parent-child pointers. Implementation with leftmost child and next-sibling pointers. Database System Concepts B.41 ©Silberschatz, Korth and Sudarshan
  • 42. Mapping Hierarchies to Files (Cont.) In general, the final child of a parent has no next sibling; rather than setting the next-sibling filed to null, place a pointer (or preorder thread) that points to the next record in preorder. Using preorder threads allows us to process a tree instance in preorder simply by following pointers. Database System Concepts B.42 ©Silberschatz, Korth and Sudarshan
  • 43. Mapping Hierarchies to Files (Cont.) May add a third child-to-parent pointer which facilitates the processing of queries that give a value for a child record and request a value from the corresponding parent record. the parent-child relationship within a hierarchy is analogous to the owner-member relationship within a DBTG set.  A one-to-many relationship is being represented.  Store together the members and the owners of a set occurrence.  Store physically close on disk the child records and their parent.  Such storage allows a sequence of get first, get next, and get next within parent statements to e executed with a minimal number of block accesses. Database System Concepts B.43 ©Silberschatz, Korth and Sudarshan
  • 44. The IMS Database System IBM Information Management System — first developed in the late 1960s; historically among the largest databases. Issue queries through embedded calls which are part of the IMS database language DL/I. Allows the database designer a broad number of options in the data-definition language.  Designer defines a physically hierarchy as the database schema.  Can define several subschemas (or view) by constructing a logical hierarchy from the record types constituting the schema.  Options such as block sizes, special pointer fields, and so on, allow the database administrator to tune the system. Database System Concepts B.44 ©Silberschatz, Korth and Sudarshan
  • 45. Record Access Schemes Hierarchical sequential-access method (HSAM) — used for physically sequential files (such as tape files). Records are stored physically in preorder. Hierarchical indexed-sequential-access method (HISAM) — an index-sequential organization at the root level of the hierarchy. Hierarchical indexed-direct-access method (HIDAM) — index organization at the root level with pointers to child records. Hierarchical direct-access method (HDAM) — similar to HIDAM, but with hashed access at the root level. Database System Concepts B.45 ©Silberschatz, Korth and Sudarshan
  • 46. IMS Concurrency Control Early versions handled concurrency control by permitting only one update application program to run at a time. Read-only applications could run concurrent with updates. Later versions included a program-isolation feature  Allowed for improved concurrency control  Offered more sophisticated transaction-recovery techniques (such as logging); important to online transactions. The need for high-performance transaction processing led to the introduction of IMS Fast Path. Database System Concepts B.46 ©Silberschatz, Korth and Sudarshan
  • 47. IMS Fast Path Uses an alternative physical data organization that allows the most active parts of the database to reside in main memory. Instead of updates to disk being forced at the end of a transaction, update is deferred until a checkpoint or synchronization point. In the event of a crash, the recovery subsystem must redo all committed transactions whose updates were not forced to disk. Allows for extremely high rates of transaction throughput. Forerunner of main-memory database systems. Database System Concepts B.47 ©Silberschatz, Korth and Sudarshan
  • 48. Sample Database Database System Concepts B.48 ©Silberschatz, Korth and Sudarshan
  • 49. Sample Database Corresponding to Diagram of Figure B.4 Database System Concepts B.49 ©Silberschatz, Korth and Sudarshan
  • 50. Sample Database Corresponding To Diagram of Figure B.8b Database System Concepts B.50 ©Silberschatz, Korth and Sudarshan
  • 51. Tree-Structure Diagram With Many-To-Many Relationships Database System Concepts B.51 ©Silberschatz, Korth and Sudarshan
  • 52. E-R Diagram and Its Corresponding Tree-Structure Diagrams Database System Concepts B.52 ©Silberschatz, Korth and Sudarshan
  • 53. Sample Database Corresponding To Diagram of Figure B.12b Database System Concepts B.53 ©Silberschatz, Korth and Sudarshan
  • 54. New Database Tree Database System Concepts B.54 ©Silberschatz, Korth and Sudarshan
  • 55. New Database Tree Database System Concepts B.55 ©Silberschatz, Korth and Sudarshan
  • 56. Class-enrollment E-R Diagram Database System Concepts B.56 ©Silberschatz, Korth and Sudarshan
  • 57. Parent–Child E-R Diagram Database System Concepts B.57 ©Silberschatz, Korth and Sudarshan
  • 58. Car-insurance E-R Diagram Database System Concepts B.58 ©Silberschatz, Korth and Sudarshan