Managing Hierarchical Data in a Relational Database.

Slides:



Advertisements
Similar presentations
COSC2007 Data Structures II Chapter 10 Trees I. 2 Topics Terminology.
Advertisements

The Hierarchical Model
Chapter 12 File Processing and Data Management Concepts
Unleashing the Power of Kinetic Bridging Ben Christenson Kinetic Data.
Introduction to Trees Chapter 6 Objectives
Data Modelling. EAR model This modelling language allows a very small vocabulary: Just as English has nouns, verbs, adjectives, pronouns.., EAR models.
B + -Trees (Part 2) Lecture 21 COMP171 Fall 2006.
1 abstract containers hierarchical (1 to many) graph (many to many) first ith last sequence/linear (1 to 1) set.
XML –Query Languages, Extracting from Relational Databases ADVANCED DATABASES Khawaja Mohiuddin Assistant Professor Department of Computer Sciences Bahria.
WHAT IS A DATABASE ? a collection of data organized to help easy retrieval & usage.
Database Models. Flat File The most basic way to organize data is as a flat file. You can think of this as a single table with a large number of records.
Entity Relationships. Relationships Relationships exist between entities The type of relationship is entirely dependent on the business rules The business.
Binary Trees Chapter 6.
Table & Query Design for Hierarchical Data without CONNECT-BY -- A Path Code Approach Charles Yu Database Architect Elance Inc. Elance Inc.
Database Design and Introduction to SQL
Chapter 3 Data Models.
MCTS Guide to Configuring Microsoft Windows Server 2008 Active Directory Chapter 3: Introducing Active Directory.
GIS Concepts ‣ What is a table? What is a table? ‣ Queries on tables Queries on tables ‣ Joining and relating tables Joining and relating tables ‣ Summary.
COSC2007 Data Structures II
By: M.Nadeem Akhtar1 The Data Base Management System (DBMS) Ch # 09.
Concepts of Database Management, Fifth Edition Chapter 1: Introduction to Database Management.
Trees. Introduction to Trees Trees are very common in computer science They come in different forms They are used as data representation in many applications.
6 Chapter Databases and Information Management. File Organization Terms and Concepts Bit: Smallest unit of data; binary digit (0,1) Byte: Group of bits.
12-CRS-0106 REVISED 8 FEB 2013 CSG2A3 ALGORITMA dan STRUKTUR DATA.
Created on 29/10/2008yahaya.wordpress.com1 Trees Another common nonlinear data structure is the tree. We have already seen an example of a tree when we.
Database Design Using Entity-Relationship Models Transformation of Entity-Relationship Models into Relational Database Design Trees, Networks, and Bills.
Chapter 12 View Design and Integration. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for view design.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Scripting with the DOM Ellen Pearlman Eileen Mullin Programming the Web.
Database A database is a collection of data organized to meet users’ needs. In this section: Database Structure Database Tools Industrial Databases Concepts.
1 Database Concepts 2 Definition of a Database An organized Collection Of related records.
Entity-Relationship (ER) Modelling ER modelling - Identify entities - Identify relationships - Construct ER diagram - Collect attributes for entities &
 2001 Prentice Hall Business Publishing, Accounting Information Systems, 8/E, Bodnar/Hopwood A field may be a single character or number, or it.
Trees CS 105. L9: Trees Slide 2 Definition The Tree Data Structure stores objects (nodes) hierarchically nodes have parent-child relationships operations.
Data Structures TREES.
Hierarchical Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
Relational Theory and Design
ADAPTING YOUR ETL SOLUTION TO USE SSIS 2012 Presentation by Devin Knight
Master Data Management & Microsoft Master Data Services Presented By: Jeff Prom Data Architect MCTS - Business Intelligence (2008), Admin (2008), Developer.
Chapter 13.3: Databases Invitation to Computer Science, Java Version, Second Edition.
Data Structures Lakshmish Ramaswamy. Tree Hierarchical data structure Several real-world systems have hierarchical concepts –Physical and biological systems.
Working with XML. Markup Languages Text-based languages based on SGML Text-based languages based on SGML SGML = Standard Generalized Markup Language SGML.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Chapter 7 Storing Organizational Information - Databases.
This Lecture Intro to Tree ADT Terminologies Tree Types Tree Traversals Binary Search Tree Expression Trees.
Hierarchical Retrieval Fresher Learning Program December, 2011.
Before the Relational Model COMP3211 Advanced Databases Dr Nicholas Gibbins –
Overview of Security Investments in SQL Server 2016 and Azure SQL Database Jamey Johnston 1/15/2016Security Investments in SQL Server 2016 and Azure SQL.
DBS201: Data Modeling. Agenda Data Modeling Types of Models Entity Relationship Model.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Chapter 7 Storing Organizational Information - Databases.
Hyperion Smart View Training Session April 25, 2017
FileTables Sam Nasr, MCAD, MCTS, MVP NIS Technologies
Assignment #1 due Wed. Feb. 15, (15)
Place a hold on a checked out item
Querying Hierarchical Data
FileTables By Sam Nasr, MCAD, MCT, MCTS NIS October 6, 2012
Using FileTables Sam Nasr, MCSA, MCT, MVP NIS Technologies
Using FileTables Sam Nasr, MCAD, MCTS, MVP NIS Technologies
B+ Tree.
Customize your Sports Team Uniforms custom-uniforms/
Trees and Binary Trees.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
Database.
Hierarchies SQL Server 2012 Tyler Graham Senior Program Manager
Place a hold on a checked out item
Databases and Structured Files: What is a database?
MANAGING DATA RESOURCES
Enterprise RLS in SQL Server in Power BI
Lecture 36 Section 12.2 Mon, Apr 23, 2007
Tree and its terminologies
Using FileTables Sam Nasr, MCSA NIS Technologies August 3, 2019.
Legacy Databases.
Presentation transcript:

