| SQL & MySQL Terminologies |
| |
| Basic Database Terminology |
| |
| Within the database world, MySQL is classified as a relational database management system (RDBMS). That phrase breaks down as follows: |
| |
| . The database (the "DB" in RDBMS) is the repository for the information you want to store, structured in a simple, regular fashion: |
| |
o The collection of data in a database is organized into tables.
o Each table is organized into rows and columns.
o Each row in a table is a record.
o Records can contain several pieces of information; each column in a table corresponds to one of those pieces. |
| |
| . The management system (the "MS") is the software that lets you use your data by allowing you to insert, retrieve, modify, or delete records. |
| |
| . The word "relational" (the "R") indicates a particular kind of DBMS, one that is very good at relating (that is, matching up) information stored in one table to information stored in another by looking for elements common to each of them. |
| |
| The power of a relational DBMS lies in its ability to pull data from those tables conveniently and to join information from related tables to produce answers to questions that can't be answered from individual tables alone. |
| |
| Query Language Terminology |
| |
| To communicate with MySQL, you use a language called SQL (Structured Query Language). SQL is today's standard database language, and all major database systems understand it. SQL supports many different kinds of statements, all designed to make it possible to interact with your database in interesting and useful ways. |
| |
| As with any language, SQL may seem strange while you're first learning it. For example, to create a table, you need to tell MySQL what the table's structure should be. You and I might think of the table in terms of a diagram or picture, but MySQL doesn't, so you create the table by telling MySQL something like this: |
| |
| CREATE TABLE company |
| |
(
company_name CHAR(30),
company_num INT,
address CHAR(30),
phone CHAR(12),
associate_type CHAR(10)
); |
| |
| Statements like this can be somewhat imposing when you're new to SQL, but you need not be a programmer to learn how to use SQL effectively. As you gain familiarity with the language, you'll look at CREATE TABLE in a different light-as an ally that helps you describe your information, not as just a weird bit of gibberish. |
| |
| MySQL Architectural Terminology |
| |
| When you use MySQL, you're actually using two programs, because MySQL operates using a client/server architecture: |
| |
| . The server program, mysqld, is located on the machine where your databases are stored. It listens for client requests coming in over the network and accesses database contents according to those requests to provide clients with the information they request. |
| |
| . Clients are programs that connect to the database server and issue queries to tell it what information they want. |
| |
| The MySQL distribution includes the database server and several client programs. You use the clients according to the purposes you want to achieve. The one most commonly used is mysql, an interactive client that lets you issue queries and see the results. |
| |
| Two administrative clients are mysqldump, which dumps table contents into a file, and mysqladmin, which allows you to check on the status of the server and performs administrative tasks, such as telling the server to shut down. |
| |
| The distribution includes other clients as well. If you have application requirements for which none of the standard clients is suited, MySQL also provides a client-programming library so that you can write your own programs. The library is usable directly from C programs. |
| |
| If you prefer a language other than C, interfaces are available for several other languages-Perl, PHP, Python, Java, C++, and Ruby, to name a few.
MySQL's client/server architecture has certain benefits: |
| |
| . The server provides concurrency control so that two users cannot modify the same record at the same time. All client requests go through the server, so the server sorts out who gets to do what and when. |
| |
| If multiple clients want to access the same table at the same time, they don't all have to find and negotiate with each other. They just send their requests to the server and let it take care of determining the order in which the requests will be performed. |
| |
| . You don't have to be logged in on the machine where your database is located. MySQL understands how to work over the Internet, so you can run a client program from wherever you happen to be, and the client can connect to the server over the network. |
| |
| Distance isn't a factor; you can access the server from anywhere in the world. If the server is located on a computer in Australia, you can take your laptop computer on a trip to Iceland and still access your database. Does that mean anyone can get at your data just by connecting to the Internet? No. MySQL includes a flexible security system, so you can allow access only to people who should have it. |
| |
| And you can make sure those people are able to do only what they should. Perhaps Sally in the billing office should be able to read and update (modify) records, but Phil at the service desk should be able only to look at them. You can set each person's privileges accordingly. |
| |
| If you do want to run a self-contained system, just set the access privileges so that clients can connect only from the host on which the server is running. |
| |
| Beginning with MySQL 5, you have another option for running the server. In addition to the usual mysqld server that is used in a client/server setting, MySQL includes the server as a library, libmysqld, that you can link into programs to produce standalone MySQL-based applications. |
| |
| This is called the embedded server library because it's embedded into individual applications. Use of the embedded server contrasts with the client/server approach in that no network is required. |
| |
| This makes it easier to create and package applications that can be distributed on their own with fewer assumptions about their external operational environment. On the other hand, it should be used only in situations where the embedded application is the only one that will need access to the databases managed by the server. |
| |
| |
|
|
| |
| |