Jump to content

Structuring a dictionary's database


alcaeus

Recommended Posts

Hello all!

 

I am wondering how the average dictionary's database would be structured. (e.g. the database for http://dictionary.reference.com/ )

 

Some words may have up to twenty definitions, whereas some may on have one. How is this usually addressed? Should I just make twenty columns called "definition 1", "definition 2", etc. and then leave the majority blank for most words? Or is this handled in a completely different way?

 

Any advice would be greatly appreciated!  :D

Link to comment
Share on other sites

make 2 tables

 

table 1: dictionary

  - dictionary_id

  - word

 

table 2: definition

    - definition_id

    - dictionary_id

    - definition

 

so in table 1 dictionary_id would be an auto_increment filed, but not it table 2 and you would match on those two columns, it would look like so:

 

select * from dictionary dic left join definition def using(dictionary_id) where dic.word = "bat";

 

you would then get this:

 

+---------------+------+---------------+---------------+----------------------------------------+
| dictionary_id | word | definition_id | dictionary_id | definition                             |
+---------------+------+---------------+---------------+----------------------------------------+
| 1             | bat  | 1             | 1             | an animal with wings                   |
| 1             | bat  | 2             | 1             | an instrument used by baseball players |
+---------------+------+---------------+---------------+----------------------------------------+

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.