Re: SQL
- From: "frebe" <fredrik_bertilsson@xxxxxxxxxxx>
- Date: 29 Jan 2006 07:29:48 -0800
> you showed me precisely a solution that uses an RDBMS,
> including a query language; and I showed you a solution that uses objects,
> including some pre-written ones.
Your original solution looked like this:
[city valueForKeyPath:@"custome...@xxxxxxxxxxxxxxxxxx"];
I suppose that "custome...@xxxxxxxxxxxxxxxxxx" can be considered as a
query or part of a query. If you claim that this solution is just using
objects, when are the statement below is also just using objects.
conn.createStatement("select * from customers where city=?");
> City *city = /* ... */;
> NSMutableSet *orders = [NSMutableSet set];
> NSEnumerator *costumerEnumerator = [[city customers] objectEnumerator];
> Customer *customer;
> while ((customer = [customerEnumerator next]) != nil) {
> [orders unionSet:[customer orders]];
> }
How do you navigate to the city object, by a map or?
Lets say we add an extra criteria, the order status has to be
"pending".
select *
from order
join customer on customer.id=order.customerid
where customer.city=? and order.status="pending"
Will you still start with the city object? Or will you start with the
OrderStatus object? Lets say that the number of cities are low and the
percentage of orders that are "pending" are low, that would be an very
ineffective way of finding the corrects orders. On the other hand, if
the number of cities are high and the percentage of "pending" orders
are high, starting from the city object would be a good idea. This kind
of decision can be made by the RDBMS optimizer totally hidden from the
application. In your network scenario, the navigational path is
hardwired in the application and impossible to automatically optimize.
Also, would you really have pointers the City and OrderStatus objects
to every order/customer. For every searchable attribute, you need to
maintain an extra map. Lets say you didn't realized that you would need
to find customers using a given city, when you first created the
application. To be able to do this search, you have to add an extra set
of customer references in the city class and update all existing city
instances using a linear traversal of all customer instances. Not very
flexible to future changes?
Fredrik Bertilsson
http://butler.sourceforge.net
.
- References:
- Prev by Date: Re: SQL
- Next by Date: Re: SQL
- Previous by thread: Re: SQL
- Next by thread: Re: SQL
- Index(es):
Relevant Pages
|