I agree with you completely, seems that the person who designed the database has no database experience....
In Oracle I would do:
create table organization(
orgid number not null primary key,
ordparent number,
orgname varchar2(40) not null);
alter table organization add constraint fk_parent foriegn key (orgpare
+nt) references organization(orgid);
-- start inserts for organizations
insert into organization ....etc.
-- end inserts for organizations
create table orglevels(
levelid number not null,
levelname varchar2(20) not null);
insert into orglevels values (1,'Sector');
insert into orglevels values (2,'Department');
insert into orglevels values (3,'Division');
You would probably get lots of data by running a query like this one (untested):
select orgid,orgname,orgparent,level,l.levelname from organization o s
+tart with orgparent is null connect by prior orgid=orgparent
left join orglevels l on l.levelid=level
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.