Presentation is loading. Please wait.

Presentation is loading. Please wait.

THE HIERARCHICAL DATA MODEL SECTION 9 Fundamentals.

Similar presentations


Presentation on theme: "THE HIERARCHICAL DATA MODEL SECTION 9 Fundamentals."— Presentation transcript:

1 THE HIERARCHICAL DATA MODEL SECTION 9 Fundamentals

2 Introduction Relational model –Grounded in mathematics Network model –Evolved from effort to establish standards Hierarchical –Evolved?

3 Some Hierarchical Systems Most widely used Other Hierarchical Systems IMS

4 Developed in early 1960s The reason? Still remains an actively used DB

5 Basic Concepts Special case of the network model Parent Child

6 Tree Hierarchical data model Segment types Parent-child relationship type

7 A conceptual model RETIREMENT PLAN EMPLOYEE HAS- EMPLOYEE PROVIDED- FOR 1 MM 1 DEPARTMENT

8 A network data model DEPARTMENT RETIREMENT PLAN EMPLOYEE DEPARTMENT/ EMPLOYEE SET RETIREMNT PLAN/ EMPLOYEE SET

9 A hierarchical data model DEPARTMENT RETIREMENT PLAN EMPLOYEE DEPARTMENT/ EMPLOYEE PCR RETIREMNT PLAN/ EMPLOYEE PCR EMPLOYEE

10 Tree Structure Conventions 2.Every segment a child 3.A parent can have many children 4.A child can only have one parent 1.Root segment

11 6.Ancestors and dependent segments 7.Root of a sub-tree 5.A leaf segment

12 Hierarchical arrangement of segment types DEPTNAMEMANAGER EMPNAMEYRS-SVC PROJNAMEDIVISIONSKILLCODESKILLNAME DEPARTMENT EMPLOYEE SKILLASSIGNEDTO Segment type

13 Hierarchical occurrence tree AccountingBlackMarketingSmith DEPTNAMEMANAGER EngineeringCook Bond7 EMPNAMEYRS-SVC DEPARTMENT EMPLOYEE Mills12Hill5Carter3Blake6Case7West6 Programmer2 SKILLCODE SKILL SKILLNAME Analyst5Proj.A3Cost Acct.3Engineer5Proj.B6 PROJNAMEDIV ASSIGNEDTO

14 Preorder Traversal Method 2.At any point, after recording a segment, record the leftmost child segment of the segment just recorded. If the segment has no child segment, move back up the tree one level and record the leftmost unrecorded child segment of the segment at that level. Continue until all segments are accounted for. 1.Begin at the root of the tree and record the root segment in a file

15 A BCD FEGHIJK D EEE SS SA AA A Segment type indicator Department Segment Type Employee Segment Type Skill and AssignedTo Segment Type Level 1 Level 2 Level 3 Illustration of Preorder Traversal

16 The following file will be generated IterationSegmentSegment-Type Indicator 1AD 2BE 3ES 4FA 5GA 6CE 7HS 8IA 9DE 10JS 11KA

17 The Models Relationship to Conceptual Modeling Transforming a conceptual model to a hierarchical data structure One - Many Relationships

18 Transforming One-Many Relationships Very simple DEPARTMENT EMPLOYEE HAS- EMPLOYEE 1N DEPTNAMELOCATIONMANAGEREMPNAMEADDRESSYRS-SVC DEPTNAMELOCATIONMANAGER DEPARTMENT EMPNAMEADDRESSYRS-SVC EMPLOYEE

19 Redundancy problems DEPARTMENT RETIREMENT PLAN HAS- EMPLOYEE 1 N DEPTNAMELOCATIONMANAGERTYPE ENROLL-DATE AMOUNT PROVIDED- FOR EMPLOYEE YRS-SVC ADDRESSEMPNAME 1 N What is the problem?

