Re: more dimensional method like a query...
- From: "Daniel Parker" <danielaparker@xxxxxxxxx>
- Date: 25 Nov 2005 07:44:20 -0800
Pi421 wrote:
> First i have stocks, depending on 4 attributes. Its like a tree, so
> there are 16 possible querys. Like the stock hat batchs, and the one
> patchs is reserverd for diffrent projekts and some of the materials in
> the stoch habe diffrent qualitys....
> So i want to programm a Method with 4 attributes. All combinations of
> the attributes are possible. Like getStock(batchA, ProjektX, QualityZ,
> conditionF).
> My question: How do i store the stock and how do i programm the
> getStock method. I think arrays are not the best way...
Where do the stocks live? In a database? In a collection in memory?
If the stocks live in a SQL RDBMS, you should attempt to meet the
requirement through a SQL query with an appropriate where clause,
bringing the minimum number of rows into your application space, and
winnowing them down further if you have additional constraints that
cannot easily be expressed in a SQL where clause.
If it's a collection in memory, the simplest thing is to iterate
through the collection and check each one for membership in your
restricted set. If one or two of the attributes are generally passed
to getStock as specific values, rather than wildcards or patterns, you
might want to create a map to narrow down the entries in the collection
that you need to search. I don't think you need to do much more than
that, linear searching in memory is very fast these days.
Another approach would be to represent the collection as an XML
document and use an implementation of XQuery to query the collection,
but that's probably more than what you need.
Regards,
Daniel Parker
.
- References:
- more dimensional method like a query...
- From: Pi421
- more dimensional method like a query...
- Prev by Date: more dimensional method like a query...
- Next by Date: Re: Decouple SQL queries from class in OOP design
- Previous by thread: more dimensional method like a query...
- Next by thread: Re: more dimensional method like a query...
- Index(es):
Relevant Pages
|