473,802 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Building a hierarchy from flat data?

My input data consists of a list of parent-child relationships. One
item in this list can be modelled like this:

+---------+
| Item |
+---------+
| Parent |
| Child |
+---------+

The Parent and Child properties are unique strings. One item's child
may be another item's parent and so on, so all together the list of
Item objects can be transformed into a hiearchy of Item objects. The
question is HOW.

I imagine a collection class called Item, with the List containing
other Item objects (since one parent can have many children).

I didn't start coding yet, becuase I have no idea how to approach the
problem. Hope someone can help me outlining the procedure.

Gus

Nov 16 '05 #1
1 3133
Hi,

If you want to create structure that support hierarchical
relationship then your "Item" should be more like:

+----------+
| Item |
+----------+
| Id |
| ParentId |
+----------+

You can not point to child item, because in common hierarchy
one parent can have zero or more children, and a child can have only
single parent (or none).

If you want to support more complicated hierarchy (e.g. human's
hierarchy) then you should extend the Item's structure or provide
additional structure:

+----------+
| ItemLink |
+----------+
| ParentId |
| ChildId |
+----------+

Regards

Marcin
My input data consists of a list of parent-child relationships. One
item in this list can be modelled like this:

+---------+
| Item |
+---------+
| Parent |
| Child |
+---------+

The Parent and Child properties are unique strings. One item's child
may be another item's parent and so on, so all together the list of
Item objects can be transformed into a hiearchy of Item objects. The
question is HOW.

I imagine a collection class called Item, with the List containing
other Item objects (since one parent can have many children).

I didn't start coding yet, becuase I have no idea how to approach the
problem. Hope someone can help me outlining the procedure.

Gus

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3484
by: vcardillo | last post by:
Hello all, Okay, I am having some troubles. What I am doing here is dealing with an employee hierarchy that is stored in an array. It looks like this: $employees = array( "user_id" => array( "name", "title", "reports to user id", "start date in the format: mm/dd/yyyy" ) ); How can I display this hierarchy in simple nested <li> tags in the most
7
5402
by: gsoftwares | last post by:
Hi XML Guru, I need to transform flat xml to Hierarchy xml. Can some one help me get started or have a same code with them my flat xml: <rowset> <row>
13
3429
by: raykyoto | last post by:
Hi all, I'm sure this is a popular question that comes up every few months here. Indeed, I've looked at some of the past postings, but I would like to ask things differently. Basically, I'm using a flat file to storing data. I have to do this because mySQL is not installed on my web server, and I am not the root user. The amount of data is so small, that it isn't worth a full-blown database anyway. However, while the data is...
1
2190
by: Tim Fierro | last post by:
Hello, I have had many years using flat file databases (File Express from way back) but am now at a company where a relational database is needed and would carry us into the future. Since I know some basics on databases, have VB Pro programming experience over the years, and I know most of what we need to carry as far as data; I have decided to create a database for our needs instead of finding an off the shelf program that may not be...
0
1574
by: Irfan Akram | last post by:
Hello People, I would appreciate your responses on this. I am writing an asp.net web-application involving C#. I am actually building a test hierarchy at the moment, which involves producing dynamic controls, depending on user response. To be more precise, I prompt the user for the number of questions, that should be in the test. He types in a number, say 10. Then I need to ask him
4
1726
by: Ben | last post by:
So, at my place of employment, we use a national standard to transmit data between certain applications. This standard consists of a fixed width, flat file 4500-some-odd chars wide that contain 375-some-odd columns (Not delimited). This standard is not changing anytime soon, so I attempting to write a library of some sort to read and write these files within our SQL databases (which use 160 of those columns, but completely ignore the...
2
7980
by: Dip | last post by:
Hi Expert, How do I flatten a Parent Child hierarchy to regular flat data: please provide some SQL code: I have now: Task_ID, Parent_Task_ID, Task_Name Level 1 1 Project Management 1 2 1 Costing 2 3 1 Estimating 2 4 2 Task1 3
9
2197
by: FFMG | last post by:
In my site I have a config table, (MySQL), with about 30 entries; the data is loaded on every single page load. This is not the only call to the db, (we do a total of about 8 calls to the db). As with many configurations settings, once the options are set the values will not change much. So I thought it would be a good idea to move the data to a flat file. I have written a small wrapper class to first look for the file, if it exists...
15
5281
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to show - text boxes, input boxes, buttons, hyperlinks ie the usual. The data is not obtained directly from a database.
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10536
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10285
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10063
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.