This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > April 2005 > Coding business directory - like Yahoo Yellow Pages





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Coding business directory - like Yahoo Yellow Pages
miner2049er

2005-04-27, 7:18 pm

I?m planning on coding a Business Directory - along the lines of Yahoo?s Yellow
Pages at http://yp.yahoo.com (and ones at many other sites) and seeking some
advice on coding my database schema.

After some searching on the web using various combinations of "yellow pages" +
"business directory" + mysql + "data structure" I wasn't able to come up with
much.

The Yahoo YP have some interesting features (a few I detail below), which
makes their data tree do things such as jump back to an earlier level, and I?m
starting to think how such things can be implemented in a data structure.

Before I start to code such an application - although not an overly complex
task, to avoid reinventing the wheel, and to save a few hours - I?m wondering
if anyone knows of any existing articles discussing the implementation of such
a system, taking into account the features I'm just about to mention?

With the Yahoo YP, there are top-level categories such as "Automotive", "Home
and Garden", "Real Estate" etc. and then sub-categories, such as "Automotive
Repair". Further down, just before you are shown the businesses, you have final
categories, which I will call container-categories, such as "Bars", "Video
Rental Stores" etc. that hold the actual businesses. Extending the Automotive
category started above, a full category path might be Automotive -> Repair ->
Transmissions.

So, a couple of features I noted (which I would like to implement):

(1) One feature with Yahoo YP, is that a business can sometimes be found in
more than one final container-category. For example, the business "BJ's Chicago
Style Brewpub" can be found in BOTH the container-categories "Bars" and also in
"Restaurants."

(2) Another feature - categories themselves can belong to multiple higher
level categories. For example, the category "Bars, Pubs, and Clubs" can be
found within both the higher level categories of "Entertainment/Arts" AND "Food
& Dining."

And another example, "Bakeries" is both located at:

Top -> Food and Dining -> Restaurants -> Bakeries

AND ALSO

Top -> Food and Dining -> Bakeries

(Interestingly, in the final example - the "page locator" text in both
instances displays as "Top > Food and Dining > Restaurants > Bakeries" in both
cases.)

FYI, I will be coding up in PHP 4.3.8 and mysql 4.0.20.

Any advice, and/or pointers to articles would be most appreciated.

Thanks in advance for any replies.

Miner2049er.

darrel

2005-04-27, 7:18 pm

> (1) One feature with Yahoo YP, is that a business can sometimes be found
in
> more than one final container-category. For example, the business "BJ's

Chicago
> Style Brewpub" can be found in BOTH the container-categories "Bars" and

also in
> "Restaurants."


You will need to have relation tables to do this.

I'd make one table 'categories' and one table 'businesses' and then a third
table 'categoriesBusinessesLink'

So, for categories you might have:

1 | auto repair
2 | resturaunt
3 | coffee shop

businesses:

10 | mike's auto repair
11 | Ben's resturaunt and coffee shop

then 'categoriesBusinessesLink' would have:

category | business
1 | 10
2 | 11
3 | 11

etc.

> (Interestingly, in the final example - the "page locator" text in both
> instances displays as "Top > Food and Dining > Restaurants > Bakeries" in

both
> cases.)


I'm assuming there is a specific relationship, and Yahoo is merely offering
'shortcuts' to deeper level children.

So, if you have your categories:

Food and Dining
Resturaunts
Bakeries

You could add a field in your DB 'showAtHigherLevel'. So, you could set that
to 'true' in bakeries, and then when you go to find all the children of Food
and Dining, you could also show Bakeries.

The catch is that now you are getting into recursive database calls, and
that can lead to some performance issues.

To be honest, UNLESS you are Yahoo, I see no need for allowing categories to
belong to multiple parent categories. I'd maybe work on a much more detailed
category system that wouldn't require that kind of relationship. And, maybe,
if you DID need it at a later time, simply add a 'related categories' option
instead.

-Darrel


miner2049er

2005-04-29, 7:21 pm

Thanks for reply.

By allowing sub-categories to appear in other categories, and also at
different levels (as in the example above) definitely gives people more avenues
to find businesses, and increases the usefulness of the directory.

Certainly, it adds to the Yahoo Yellow Pages functionality.

Another good example I found just now is that the category "Convenience
Stores" is located BOTH at:

Top - > Food and Dining -> Convenience Stores

AND ALSO

Top -> Retail Shopping -> Convenience Stores

So I plan on introducing such a feature into my database schema from the
start, to reduce the chance of any rewrites or modifications to the code/data
later.

So having the final leaf nodes (the businesses) be assocated with categories
seems OK to do, but I'm a bit stumped on how to handle the way that some
parents of an item, can also be the grandparents of that item? And being able
to do this with a data structure that doesn't require and "special treatment"
flags.

Any other advice folks?

Miner204er.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews