Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
QUE:- A world have multiple forest, forest has multiple trees, and trees has different type of leafs and multiple leafs. Design DB Schema of this structure in fetch the all leafs where forestID=10??
(Hint: use join)
Plzzz help me...
Posted

This has the familiar odour of homework - so no code, just suggestions.

What information do you need to store? Look at the objects you have, and list out what objects they are part of, or related to. Draw yourself a picture if you need to.

Then look at how you store all that, with the various relationships, without duplicating information at any time.

Then look at what Join does.

For example, a Tree may have many Leaf objects, but a particular Leaf (as in "this leaf here in my hand") will only be associated with a single Tree - it can't grow on two at the same time! So you will probably want to have a Tree table, and a Leaf table each row of which refers to a specific row in the Tree table.
 
Share this answer
 
Hint: Make your own homework... If we do it for you you won't learn anything from it, you might get a job and we'll have to work with people like you who can't solve their own problems.
Worst case scenario: If we answer your question now we might have to work with your code/database in 10 years...

I suggest reading your study books and make something out of it. If your design is flawed your teacher should be able to point out where and why it is faulted. Then you will have learned!
If you have a specific problem like "I have solution A and B, these are the pro's and cons to both what are you opinions?" I think you'll find people here more than willing to help.

Good luck!
 
Share this answer
 
Comments
ssoni346 28-Jan-12 5:27am    
Sorry sir
i was try my best but i have no good knowledge about database and i am fresher and i am looking for a job its a good interview question i want to check that the schema which is made by me for this query is right or wrong so that's why am asking..
Sander Rossel 28-Jan-12 5:38am    
You are looking for a job in a field you have no clue about? Seems odd...
Anyway, if you want some help here it's best to show us what you have already tried and tell us where you're stuck. Not present us a problem and suppose we fix it for you.
ssoni346 28-Jan-12 6:48am    
firstly i create 3 table 1st is forest(F_id,F_Name), 2nd is Trees(T_ID,T_Name,F_id) and third is leafs(L_id,L_name,T_ID)
query is
select * from leaves where L_ID in (select L_ID from Trees where F_id = 10);
Sander Rossel 28-Jan-12 7:23am    
Please use the "Improve question" button on the lower right side of your question. This way other people can read this too and you will get a better chance of getting your question answered. What exactly is your problem? I'd say your tables look about correct. Can't say for certain for your query. I'm sure other people could help in that respect.
Jörgen Andersson 29-Jan-12 16:38pm    
You've missed the fact that the leaves were supposed to have different types, so you need to add a field for that purpose.
Otherwise your tables seem fine.
But your query doesn't look so good: the table Trees doesn't have a field L_ID

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900