alcaeus Posted May 14, 2012 Share Posted May 14, 2012 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! Quote Link to comment https://forums.phpfreaks.com/topic/262527-structuring-a-dictionarys-database/ Share on other sites More sharing options...
The Little Guy Posted May 14, 2012 Share Posted May 14, 2012 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 | +---------------+------+---------------+---------------+----------------------------------------+ Quote Link to comment https://forums.phpfreaks.com/topic/262527-structuring-a-dictionarys-database/#findComment-1345429 Share on other sites More sharing options...
alcaeus Posted May 19, 2012 Author Share Posted May 19, 2012 Thank you so much! This had been bugging me for ages. Now that you've said it, it seems so obvious! Quote Link to comment https://forums.phpfreaks.com/topic/262527-structuring-a-dictionarys-database/#findComment-1346917 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.