20 DEPTNAMELOCATIONMANAGER DEPARTMENT EMPNAMEADDRESSYRS-SVC EMPLOYEE TYPE ENROLL- DATE AMOUNT RETIREMENT-PLAN EMPNAMEADDRESSYRS-SVC EMPLOYEE

21 1.For each entity set E in a conceptual model, create a segment type S in the hierarchical model. All attributes of E are represented as fields of S. 2.For one-many relationships between two entity sets, create corresponding tree structure diagrams, making each entity a segment and making the one- many relationship a parent-child relationship. The segment on the “many” side becomes the child, and the segment on the one side becomes the parent. The following rules:

22 Transforming Many-Many Relationships A more complex situation PRODUCT SUPPLIER IS- SUPPLIED- BY N IDDESCRIPTIONPRICE NAME LOCATION M

23 IDDESCRIPTIONPRICE PRODUCT NAMELOCATION MANUFACTURER IDDESCRIPTIONPRICE PRODUCT NAMELOCATION MANUFACTURER 3.For entity sets, E 1 and E 2, that have a many-many binary relationship, and from which segments S 1 and S 2 have been identified, construct two different one- many PCRs: S 1 to S 2, and S 2 to S 1.

24 Many-Many Relationship with an Attribute PRODUCT SUPPLIER IS- SUPPLIED- BY N IDDESCRIPTIONPRICE NAME LOCATION M QUANTITY

25 4.If a binary many-many relationship has attribute data, create a new intersection segment I, which contains that data. IDDESCRIPTIONPRICE PRODUCT NAMELOCATION MANUFACTURER QUANTITY IDDESCRIPTIONPRICE PRODUCT NAMELOCATION MANUFACTURER QUANTITY

26 The IMS Architecture Hierarchical data model has no standard Must be hierarchically oriented Limit on segment types

27 Database Description (DBD) Program Specification Block (PSB) Program Communication Block DL/1

28 Defining the Physical Database – The DBD An example – four segment types –DEPARTMENT –EMPLOYEE –SKILL –ASSIGNEDTO The DBD is analogous to the network schema

29 1DBDNAME = DEPTPERS, ACCESS = HISAM 2SEGMNAME = DEPARTMENT, PARENT = 0, BYTES = 20 3FIELDNAME = (DEPTNAME,SEQ,U), BYTES = 10, START = 1, TYPE = C 4FIELDNAME = MANAGER, BYTES = 10, START = 11, TYPE = C 5SEGMNAME = EMPLOYEE, PARENT = DEPARTMENT, BYTES = 22 6FIELDNAME = (EMPNAME,SEQ), BYTES = 20, START = 1, TYPE = C 7FIELDNAME = YRS-SVC, BYTES = 2, START = 21, TYPE = P 8SEGMNAME = SKILL, PARENT = EMPLOYEE, BYTES = 17 9FIELDNAME = (SKILLCODE,SEQ), BYTES = 2, START = 1, TYPE = P 10FIELDNAME = SKILLNAME, BYTES = 15, START = 3, TYPE = C 11SEGMNAME = ASSIGNEDTO, PARENT = EMPLOYEE, BYTES = 4 12FIELDNAME = (PROJNI,SEQ), BYTES = 2, START = 1, TYPE = P 13FIELD NAME = DIVISION, BYTES = 2, START = 3, TYPE = C 14DBGEN

30 Defining the Logical Database – The PSB The PCB Sensitive segments Analogous to the network subschema

31 PROCOPT G=GET I=INSERT R=REPLACE D=DELETE A=ALL 1PCBTYPE = DB, DBNAME = DEPTERS, PROCOPT = A, KEYLEN = 18 2SENSEGNAME = DEPARTMENT, PARENT = 0 3SENSEG NAME = DEPTNAME, START = 1 4SENSEG NAME = EMPLOYEE, PARENT = DEPARTMENT 5SENFLDNAME = EMPNAME, START = 1

32 IMS Access Methods HISAM HDAM HIDAM HSAM

