pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedjtree and sql queries
2+ messages / 2 participants
[nested] [flat]
* jtree and sql queries
@ 2006-11-03 17:19 Luca Ferrari <fluca1978@infinito.it>
2006-11-03 23:30 ` Re: jtree and sql queries Roland Walter <roland.walter.rwa@gmx.net>
0 siblings, 1 reply; 2+ messages in thread
From: Luca Ferrari @ 2006-11-03 17:19 UTC (permalink / raw)
To: pgsql-jdbc
Hi all,
I'm just wondering if someone has already bound a JTree to a set of sql
queries. I explain it better: I've got a person table, a skill table and a
role table. Each person can play one or more role, and can have one or more
skill. I'd like to show to the user the result of the query as a tree:
person
+- roles
+- role1
+- role2
+skills
+- skill1
+- skill2
....
As you can imagine, the difficult is to bind each node tree to its table and
to a specific query. For now I've bound each node to its table and its key
value (with bound I mean that from the node I can know which table and key I
must use to find the row in the database), but my difficult now is to refresh
the tree each time the user makes a changes to the database. Unlike the use
of simple tables, building the tree is more complex, because more queries
must be performed, so I was wondering if someone out there has already
something similar and can suggest me.
Thanks,
Luca
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: jtree and sql queries
2006-11-03 17:19 jtree and sql queries Luca Ferrari <fluca1978@infinito.it>
@ 2006-11-03 23:30 ` Roland Walter <roland.walter.rwa@gmx.net>
0 siblings, 0 replies; 2+ messages in thread
From: Roland Walter @ 2006-11-03 23:30 UTC (permalink / raw)
To: Luca Ferrari <fluca1978@infinito.it>; +Cc: pgsql-jdbc
Luca Ferrari schrieb:
> Hi all,
> I'm just wondering if someone has already bound a JTree to a set of sql
> queries. I explain it better: I've got a person table, a skill table and a
> role table. Each person can play one or more role, and can have one or more
> skill. I'd like to show to the user the result of the query as a tree:
> person
> +- roles
> +- role1
> +- role2
> +skills
> +- skill1
> +- skill2
> ....
>
> As you can imagine, the difficult is to bind each node tree to its table and
> to a specific query. For now I've bound each node to its table and its key
> value (with bound I mean that from the node I can know which table and key I
> must use to find the row in the database), but my difficult now is to refresh
> the tree each time the user makes a changes to the database. Unlike the use
> of simple tables, building the tree is more complex, because more queries
> must be performed, so I was wondering if someone out there has already
> something similar and can suggest me.
>
> Thanks,
> Luca
I had once similiar problem. I used one statement with left outer joins
that queried all tables connected with the nodes. The values of the row
were inserted into the tree. First checked if the first value exists on
his level, if it did not I created a new node, elsewhile I checked all
subnodes of that node for the second value. The algorithm was recursive.
If the database changed I built the whole tree again. Not very
performant but was sufficient for results with about a few thousand rows.
I would only build the tree once with one query. All changes of the user
on the tree might create insert or update statements but the tree would
not be build again but only modified according to the changes. But this
works only if there are no concurrent changes on the tables. You should
consider putting the modification into a transaction then.
Regards,
Roland.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-11-03 23:30 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-03 17:19 jtree and sql queries Luca Ferrari <fluca1978@infinito.it>
2006-11-03 23:30 ` Roland Walter <roland.walter.rwa@gmx.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox