If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > return records that are related to other records

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-25-08, 12:57
unc_manos unc_manos is offline
Registered User
 
Join Date: Nov 2008
Posts: 4
return records that are related to other records

hi guys!,

I am quite familiar with datbase design and SQL, but I need your help to the problem I am facing right now!

I have a table in the database I am building now, in which I store words, their meaning and their etymology. Some of the words are derivatives of words in other records. For example, I may have one main word looking like:
word_id derivative_of word maening etymology
word_id - "analyze" "meaning of the word" "etymology"
word_id "analyze" "analyzable" "meaning of the word" (no etymology)

Whenever I want to get all the words that contain a word in their etymology, I run the proper query and everything goes OK. What I cannot do though, is to return the derivatives of the words along with the main words, when a word in the etymology exists. The main words have etymology only; their derivatives do not, as they are assumed to have the same etymology as their parent!
Do you think of a good design so that I get the word AND its derivtive(s) in one query?
One thought is to run the simple query, then programmatically ask for each derivative according to the returned parent word and then merge the 2 queries.
Another approach would be to store the derivatives in another table and return all the main words as well as the linked derivatives from the other. But this approach would not allow me to query one table when searching for parts in the word field.
Do you have any thoughts of a better design?
Thanks in advance,

Manos
Reply With Quote
  #2 (permalink)  
Old 11-25-08, 13:16
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Post the DDL for your tables.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #3 (permalink)  
Old 11-25-08, 13:56
unc_manos unc_manos is offline
Registered User
 
Join Date: Nov 2008
Posts: 4
[QUOTE=blindman]Post the DDL for your tables.[/
The database is in MS Access. The definition of fields (if I am not mistakn this is what you are asking me for) is the following:


WordId (autonumber)
Derivative (memo)
MainWord (memo)
Explanation (memo)
Etymology (memo)


Is this what you asked me to post?

Thanks again,

Manos
Reply With Quote
  #4 (permalink)  
Old 11-25-08, 14:05
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Well, the first thing that knocks me back in my seat is that you are using memo for all your datatypes.
Not only is this overkill, and a performance crusher, but the solution to your problem is going to rely on joining the table to itself on the Derivative and MainWord columns.
I wouldn't even store MainWord in your table. I'd store the WordID of the MainWord.... MainWordID.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #5 (permalink)  
Old 11-25-08, 14:18
unc_manos unc_manos is offline
Registered User
 
Join Date: Nov 2008
Posts: 4
Quote:
Originally Posted by blindman
Well, the first thing that knocks me back in my seat is that you are using memo for all your datatypes.
Not only is this overkill, and a performance crusher, but the solution to your problem is going to rely on joining the table to itself on the Derivative and MainWord columns.
I wouldn't even store MainWord in your table. I'd store the WordID of the MainWord.... MainWordID.
You are right, but then again I did not want to take any chance and trim any data fields. Are you suggesting that in the derivative field I should save its parent's wordID?
If so, have you got any suggestion as to how to retrieve the derivatives along with the main word?

Thanks again,

Manos
Reply With Quote
  #6 (permalink)  
Old 11-25-08, 15:22
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Yes.
A join.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
  #7 (permalink)  
Old 11-25-08, 16:04
unc_manos unc_manos is offline
Registered User
 
Join Date: Nov 2008
Posts: 4
Quote:
Originally Posted by blindman
Yes.
A join.
thanks alot for your quick replies. You suggestion did work.

For reference to other people, I write the methodology I followed.

Derivatives have now the parent word's ID and I build a typical query which would return all the words according to the criteria given in the query.

In order to solve the problem announced here, would be solved by inserting another table and joining it in the query build.

Thanks again,


Manos
Reply With Quote
  #8 (permalink)  
Old 11-26-08, 10:52
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
Quote:
Originally Posted by unc_manos
hi guys!,

I am quite familiar with datbase design and SQL
Respectfully....no. You are not. But you are on your way.
Good luck, and check back with us if you need help with anything else.
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On