33 DEPTNAME Smith MANAGER Marketing Bond EMPNAME 7 YRS-SVC Hill EMPNAME 5 YRS-SVC Programmer2 SKILLCODESKILLNAME Systems Analyst 5 SKILLCODESKILLNAME Sales10 SKILLCODESKILLNAME Tree Occurrence Example

34 Hierarchical Pointers DEPTNAME Smith MANAGER Marketing * Bond EMPNAME 7 YRS-SVC * Programmer2 SKILLCODESKILLNAME * Systems Analyst 5 * Hill5 * Sales10 o

35 Child and Twin Pointers DEPTNAME Smith MANAGER Marketing ** (Twin Pointer) YRS-SVC Bond EMPNAME 7 ** (Child Pointer) SKILLNAME Programmer2 SKILLCODE *o Hill5 o* Systems Analyst 5 oo Sales10 oo

36 The IMS Data Manipulation Language Program Work Area –Segment templates –Currency templates The language?

37 GET UNIQUE (GU) GET NEXT (GN) GET NEXT WITHIN PARENT (GNP) GHU, GHN, GHNP INSERT (ISRT) REPLACE (REPL) DELETE (DLET) Retrieve the first segment that satisfies a given condition Retrieve the next segment Retrieves the next segment, but only within the current parent Lock the database for GU, GN, GNP Add a new segment to the database Modify the value of a segment field Delete a segment DL/1 Data Language 1 Commonly used commands Command

38 1.A Simple Segment Retrieval GU DEPARTMENT (DEPTNAME = ‘Marketing’) Get Unique (GU) 2.Retrieval of a Dependent Segment GU DEPARTMENT (DEPTNAME = ‘Marketing’) EMPLOYEE? (EMPNAME = ‘Steve Smith’)

39 3.Retrieval of dependent Segment When Parent is Not Known GU DEPARTMENT EMPLOYEE (EMPNAME = ‘Steve Smith’) 4.Retrieval of a Set of Segments GU DEPARTMENT (DEPTNAME = ‘Marketing’) EMPLOYEE GN EMPLOYEE Get Next (GN)

40 5.Retrieving All Segments of a Particular Type GU DEPARTMENT EMPLOYEE MORE GN EMPLOYEE GOTO MORE 6.Retrieving Segments for Just One Parent GU DEPARTMENT (DEPTNAME = ‘Marketing’) EMPLOYEE GNP EMPLOYEE Get Next Within Parent (GNP)

41 7.Retrieving Segments for Just One Parent GU DEPARTMENT (DEPTNAME = ‘Marketing’) EMPLOYEE (EMPNAME = ‘Steve Smith’) SKILLS NEXT GNP SKILLS GOTO NEXT GET HOLD UNIQUE GET HOLD NEXT GET HOLD NEXT WITHIN PARENT Get Hold

42 Replace (REPL) 8.Modifying Segment Field Values GHU DEPARTMENT (DEPTNAME = ‘Marketing’) EMPLOYEE (EMPNAME = ‘Irving Valtz’) MOVE 55000 TO SALARY REPL

43 Delete (DLET) 9.Deleting a Segment GHU DEPARTMENT (DEPTNAME = ‘Marketing’) EMPLOYEE (EMPNAME = ‘Irving Valtz’) DLET

44 Insert (INSRT) 10.Adding a Segment MOVE 598 TO SKILLCODE MOVE ‘ENGINEERING DRAFTSMAN’ TO SKILLNAME MOVE 0 TO YRS-EXPERIENCE INSRT DEPARTMENT (DEPTNAME = ‘Engineering’) EMPLOYEE (EMPNAME = ‘Bob Lee’) SKILL

45 1.Data representation Hierarchical Data Model Evaluation 2.Data manipulation language


Download ppt "THE HIERARCHICAL DATA MODEL SECTION 9 Fundamentals."

Similar presentations


Ads by Google