340 likes | 693 Views
Basics of Web Databases. With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database. Web sites are now able to display updated information on-the-fly and support user interactivity.
E N D
Basics of Web Databases • With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database. • Web sites are now able to display updated information on-the-fly and support user interactivity. • One can use the same page to display information of thousands of products in a database.
Three tiers of Web Databases • To build a Web database, usually we need to use a three-tier model: • Web server • Web application server (middleware), and • Database
How a User Interacts with a Web Database • From a Web browser, a user submits a request to the Web server. • The Web server passes it onto the middleware • The middleware writes the request in SQL queries and sends it to a back-end database. • The data retrieved are handed back to the middleware
How a User Interacts with a Web Database 5. The middleware generates a Web page for the data 6. The Web server sends the Web page to the browser 7. The browser displays the Web page to the user
Web Database Connectivity • Web-database connectivity takes several different forms: • CGI scripting A custom application is developed using a traditional programming language (such as C++, Python, Perl, or Java) accessed through the Common Gateway Interface (CGI). • Application server Such as ColdFusion or ASP, which works with the Web server that can communicate with databases through ODBC
ASP – Middleware for Windows Platform • ASP stands for Active Server Pages • ASP is a programming environment that gives the ability to generate dynamic html pages with the help of server side scripting. • VBScript is the default scripting language for ASP
ASP – Middleware for Windows Platform • An ASP page is almost the same as a HTM or HTML page... the only difference is that an ASP page has the '.asp' extension • Active Server Page can include both client side and server side scripts. • In an ASP page VBScript is usually used as the server side and Java Script as the client side scripting language
Special Software Needed to Write ASP? • You don't need any special software to write an ASP page. • An ASP page can be written with any HTML editor... even in Windows Notepad. • If you are looking for some special software to write an ASP page, Microsoft Visual InterDev is the best tool.
Special Software Needed to Write ASP? • InterDev helps you to easily develop ASP applications because it simplifies the process of developing and debugging ASP applications • ASP is browser independent because all the scripting code runs on the server and the browser only gets a normal HTML page as a result of server side scripting.
ASP Compatibility • ASP is an engine/program built into Internet Information Server (IIS) / Personal Web Server (PWS) • PWS is a smaller - but fully functional - version of IIS • To run IIS you must have Windows NT 4.0 or later • To run PWS you must have Windows 95 or later
What is an ASP File? • An ASP file is just the same as an HTML file • An ASP file can contain text, HTML, XML, and scripts • Scripts in an ASP file are executed on the server • An ASP file has the file extension *.asp
How Does it Work? • When a browser requests an HTML file, the server returns the file • When a browser requests an ASP file, IIS/ PWS passes the request to the ASP engine • The ASP engine reads the ASP file, line by line, and executes the scripts in the file • Finally, the ASP file is returned to the browser as plain HTML
What Can be Done with ASP • Dynamically edit, change or add any content of a Web page • Respond to user queries or data submitted from HTML forms • Access any data or databases and return the results to a browser
What Can be Done with ASP • The advantages of using ASP instead of CGI and Perl, are those of simplicity and speed • Provides security since your ASP code can not be viewed from the browser • Since ASP files are returned as plain HTML, they can be viewed in any browser
A Sample ASP Script <HTML> <HEAD> <TITLE>Hello World</TITLE> </HEAD><BODY> <% ' This will print to the browser the ' words Hello, ASP World. response.write "Hello, ASP World!" %> </BODY></HTML>
ASP and Database Servers • To interact with a database, you usually have to add code that talks to a particular database using a proprietary language. • If you want your program to talk to an Access, FoxPro and Oracle databases you have to code your program with three different database languages.
ASP and Database Servers • When programming to interact with ODBC you only need to talk the ODBC language. • The ODBC Manager will figure out how to contend with the type of database you are targeting • All that you need to do is have installed an ODBC driver that is specific to the type of database you will be using.
ODBC/DSN • ODBC stands for Open Database Connection (or Connectivity). • ODBC makes it easy to create ASP scripts that will connect to a database. • Normally, each ODBC will have a DSN (Data Source Name). • DSN contains all the information about the database
Setting Up the DSN • Setting up the DSN is a simple process. • Simply double-click the ODBC in the Control Panel • Choose the System DSN tab, and click Add. Choose the type of database you'll be working with - the sample database is MS Access - then click finish. • You'll then need to type in the database name in the Data Source Name box, and click Select.
Setting Up the DSN • Next you'll navigate to the drive and directory where the database is located, • Click on the file name and click OK on that window and the one behind it. • Now you can refer to the database by name in your scripts and the system will know which ODBC driver to use and where the database is located.