MySQL program design overview [figure] _ MySQL

Source: Internet
Author: User
MySQL program design overview [figure] MySQL has a set of utilities. For example, mysqldump exports the context and structure definitions of a table. mysqlimport loads data files into the table, and mysqladmin manages w operations. mysql allows users to interact with the server to execute arbitrary queries. Every standard MySQL utility tends to be small, with a focus on the specific and limited functionality that a program can accomplish. Even in mysql, mysql is more flexible than other utilities, so it can be used to execute any number of queries, that is, it is designed to allow direct SQL queries to the server and view the query results.

The limited feature of the MySQL client is not a drawback, but is specially designed. Programs are utility programs with a general purpose; they do not try to anticipate all the possible needs you want to do. MySQL developers do not approve of writing large, bloated programs to try to do everything they may want (and the results will make the program contain a large number of things that you don't care about at all ). However, sometimes some applications do need to be unable to process the capabilities of conventional clients. To handle these situations, MySQL provides a client programming library. This allows you to write your own program to meet any specific requirements that your application may have. By allowing you to access the MySQL server, the openness of the client is limited only by your imagination.

How can I write my own program to obtain special capabilities? Let's compare the access to the mysql server by the MySQL client and its interface without additional code:

Customizable input processing

You can use mysql to enter the original SQL statement. With your own program, you can provide users with more intuitive and easy-to-use input methods. The user does not need to know SQL, or even the role of the database in the completed task.

The collection of input information may be a basic way to read prompts and values in the command line style, or it may be to use screen management packages (such as curses or S-L a n g), using the Tcl/Tk X Window or Web browser format based on the screen input as complex.

For most people, it is easier to specify the search parameters by entering a certain format than to publish a SELECT statement. For example, if a real estate agent is looking for a house with a certain price range, style, or location, you only need to input the search parameters into the table to get the matching content at the minimum price. This application is also considered when you enter a new record or update an existing record. The keyboard operator in the data input department should not need to know the SQL syntax such as INSERT, REPLACE or UPDATE.

Another reason for proposing the input collection layer between the end user and the MySQL server is that the input provided by the user can be verified. For example, you can check the data to confirm that they are in a MySQL-compliant format, or you can ask for a specific region.

Customizable output

Mysql outputs are basically unformatted. you can select a tab as the separator or output in the form of a table. If you want to make the output result look better, you must format it yourself. These requirements may be as simple as printing "Missing" instead of "NULL", or more complex. Consider the following report:

This report includes several specific elements:

1. customize the title.

2. duplicate values in the State column can be printed only when they are changed.

3. calculate the Subtotal and total.

4. digit format, for example, 9 4 3 8 4. 2 4. the number of USD printed is $9 4, 3 8 4. 2 4. Some tasks may not even require any output. You may be inserting computation results to another database table for simple retrieval. In addition to running this query, you may even want to output this result to other places. For example, if you are extracting the name and email address to automatically enter the format of the batch email to generate the Mail, the program generates the output. However, the output consists of the information of the email recipient without the information of the running program personnel. It can work in an environment where SQL itself imposes constraints. SQL is not a process language with a process control structure with conditional selection, loops, and subroutines. SQL scripts include a set of executable statements from the beginning to the end, with a minimum error check.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.