This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes how to retrieve data from relational database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to retrieve data from relational database" Watch "how to retrieve data from relational database" New topic
Author

how to retrieve data from relational database

Gopu Akraju
Ranch Hand

Joined: Jan 13, 2008
Posts: 242
Hi,

I have not done database design before and as a first step I designed a flat database schema in a table called test which contains the following columns and I am also enclosing example data

----------------------------------------------------------------|
ID name item1 cost1 item2 cost2 item3 cost3 |
----------------------------------------------------------------|
1 ivy bash1 30 bash1 10 bash3 20
2 joe bash2 18 bash1 8 bash2 20
3 ila bash3 45 bash3 2 bash2 50

And the list goes on.

Basically bash1 represents a directory by name /usr/fig/bash1
bash2 represents a directory by name /usr/fig/bash2
bash3 represents a directory by name /usr/fig/bash3


Since all the information are ina flat scema right now, I have hard coded the directory as below:



But now I want to change the design to relational database. Hence want to have table as follows which contains the bash info as below:

id bashNo directory
-------------------------------
1 bash1 /usr/fig/bash1
2 bash2 /usr/fig/bash2
3 bash3 /usr/fig/bash3


I am bit confused after this. How do I retrive the information from a relational databaase.

Because if I see bash1 in the 1st table I want to fetch the directory path from the 2nd table. How do I modify my tables and hence my designing is perfect relational database.

Thanks in advance.

[ July 28, 2008: Message edited by: Gopu Akraju ]
[ July 28, 2008: Message edited by: Gopu Akraju ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

That's called a "join". I won't go into more detail than that, because learning database design from nothing by asking questions on a forum isn't the best way to learn things. Hopefully it gives you the right word to look up in the index of a book, though.
 
 
subject: how to retrieve data from relational database
 
Similar Threads
String from JTextField
URLyBird data file and DBMain interface
Size of JLabel
JSF datatable doubt
JSF backingbean value is null always.