I am setting up vocabularies which replicate lookup tables we have in our current DB schema. I have many cases which require multiple "descriptions" of the same item.

For example, we have terms such as "Food & Beverage" and "Cross Country Skiing". In some locations in the site, the full name is used, and in other areas shortened versions are used ("Food & Beverage" becomes "Food", "Cross Country Skiing" becomes "XC Skiing").

Is it possible to use the taxonomy synonym field to accomplish this? Are there other recommended ways to do this?

Comments

cog.rusty’s picture

As far as I know, synonyms get into the database but currently they are not used at all in any way. If my understanding is correct, you would need some code of yours to use them.

sgdev’s picture

Ok, but are there approaches other than using synonyms? I know I could create duplicate vocabularies ... for example, one category of "full names" (Georgia, Hawaii, etc.) and a second of "short names" (GA, HI, etc.). However this just doesn't seem logical since typically these values would just be different columns in the same database table.

sgdev’s picture

No other thoughts on this?

cog.rusty’s picture

Depending on where the alternative labels should appear, I might try to solve this by theming.

sgdev’s picture

By theming? I'm not sure I understand ... you're suggesting code in the theme to display alternative labels?

Traditionally, if I was writing a SQL select I could call "state_id" on a States table and know this automatically references "state_abbreviation" and "state_name". If I create a vocabulary in Drupal, I get the sense there's only one dimension to the data ... for example, I'm only getting "state_name". If I want "state_abbreviation", I have to create a whole new vocabulary for it?

What I'm trying to understand is does this same concept exist in Drupal? Is there a notion within Categories or any other module where reference data is created, and has more than one term which means the same thing? For example, "North Carolina" = "NC" = "N. Carolina", and as a developer I can select any one of them knowing it's coming from the same place ...

cog.rusty’s picture

I am not aware of any available way to take advantage of taxonomy's synonyms. As far as I know taxonomy in its current state can't do it. It has been waiting for a few years for someone to need it bad enough to write code for it.

And yes, I meant code in the theme to display alternative labels, for example a function in template.php to override the $terms variable or to override an input form... it depends where I wanted those alternatives for judging if it's worth it. For example something like these:

Display taxonomy terms broken out by vocabulary
http://drupal.org/node/133223
Replacing certain taxonomy terms with icons
http://drupal.org/node/149738
Separate 'free tagging' terms from normal taxonomy terms
http://drupal.org/node/42680

sgdev’s picture

Yes that's what I assumed you meant ... I do appreciate you sharing. I guess this discussion makes me scratch my head a bit. I'm somewhat surprised this wasn't considered an important point in the application data approach.

While it's certainly possible to create many vocabularies or perform some exception coding to display alternative data, to me this is poor data design. Take a simplistic example such as assigning a country name to a node. I should be able to assign the term "United States" to content, and have it be a synonym for "US", "USA" and "United States of America".

When someone searches for "United States" in content, it would be easier to return all nodes with any of the 4 terms rather than having to retrieve a union of four terms on separate vocabularies. As well it would be much easier if I have the ability to select which of the 4 synonyms I want to display on a node, and just as easy to modified in the future since it's part of the same vocabulary. And don't even get me started on the long-term data entry/cleanliness issues faced with multiple vocabularies which are synonyms of each other.

Unless someone can help me better understand how I can handle such a scenario, I'll most likely wait until a future version when Drupal has a higher level of flexibility to its data architecture.

cog.rusty’s picture

Heh, it gets worse.

Terms are not even keys. You can have a single hierarchy like

London
- restaurants
- cafes
Paris
- restaurants
- cafes

where restaurants and cafes are totally different terms with different IDs. And the same term names can also exist in other vocabularies. So I can't really be picky with synonyms when it comes to searching.

Or you can have a multi-parent hierarchy where some children under different parents *can be* the same. Of course this doesn't make term names a key for searching either. There can be other vocabularies with that term.

Not sure how the data model(s) fare for a librarian/information scientist, but with Drupal I can do whatever I want one way or another. Definitely I wouldn't use multiple vocabularies there.

sgdev’s picture

I'm sure I'd have a different opinion about this if I was building a new site or upgrading a site with limited capabilities. However we're looking to upgrade an existing site which has a very well planned data model which is both efficient and flexible.

We were considering Drupal because we'd like to move to a more standardized platform with fully integrated user control/access rights. In my research though I've come to realize some of Drupal's functionality would be an improvement for us (administrative control, some aspects of content management) while others would be a significant step back (eCommerce, data integrity, speed of queries, among others).

I'll probably take a look at the product again in 18-24 months and see how things have progressed, maybe eventually once Drupal 7 is in initial testing. Thanks for your information, it has been helpful in making this decision.