Edward said:
basically, MS office help and the walkthroughs I have seen
dont actually give me definitions on what a Query is
actually doing... in fact, they dont really define
anything to do with the product. They just throw a bunch
of examples up in the air and say "imitate." I dont learn
that way.
I need to know what a Query is, what the fields Im filling
up are actually telling the computer, and how it all
relates to the other features in MS Access. I have
created forms successfully, and relational databases. But
I cannot search them, filter them, any of that fancy stuff
that actually makes a database something more than a
glorified shopping list. If Im understanding correctly,
queries are how I do this.... but Im just not seeing it...
the relationships dont make any sense.
Can someone explain in concept terms, not via example and
imitate, how this works? Right now this is just seeming
like high school calculus all over again. The teachers
know what theyre talking about, but examples arent
teaching the fundamental concepts, just how to copycat
procedure.
Thanks to anyone who can assist.
-EA
I agree with everything John Vinson said, his descriptions are great.
<technical discussion of MS Access and JET follows, ignore as desired>
Yes, this will dicuss MS Access Queries, but will get to it in a
round-about way.
A "Relational" Database is made up of several features.
The "DBMS", or Database Management System. Or "RDBMS" for Relational
Database Management System. MS Access and JET (mostly JET) are one such
product. More on this later.
The "Table" (technically known as a "Relation", and is the reason
Relational DBs are called what they're called).
Tables have "Rows" (technically known as a "Tuple", though not many refer
to it that way).
Tables also have "Columns" (although, if you listen to Mr. C.J. Date, it's
the Row that has Columns, but never mind).
Tables, Rows, Columns.
Every Column represents a place to keep a piece of data (whatever kind of
data the database designer wanted there). According to best practices in
database design, each Column should contain only a single piece of data that
cannot be broken down into sub-pieces of any kind.
A Row contains many Columns. The data found in one or more of those
Columns, together, uniquely identify the Row, and this Column or combination
of Columns is called the Primary Key (although virtually every RDBMS product
allows Tables to be created with no Primary Key at all).
Now that we have our Tables and their contents, what do we do with them?
We can ask the Database Manager (a piece of software) "questions" about
the data in the Tables. We do that with "SQL", a specialized computer
language. This is a key aspect of RDBMSes: The use of SQL to ask questions
about data in Tables through the Database Manager. The Database Manager
(JET, in the case of MS Access) rules the roost. Every question posed for
the database (a written SQL statement) is passed to the Database Manager.
It looks at the question, and decides the best way to get at the data stored
in the Database's Tables (a bunch of very smart people thought up lots of
cool and efficient ways to get at the data, and designed the Database
Manager to be able to figure out which of those ways were best to use to
solve any question posed with SQL). The Database Manager uses the
SQL/Question to go out to the data in the Tables, grab that data, and come
back with it and put it in a format also specified by the SQL/Question for
human viewing.
SQL is a type of computer language. The core of the language is commonly
used in all RDBMS products (SELECT, UPDATE, INSERT, DELETE, etc.), although
virtually every vendor has proprietary "extensions" built into it; MS
Access's "Crosstab--TRANSFORM/PIVOT" feature, is one such.
SQL is called a non-procedural language, because in the purest sense you
cannot write a series of instructions with decision branches and loops
(hallmark features of most computer languages) using it. Each SQL statement
tends to be all or nothing. Most RDBMS products have proprietary extensions
that allow SQL to be used in a procedural way (sort of); VBA for MS Access,
Transact-SQL for MS SQL Sever, etc.
In the SQL/RDBMS world, the SELECT statement of SQL is quite commonly
known as a "query", because it asks a question. "Query" has even become
synonomous with any SQL Statement, even those that don't ask questions
(UPDATE, CREATE TABLE, etc.).
Now, we finally get around to the MS Access Query. It is a little named
software "object" inside MS Access. It "wrappers" any SQL statment that JET
is capable of executing. The QBE (Query By Expression Grid) is a front-end
and user-friendly GUI-way of avoiding the need for knowledge of SQL. You
pick Column names and write Criteria, and when done, MS Access figures out
how to turn all that GUI-stuff into an SQL statment. Yup, all that just to
create a piece of SQL computer code. When you run the "Query", it is
actually taking the SQL statement inside the Query (viewable through SQL
View) and passing it to the JET Database Manager software. JET figures out
how to get the data, and then tosses it back into a GUI datasheet for the
user to view on the computer screen (or a Report calls on a Query and the
info is either displayed on-screen or is printed (but with lots of nice
formatting options not available to a simple computer-screen data-sheet)).
Most other RDBMS products call this sort of arrangement a "VIEW". SQL
even has a "CREATE VIEW" statement, but this is not implemented in JET, and
so we have the MS Access Query set-up that we do.
It is totally possible to avoid using the QBE Grid. Personally, I switch
to SQL view and write straight SQL for almost all cases (this is because I
learned to write SQL on other products, and don't get along with the QBE
Grid too well).
Sincerely,
Chris O.