yukio:
> I'm using a UNION to add the results for each entity type,
> but is this the best way to do it?
if you want payments from both employees and suppliers, yes
greg:
> Currently, I have an InvItem table and then the 5 sub category
> tables with a Type field in the InvItem table. This looks like it will
> work, but the queries will run slower than I would like.
you cannot predict performance; the best you can do is set it up several different ways, load up some meaningful volumes, and test -- but who's got time for that?
you have a few options
consider throwing all attributes into one table, and letting them be null where necessary -- that would make a query like the following really efficient
> A query that listed all inventory items would need to
> include cost, price, etc as well as color, length, width,
> weight, packaging, and shelf_life even though those fields
> will not have anything in them most of the time.
note that this is the same result you'd get if you did a 6-way left outer join -- nulls in all the places where the subtype didn't match, but the entire result set includes all items
another option is to put all attributes into a separate table, so that each item will join to the attribute table, and pull out as many rows as needed to describe it -- this means each attribute (color, size, cost, etc.) will need to be coded into an attribute table
the advantages are that you can pull common attributes (list all items that have a cost, where cost was common to, say, 3 of your 5 subitem types), and furthermore, further enhancements are easy -- imagine what a mess of your code it would be to suddenly be told the week after your app goes live that you have to add a 6th type... all your queries are belong to us!!
let me know if you need more info, i realize my descriptions here are pretty brief
rudy
http://rudy.ca/