how to store the names in database in tree format

K

kashi

hi,

I am doing multilevel marketing project , in that i have to store in
tree format in data base like supose A as the root and B and C are
the childs .A
B C
 
M

Martin Gregorie

hi,

I am doing multilevel marketing project , in that i have to store in
tree format in data base like supose A as the root and B and C are the
childs .A
B C

This question belongs on a database group, not Java. Find one and ask
there. Hint - think BOM (Bill Of Materials).
 
R

RedGrittyBrick

kashi said:
hi,

I am doing multilevel marketing project , in that i have to store in
tree format in data base like supose A as the root and B and C are
the childs .A
B C

Martin's right but ...

ID NAME PARENT_ID

A Alex NULL
B Bob A
C Cath A
....
M Moe C
....
 
R

Roedy Green

I am doing multilevel marketing project , in that i have to store in
tree format in data base like supose A as the root and B and C are
the childs .A
B C

some ideas.

1. use a POD. See http://mindprod.com/jgloss/pod.html

2. Buy lots of ram, and persist your state when you shut down.

3. use an SQL database. Devise a Linnaeus-like system of naming like
that use for Latin names of plants and animals. Then store each record
with various level of name as separate fields3.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Here is a point of no return after which warming becomes unstoppable
and we are probably going to sail right through it.
It is the point at which anthropogenic (human-caused) warming triggers
huge releases of carbon dioxide from warming oceans, or similar releases
of both carbon dioxide and methane from melting permafrost, or both.
Most climate scientists think that point lies not far beyond 2°C (4°F) C hotter."
~ Gwynne Dyer
 
M

Marcelo Morales

hi,

  I am doing multilevel marketing project , in that i have to store in
tree format in data base like  supose A as the root and B and C are
the childs .A
                                             B  C

any JSR 170 implementation can store tree-like structures natively.
Try Jackrabbit.apache.org
 
L

Lew

That puts you in poor company.

One can make money selling to multi-level marketers without being one.

One can make money selling to musicians without being one. OK, not
full-time musicians, but wannabes with day jobs.

I worked on a couple of projects for startups seeking funding. They
needed prototype applications to show potential investors. We
demanded cash to develop the prototypes, having observed that these
would-be captains of industry were unlikely to gain the funding they
sought. (Doesn't anyone research how to write a business plan first?)

One should not assume that a person writing an app for multi-level
marketing organizations is themself snookered.
 
K

kashi

Martin's right but ...

ID   NAME   PARENT_ID

A    Alex   NULL
B    Bob    A
C    Cath   A
...
M    Moe    C
...

ya what u done its correct , how to do in DB send me the query's for
the above table . how to create and retrieving .
 
L

Lew

kashi said:
ya what u done its correct , how to do in DB send me the query's for
the above table . how to create and retrieving .

Have you studied SQL? There is a statement called "CREATE TABLE". It is
mostly the same, but not quite, between different versions of SQL.

Relational database management systems (RDMBS) have slightly different syntax
for their commands. They are similar, though. In each one you have to decide
the type of each column in a table. Without knowing the details of what
information you will store in the table, and therefore what each column will
contain and represent, it is impossible to answer your question.

What RDBMS do you plan to use? I prefer PostgreSQL myself. Many people like
MySQL, now owned by Sun. Apache Derby comes with Java now, in the JDK, where
it is called "Java DB". Oracle, IBM DB2 and Microsoft SQL Server all provide
free versions of their database products, with certain restrictions. And
those are just the free ones.

Using a common version of the syntax to create a table, I would implement
RedGrittyBrick's example:

ID NAME PARENT_ID
>
> A Alex NULL
> B Bob A
> C Cath A
> ...
> M Moe C
> ...

something like this:

CREATE TABLE person
(
id CHAR(1) PRIMARY KEY,
name VARCHAR(100) NOT NULL,
parent_id CHAR(1) FOREIGN KEY REFERENCES person (id)
);
CREATE INDEX ON person (name);
CREATE INDEX ON person (parent_id);

INSERT INTO person (id, name) VALUES ( 'A', 'Alex');
etc.

What queries you write depends on what you want to find out. One typical
query might be:

SELECT id, name FROM person WHERE parent_id IS NULL ORDER BY id;

The number of queries you could write, or would want to, even for this simple
and not very practical table is quite large.

In Java, you would use JDBC to encapsulate those queries, send them to the
database, and recover the results into your program. Look at the 'java.sql'
package, and types like 'PreparedStatement'.

You have a good deal of studying ahead of you. Besides the documentation for
the database system you use (such as Derby / Java DB), there are good
tutorials at the java.sun.com site. IBM DeveloperWorks is another good web site.

By the way, the word "you" is not spelled "u".
 
K

kashi

Have you studied SQL?  There is a statement called "CREATE TABLE".  It is
mostly the same, but not quite, between different versions of SQL.

Relational database management systems (RDMBS) have slightly different syntax
for their commands.  They are similar, though.  In each one you have to decide
the type of each column in a table.  Without knowing the details of what
information you will store in the table, and therefore what each column will
contain and represent, it is impossible to answer your question.

What RDBMS do you plan to use?  I prefer PostgreSQL myself.  Many people like
MySQL, now owned by Sun.  Apache Derby comes with Java now, in the JDK, where
it is called "Java DB".  Oracle, IBM DB2 and Microsoft SQL Server all provide
free versions of their database products, with certain restrictions.  And
those are just the free ones.

Using a common version of the syntax to create a table, I would implement
RedGrittyBrick's example:

ID   NAME   PARENT_ID
 >
 > A    Alex   NULL
 > B    Bob    A
 > C    Cath   A
 > ...
 > M    Moe    C
 > ...

something like this:

CREATE TABLE person
(
   id CHAR(1) PRIMARY KEY,
   name VARCHAR(100) NOT NULL,
   parent_id CHAR(1) FOREIGN KEY REFERENCES person (id)
);
CREATE INDEX ON person (name);
CREATE INDEX ON person (parent_id);

INSERT INTO person (id, name) VALUES ( 'A', 'Alex');
etc.

What queries you write depends on what you want to find out.  One typical
query might be:

SELECT id, name FROM person WHERE parent_id IS NULL ORDER BY id;

The number of queries you could write, or would want to, even for this simple
and not very practical table is quite large.

In Java, you would use JDBC to encapsulate those queries, send them to the
database, and recover the results into your program.  Look at the 'java..sql'
package, and types like 'PreparedStatement'.

You have a good deal of studying ahead of you.  Besides the documentation for
the database system you use (such as Derby / Java DB), there are good
tutorials at the java.sun.com site.  IBM DeveloperWorks is another good web site.

By the way, the word "you" is not spelled "u".

Thank you,
i trying out this.
 
A

Arne Vajhøj

Lew said:
One can make money selling to multi-level marketers without being one.

One can make money selling to musicians without being one. OK, not
full-time musicians, but wannabes with day jobs.

I worked on a couple of projects for startups seeking funding. They
needed prototype applications to show potential investors. We
demanded cash to develop the prototypes, having observed that these
would-be captains of industry were unlikely to gain the funding they
sought. (Doesn't anyone research how to write a business plan first?)

One should not assume that a person writing an app for multi-level
marketing organizations is themself snookered.

True.

But kashi did not claim so.

He only set that he was in poor company.

Which I read as "hanging out with the wrong crowd".

And MLM is the wrong crowd.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top