[thelist] help with SQL and PHP

Tom Dell'Aringa pixelmech at yahoo.com
Tue Dec 10 16:23:02 CST 2002


--- rudy <r937 at interlog.com> wrote:
> > So Question #1 - how can I pull all the categories in my SQL
> above
> > as well as what I am already getting.
>
> this is a trickier question than you realize

I was afraid of that...

> can menuitem-to-category be zero-to-one? or must each menuitem have
> a
> category?

No, each menuitem must have a category.


> the other side of the category-menuitem relationship is whether a
> category
> can exist without any menuitems in it
>
> assuming the answer is yes, then you'd need an outer join in that
> direction,
> and if you combine that with the above requirement, menuitems
> without
> categories, then you are looking at doing a "full outer join"

Yes, a category CAN exist without a menuitem. The example is a
restaraunt that has a dinner menu based on the day of the week. They
would have:

Dinner
  Mon
  Tues..etc

There wouldn't ever be a dinner menuitem directly under 'dinner',
only under the days of the week.

> complicating the whole deal is the category-subcategory structure,
> with the
> likelihood that menuitems can be related to either a subcategory or
> a
> category, and that a category may or may not have any subcategories
> (another
> outer join in the offing) and you end up with very complicated
> retrieval
> requirements indeed, assuming you wanted to print everything out,
> nicely
> nested, with menuitems at any level, or not at all, and categories
> with or
> without menuitems, and with or without subcategories...

Yep, this is why I had at first thought of doing things the 'bad' way
- looping through the cats and running queries in the loop. But I
figured, try do it right at least!

Categories may or may not have subcats. And I do need to print out
everything nice and neat. If this was just for one restaraunt, it
would be of course easier, but this has to fit multiple places with
multiple types of menus.

To reiterate:
- A menuitem MUST have a category
- A category MIGHT NOT have a menuitem attached (it may have only
subcategories)

What think ye!?

Tom

=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the thelist mailing list