How to model government organization hierarchies so that the list can expand and compress

Friedrich Rentsch anthra.norell at bluewin.ch
Fri Aug 14 17:25:20 EDT 2015



On 08/13/2015 09:10 PM, Alex Glaros wrote:
> It's like the desktop folder/directory model where you can create unlimited folders and put folders within other folders. Instead of folders, I want to use government organizations.
>
> Example: Let user create agency names: Air Force, Marines, Navy, Army. Then let them create an umbrella collection called "Pentagon", and let users drag Air Force, Marines, Navy, etc. into the umbrella collection.
>
> User may wish to add smaller sub-sets of Army, such as "Army Jeep Repair Services"
>
> User may also want to add a new collection "Office of the President" and put OMB and Pentagon under that as equals.
>
> What would the data model look like for this?  If I have a field: next_higher_level_parent that lets children records keep track of parent record, it's hard for me to imagine anything but an inefficient bubble sort to produce a hierarchical organizational list. Am using Postgres, not graph database.
>
> I'm hoping someone else has worked on this problem, probably not with government agency names, but perhaps the same principle with other objects.
>
> Thanks!
>
> Alex Glaros

After struggling for years with a tree-like estate management system 
(onwer at the top, next level: real estate, banks, art collection, etc., 
third level: real estate units, bank accounts, etc. fourth level: 
investment positions, currency accounts, etc)--it recently occurred to 
me that I had such a system all along: the file system. The last folder 
at the bottom end of each branch names its contents (AAPL or USD or 
Lamborghini, etc) the contents is a csv file recording an in and out, 
revenue, expense history (date, quantity, paid or received, memo, . . 
.). Any documentation on the respective value item may also be stored in 
the same folder, easy to find without requiring cross referencing.

Managing the data is not a awkward as one might fear. A bash wizard 
could probably do it quite efficiently with bash scripts. Bash dummies, 
like me, are more comfortable with python. Moving, say, a portfolio from 
one bank to another is a matter of "mv i/banks/abc/account-123 
i/banks/xyz" (system call). With the tabular data base system (MySQL) I 
have, simple operations like this one are quite awkward.

Well, you might laugh. Or others might. If your task is a commercial 
order, then this approach will hardly do. Anyway, I thought I'd toss it 
up. If it won't help it won't hurt.

Frederic










More information about the Python-list mailing list