What Is an HTML Database?
Web database refers to the database resources accessed through the Web query interface in the Internet. One of the factors that promotes the development of the Internet is Web technology. From the static webpage technology HTML to the dynamic webpage technology CGI, ASP, PHP, JSP, etc., the web technology has undergone an important transformation process. The Web is no longer limited to only providing information services from static web pages, but has changed to dynamic web pages, which can provide interactive information query services, making information database services possible. Web database is the fusion of database technology and Web technology, making the database system an important organic part of the Web, so as to achieve the seamless combination of database and network technology. This combination not only brings together all the advantages of the Web and the database, but also makes full use of the information resources of a large number of existing databases. Web database consists of database server (Database Server), middleware (Middle Ware), Web server (Web Server), browser (Browser) 4 parts.
Web Database
- Web database access technology is usually implemented through a three-tier structure. The current technical methods of establishing connection and access to Web databases can be summarized as CGI technology, ODBC technology and ASP, JSP, PHP technology.
- CGI technology
- CGI (Common Gateway Interface, Common Gateway Interface) is a method based on a Web browser input program running on a Web server, and is the earliest solution for accessing a database. The CGI program can establish a connection between a web page and a database, convert a user's query request into a database query command, and then return the query result to the user through the web page.
- CGI programs need an interface to access the database. This kind of interface is various. The database system provides various database interfaces for CGI programs, such as Perl, C / C ++, VB and so on. In order to use various database systems, the CGI program supports ODBC mode, and accesses the database through the ODBC interface.
- ODBC technology
- ODBC (Open Database Connectivity) is an application program interface (API) that uses SQL. The most significant advantage of ODBC is that the program it generates has nothing to do with the database system. It provides a unified interface for programmers to easily write database applications that access various DBMSs, enabling data exchange between the application and the database source. The internal structure of ODBC is four layers: application layer, driver manager layer, driver layer, and data source layer. The relationship between them is shown in Figure 1-5. Because ODBC is applicable to different database products, many server extensions use a system structure that includes an ODBC layer.
- The Web server sends an SQL request to the database system through the ODBC database driver. The database system receives standard SQL query statements, and then sends the results of the executed query back to the Web server through ODBC. The Web server transmits the results to the Web as HTML pages. The browser works as shown in Figure 1-6.
- The programming advantage shown by the Java language has won the support of many database vendors. In terms of database processing, JDBC provided by Java provides a standard application programming interface for database development applications. Similar to ODBC, JDBC is also a special API, which is a Java application program interface for executing SQL statements. It specifies how Java exchanges data with the database. Database applications written in Java and JDBC have platform-independent features.
- ASP, JSP, PHP technology
- ASP is a dynamic web technology developed by Microsoft and is mainly used in Windows NT + IIS or Windows 9x + PWS platforms. To be precise, ASP is not a language, but a Web server-side development environment. ASP can be used to generate and run dynamic, interactive, high-performance Web services applications. ASP supports a variety of scripting languages. In addition to VBScript and Pscript, it also supports Perl language, and you can use multiple scripting languages in the same ASP file to take advantage of various scripting languages. However, ASP only supports VBScript and Pscript by default. To use other scripting languages, you must install the corresponding scripting engine. ASP supports calling ActiveX components ADO objects on the server side to achieve database operations. In specific applications, if there is a request to access the database in the scripting language, it can be connected to the back-end database through ODBC and perform operations to access the library through ADO. About ASP programming technology will be introduced in detail in Chapter 7.
- JSP is a new generation of Web development technology introduced by Sun. As a member of the Java family, it can run on almost all operating system platforms and Web servers, so JSP runs more widely. Currently, the only scripting language supported by JSP is Java. JSP uses JDBC to achieve access to the database. The target database must have a JDBC driver, that is, an interface from the database to Java. This interface provides standard methods for Java applications to connect to the database and perform operations on the database. JDBC does not need to create a data source on the server. SQL statements can be implemented through JDBC and JSP.
- PHP is a cross-platform embedded scripting language launched by Rasmus Lerdorf. It can run on popular operating systems such as Windows, UNIX, Linux, and IIS, Apache, Netscape and other web servers. Users do not need to change PHP code when changing platforms. PHP is an open source software developed through the cooperation of the Internet. It borrows the syntax of C, Java, and Perl and combines the characteristics of PHP to quickly write dynamically generated pages. PHP can access various databases through ODBC, but mainly access the database directly through functions. PHP supports most of the current databases, and provides many functions that directly interconnect with various types of databases, including Sybase, Oracle, SQL Server, etc. Among them, the best combination is the interconnection with SQL Server databases.
- Currently, Internet / Intranet technology is developing rapidly, and more and more database application software is running in the Internet / Intranet environment. Prior to this, the development of database application systems experienced a stand-alone structure, a centralized structure, and a client / server (C / S) structure. With the popularity of the Internet, a browser / server (B / S) structure and Multi-layered structure. When constructing an application system, the first consideration is the system architecture. Which structure is used depends on the network environment and application requirements of the system.
- Client / server architecture
- 1 . Two-tier C / S structure
- The two-tier C / S structure is a very popular database system structure. In this structure, the client makes a request, and the server responds to the client's service request. It separates the interface and data processing operations on the front-end (client) and back-end (server-side). This main feature makes the working speed of the C / S system mainly depends on the server that performs a large amount of data operations, rather than the front-end hardware equipment; At the same time, the requirements for network transmission speed are greatly reduced, because only the client needs to send a service request to the database server, and the database server only sends the service result back to the front end.
- At design time, data may be processed in different ways as follows.
- (1) During processing, the client first requests data from the server, and then releases the database, that is, the client sends a file request, processes the data on the client side, and finally sends the result back to the server. The disadvantage of this processing method is obvious: all application processing is done on the client side, which requires that the client computer must have sufficient capacity to execute any program required. To make matters worse, because all processing is done on the client, the entire file must be transferred to the client each time it is run before it can be executed. For example: There are 30 000 records in the Student table, the client issues a command:
- Select * From Student Where Sno = '200101'
- This command will require the server to transfer all records in the Student table to the client, and then execute the query on the client. Only one record is used as the result; if the query does not exist, the data transmitted by the network is actually useless. Such a large amount of data transmission is unimaginable. Therefore, a client / server structure is proposed in which a part of code can be executed in a server.
- (2) During processing, the client accepts the user's request and sends it to the server; on the server side, it processes the user's request, and finally sends the result back to the client for display or printing. This processing method has less network traffic. The client sends a processing request to the server, not a file request. The code in the processing request is transmitted to the client after the server executes the processed result.
- In this way, for specific tasks, the program on the client and the program on the server work together: the code on the client side is used to complete the user's input and output and data checking, while the server-side code completes the operation of the database.
- Another major feature of the client / server architecture is software and hardware platform independence. The database management system on the database server is centrally responsible for managing data. It provides an open environment for the client. The client accesses the database through database interfaces, such as ODBC (Open Database Connectivity) and SQL language. What kind of hardware and software can access the database as long as it can connect to the server through the network and database interface program.
- In the client / server architecture, the client is often called the foreground and the server is called the background. The functions of the foreground application include the user interface, receiving user data, processing application logic, making a request to the background, and receiving the results returned by the background at the same time, and finally displaying the returned results to the user in a certain format or manner. The background server is responsible for sharing external devices, accessing shared data, responding to requests from front-end clients and returning results. The foreground applications and data are generally user-specific, while the background data and code are shared by all users.
- Since the database server not only manages the shared data, ensures the integrity of the data, but also executes some code to complete some processing requests from the client, it places higher requirements on the computer used for the server. It is best to use a dedicated server with fast processing speed, large-capacity hard disk and memory, and support for large-capacity storage devices such as magnetic tape.
- The client / server structure mentioned above divides the application into two levels of client and server, which is called a two-tier client / server structure. In short, the basic working mode of the two-tier C / S structure is that the client program sends a SQL request to the database server, and the server returns data or results.
- There are two ways to implement this C / S structure. One is for the client to complete the presentation part and the application logic part, and the server for the data access part. This situation is client-centric, and is suitable for relatively simple applications and data access. The amount is not very large. The other is server-centric, and puts some important application logic on the server. This can make full use of the computing power of the server and reduce the data that needs to be transmitted on the network. Usually comes in the form of stored procedures and triggers, but stored procedures are dependent on a specific database, it is difficult to transplant between different databases, and the three-tier C / S structure can solve this problem well.
- Note: A trigger is a record-level event code in a database system that runs after insert, delete, or modify operations. Different events can correspond to different actions. There are usually three types of triggers: INSERT trigger, DELETE trigger, and UPDATE trigger.
- 2 Three-layer C / S structure
- Due to the inherent shortcomings of the two-tier client / server system, it cannot be applied to some large and more complex systems. Therefore, a three-tier client / server system has emerged. It is divided separately from the client application, that is, it adopts the "client-application server-database server" structure (as shown in Figure 1-8). A typical database application can be divided into three parts: the presentation part, the application logic (business logic) part, and the data access part. The three-tier structure corresponds to these three parts.
- The application server and the database server can be located on the same host or on different hosts. The client is the user interface part of the application and is responsible for the interaction between the user and the application. The software running on the client is also called presentation layer software. Application server stores business logic layer (also called functional layer) software, which is the core of application logic processing and realizes specific services. It can respond to client requests, complete business processing or complex calculations. If there is a database access task, the application server layer can send SQL instructions to the database server according to the client's requirements. When the application logic becomes complicated or a new application is added, a new application server can be added. The database server is used to execute the SQL instructions sent by the functional layer to complete data storage, access, and integrity constraints. After the operation is completed, the operation result is returned to the client through the application server.
- Browser / server architecture
- With the wide application of Internet technology and Web technology, the C / S structure has been unable to meet people's needs. Because in a typical C / S system, it is no longer realistic to install front-end applications for customers, and it is not practical to restrict the client working environment to operating systems such as Windows, Macintosh, or UNIX. Therefore, a browser / server-based system came into being.
- After adopting the B / S structure, only a universal browser needs to be installed on the client, and it is no longer restricted by the specific operating system and hardware, which enables cross-platform applications.
- A typical application based on the B / S structure usually adopts a three-tier structure: "browser-Web server-database server". The working principle of the B / S mode is to request the Web server to access the database through the browser in the form of hypertext. After the web server accepts the client request, it activates the corresponding CGI program to convert the hypertext HTML language to SQL syntax, passes the request to the database, and after the database server receives the request, it performs data processing, and then returns the processing result set to the CGI program. CGI then converts the results to HTML, which is forwarded by the web server to the requesting browser, as shown in Figure 1-9.
- In the B / S mode, the standard configuration of the client is a browser, such as IE; business function processing is handled by an independent application server, and the Web server becomes the standard configuration of application processing; data processing is still handled by the database server.
- In essence, the B / S structure and the traditional C / S structure both execute applications in the same request and response mode. The main difference is that C / S is a two-layer or three-layer structure model, and its customers A large number of application software are concentrated on the client side, and B / S is a three-level or multi-level C / S structure based on HyperLink, HTML, and Java. The client requires only a single browser software, which is a brand new The architecture solves cross-platform issues. Up to now, these two structures have been widely used in different aspects. Although the C / S structure is obviously not as advantageous as the B / S structure in the Internet environment, it still has advantages in the LAN environment.
- Multi-layer architecture of Internet / Intranet information system
- Compared with the traditional two-tier application software, the multi-tier application software has many advantages such as good scalability, strong manageability, high security, and good software reuse. How to build an application software system in the Internet / Intranet environment Structure has become a very important issue, and it is also a new hotspot in the research of software systems today.
- At present, various technologies are emerging, such as the original static HTML pages, simple CGI gateway programs, Java Applet programs, current Web database technologies such as ASP, and dynamic Java online games and PHP technologies.
- In fact, the concept of multiple layers was proposed by Sun. The multi-layer application system proposed by Sun includes 4 layers: customer layer, top Web service layer, application service layer and database layer. The top Web service layer is a very important layer in Sun's multi-layered architecture, which mainly plays the role of proxy and cache. The top web server's role is to cache Java Applet programs and static data often used by local clients. It is usually placed in the local area network of the client and serves as a Java Applet host (a computer that transmits Java Applet programs to a Web browser). And acting as a proxy for accessing other services. Has the same effect as a normal proxy server. When building multi-layered application software, the Java platform is a good choice because it spans application platforms. In short, building a multi-layer application software system on the Java platform represents the future trend of Internet / Intranet applications.