Managing Hierarchical Data in a Relational Database

Who’s the old guy?  Robert Hatton  Data Architect at ARI Network Services  Building databases since the ‘70s  Author of ‘The Business Intelligence Team Handbook’  Feel free to contact me at

What is ‘Hierarchical Data’  Data elements related by Parent/Child and sibling relationships  Chart of Accounts  Bills of Material  Organization Charts  Catalogs  Outline style  Hierarchy is separate from data it organizes  Your reporting structure only helps folks navigate to your Employee record

The nature of hierarchies  Organized in levels  Number of levels  Width of levels  Single Parent vs. Multiple Parent  Different ID requirements

Hierarchy Terminology  Node  An individual member of a hierarchy  ROOT  The parent or ancestor of all other nodes  The Root has no parent  Leaf Node  A node without children  It’s a place to hang all of the data folks are interested in  Parent / Child / Sibling  They mean what they usually do

Node identification  String (or binary)  A single number won’t do!  Every level of hierarchy must be represented  Location in level has to be there too  Examples:  ‘/54/432/64/23/45’  ‘sporting goods, bicycles, mountain bikes, fat tire bikes, Fat Albert’

Example  Sporting Goods  1 Court sports  1.1 Tennis  1.2 Basketball  2 Field sports  2.1 Football  2.2 Baseball  3 Outdoor sports  3.1 Camping Gear  3.2 Bicycles  Road Bikes  Mountain Bikes  4 Drinking sports  4.1 Vocal Games  4.2 Skill Games  4.3 Card Games

Single Parent VS Multi-Parent Hierarchies  Know your data!  How you design your solution depends on data  Single Parent  If there is (or could be) a single node that could be in more than one branch, you can’t use this model!  Single parent model can house relationship key with the nodes.  Example: Chart of Accounts  Multi Parent  Relationship table has to be kept separate from nodes.  Example: Bills of Material.

 Bicycles  Bicycles.Felt  Bicycles.Felt.Mountain  Bicycles.Felt.Mountain.All Mountain  Bicycles.Felt.Mountain.All Mountain.Compulsion 10  Bicycles.Felt.Mountain.All Mountain.Compulsion 30  Bicycles.Felt.Mountain.Trail 27.5  Bicycles.Felt.Mountain.Trail 27.5.Decree 1  Bicycles.Felt.Mountain.Trail 27.5.Decree FRD  Bicycles.Felt.Road  Bicycles.Felt.Road.Aero  Bicycles.Felt.Road.Aero.AR FRD  Bicycles.Felt.Road.Aero.AR1 W  Bicycles.Felt.Road.Aero.AR2  Bicycles.Felt.Road.Race  Bicycles.LiteSpeed  Bicycles.LiteSpeed.Carbon  Bicycles.LiteSpeed.Titanium  Bicycles.LiteSpeed.Titanium.Mountain  Bicycles.LiteSpeed.Titanium.Mountain.All Mountain  Bicycles.LiteSpeed.Titanium.Mountain.All Mountain.Compulsion 10  Bicycles.LiteSpeed.Titanium.Mountain.All Mountain.Compulsion 30  Bicycles.LiteSpeed.Titanium.Mountain.Trail 27.5  Bicycles.LiteSpeed.Titanium.Mountain.Trail 27.5.Decree 1  Bicycles.LiteSpeed.Titanium.Mountain.Trail 27.5.Decree FRD Sample Hierarchy

Microsoft’s solution: HierarchyID data type  The hierarchyID data type is a variable length, system data type.  Example: /1/1/ or /1/2/ or /1/1.5  Root is represented by /  Supports ordering of siblings.  Intended to be housed in table holding hierarchy nodes.  Examples only show support for single parent hierarchies.  Supported in SQL Server 2008 and newer.

HierarchyID methods  GetAncestor  GetDescendant  GetLevel  GetRoot  IsDescendantOf  Parse  Read  GetReparentedValue  ToString  Write

Relationship table solution  Use a dedicated table to map relationships  Example  relationshipID  parentID  itemID  Key concept!  The parentID doesn’t point to the table housing node data.  It uses relationshipID from the mapping table  The itemID does point to the table housing node data.

Attribute tables  Item Attributes  Example fields  Item Description  Weight  QuantityOnHand  Price  Alternate tables  Employees  BillsOfMaterial  ChartOfAccounts  Relationship Attributes  Used by  Obsolete

Sample Schema

Demos  Children by Name  Children by ID  Ancestors by Name  Ancestors by ID  populateItemRelationshipPath

Thank you! 