Fog Creek Software
Discussion Board




Simple ASP Question

I'm pulling PRODUCT_SPECS from my database into a large Recordset and displaying them on my site.

Within the specs information sometimes there are titles of products.

Desire:
I'd like to automatically convert each product title found in the specs to be a link to another page.  I figure to open another Recordset from the PRODUCT_TITLES table and compare that listing to PRODUCT_SPECS and where a title exists make it into a link.

Problem:
Some product titles actually contain other titles. Example:

- TurboCAM Milling (software)
- CAM Milling (machine)

Question:
What's the best and simplest way to compare the information and create an automatic link? And how do I make the code differentiate between text found within other text and that which appears alone?

Thanks for the help.

Chi Lambda
Sunday, December 28, 2003

So we can help post the fields of the product_title and product_specs tables.

Matthew Lock
Sunday, December 28, 2003

I'm not sure why you wouldn't have a numeric primary key that you could compare with.

I'm also not sure why you wouldn't use join the tables using SQL, even if you did have text keys.

dmooney
Sunday, December 28, 2003

Note: the product titles found in the specs do not come from the PRODUCT_TITLES table.

Chi Lambda
Sunday, December 28, 2003

hmmm sunday + simple question = Homework?

the artist formerly known as prince
Sunday, December 28, 2003

prince:

Nope. Employee + Israel = Work on Sunday.

Chi Lambda
Monday, December 29, 2003

Give us some more info.  Is performance an issue? Is the PRODUCT_TITLES table large?  Where does the data come from and how else is it used? Can you add an index table of some kind to the database?  Can you flag or tag titles in the text of the specs?

Are you familiar with regular expressions?

Stuart Matheson
Monday, December 29, 2003

Stuart: Thanks for the follow-up but I got my question answered already.

Chi Lambda
Tuesday, December 30, 2003

1) intermediate look up field/table
2) MD5 hash function with salt

Li-fan Chen
Saturday, January 03, 2004

you'll also have to clean up the titles, dups and shit will just clog up your lookup and make you look stupid.

Li-fan Chen
Saturday, January 03, 2004

what you gotta do is download one of those sp_oa stored procedures from the net that creates an MD5 function for you
salt = SaltBuilder(Rnd)
key = Digest_Builder(MD5_Encode(salt,strTitleInEntirety)), LenOfDesiredKey)
insert into intermediate table the base64ed text appending salt + unique delimiter + key

you'll have to do a uniqueness check

say hi to all the folks in israel for us

Li-fan Chen
Saturday, January 03, 2004

you don't have to use sp_oa, this could be asp side, okay okay, chi i am sure you don't need THAT much spoon feeding so i'll stop. ;)

Li-fan Chen
Saturday, January 03, 2004

the rational for this whole hashing exercise:

links tends to need to be small, if a title is 512 characters long.. that's not a fun query_string to embed into an asp flow (although it is legal to a certain length).. at this point the proper solution is a key look up or a cryptographic hash of text comparison.

this is the only way to make those links short and pretty (and a somewhat acceptable way to prevent people from accidentally or intentially doing look ups of entire description tables using incremental rowid scans)

Li-fan Chen
Saturday, January 03, 2004

well, technically, to really prevent people from hashing to the same thing you'll need a secret salt as well on the backend, but you all knew that...

Li-fan Chen
Saturday, January 03, 2004

*  Recent Topics

*  Fog Creek Home