[thelist] Beginner asp question

rudy r937 at interlog.com
Thu Oct 17 07:52:01 CDT 2002


>... Access (second stupidest app name ever)

the stupidest, of course, being "microsoft works"


to pay for this offtopic remark, i'd like to introduce a tip which some may
find surprising, coming from me

y'all are familiar with the concept of separating style from content?

it's difficult, isn't it?

the ultimate separation is achieved when you have used not a single class
or id name, applying all styles just to the structure, i.e. tags (aside:
run this concept by your favourite css guru and look for the interesting
facial shade of purple)

with database-drive web sites, a similar objective in development should be
the separation of application and database, such that there is no logic in
the application to deal with record processing


<tip type="sql">

the biggest difference between procedural thinking and set-based thinking
lies in the approach to accomplishing some action involving a number of
records

with procedural thinking, it's "do this, then do this, then this"

with set-based thinking, it's "these are the records i want"

for example, consider the problem of selecting a set of records from the
database, and returning them in sequence by some column using the ORDER BY
clause

so far so good, but now let's say you want to number the sorted rows, from
1 to N

with procedural thinking, you initialize a counter to 0, and start looping
over the returned records, incrementing the counter each time

with set-based thinking, you get the database to number the rows for you

yes, you can actually do this -- it is called a ranking query, and requires
a partial cross-join of the table to itself

is the set-based solution better?  yes, but only within limits

any solution where you can get the database to hand you the results,
instead of producing those results yourself with application code, is
better, because it separates application and database coding

ultimately, you want to reduce your application code as much as possible

however, a ranking query is relatively inefficient, and really starts to
bog down for large result sets

if you stretch the definition of "get the database to hand you the results"
to include a stored procedure, which can surreptitiously loop over the
result set and add another column for the row number, then you are well on
the way to separating application code from database code

procedural thinking is fine if it's within the realm of the database code!

</tip>





More information about the thelist mailing list