|
|
Static and Dynamic SQL Continued from SQL and the Relational Model Now that you know a little about the relational model, we're going to ask you to forget about it. Well, not really, but at this point we should explain that even though SQL is based on Codd's relational model, it is not a full or faithful implementation of it. (That's one reason the SQL-92 standard doesn't mention relations.) For example, a SQL table is not exactly the same as a relation, because among other things, a SQL table allows duplicate rows and relations don't have duplicate tuples. Also, SQL doesn't support relational domains, although it does support data types to some extent. (Several prominent relational advocates are lobbying to include relational domains in a future SQL standard, however.) Unfortunately, the disparity between SQL and the relational model has caused a lot of confusion and debate over the years. Since the focus of this article is to teach you about SQL, not relational theory, we won't discuss all of the discrepancies here. For now, you just need to know that because there are differences, relational terms and SQL terms are not always interchangeable. From now on, we'll only use SQL terminology. Instead of relations, attributes, and tuples, we'll refer to their SQL counterparts: tables, columns, and rows. Static and Dynamic SQL You may have heard the terms static SQL and dynamic SQL. SQL is static when it is compiled and optimized prior to execution. We've already mentioned one form of static SQL when we talked about "embedding" it in C or COBOL applications. (This is also known as embedded SQL.) As you may have guessed, dynamic SQL is compiled and optimized during execution. Most end-user tools use dynamic SQL, because it enables you to write ad hoc queries. One way of executing dynamic SQL is through interactive or direct invocation (also known as directSQL), where the SQL statements are executed interactively from a terminal. There are some differences in syntax and behavior between static and dynamic SQL, but we don't need to go into them here. The main point is that for the sake of simplicity, we will give our examples in direct SQL, since more people--nonprogrammers as well as programmers--can learn SQL that way. Next: SQL Tutorial Published as PC Tech Feature in the 11/3/98 issue of PC Magazine. Elsewhere on ZDNet
|
|
TOP |
Copyright (c) 1998 Ziff-Davis Inc. |