Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP3121 E-Commerce Technologies Richard Henson University of Worcester October 2010.

Similar presentations


Presentation on theme: "COMP3121 E-Commerce Technologies Richard Henson University of Worcester October 2010."— Presentation transcript:

1 COMP3121 E-Commerce Technologies Richard Henson University of Worcester October 2010

2 Week 4 –Server-Side Scripting and Database Connectivity n Objectives:  Explain how software tools can assist with integration of the four basic components of a client-server dynamic web pages application  Identify available server-scripting & database connectivity systems  Create and use a simple database-linked server-script with Dreamweaver MX

3 WHY NOT Client only web applications? n In an ideal world everything would be able to run via the browser on the client machine:  faster  all data local  more controlled n If…  only small data sources, or infrequently changed data sources are used  data wasn’t being captured for a database that would be accessible by other clients, this could be the case

4 Example : Shop@ssistant n All written in Java Script and runs on the client machine  stores & presents product data  shows all the components and functionality expected of a shopping cart system  interfaces with systems that can be used to handle online payment n TAKE A LOOK!!!  downloadable from my website…

5 Critical Look at Client-end Applications n Pitfalls:  what if a large, regularly updated centralised data store needs to be accessed? »Example: search engine:  whole database would have to be downloaded every time the application is to be used!  client not powerful enough  client wouldn’t have the storage capacity  bandwidth not sufficient  local editing of code/data can compromise security n In many instances, server-scripting/interrogating a server-based database is the only way…

6 Location of the Database used for client-server web apps n Could be:  on the remote server containing the scripts  on an entirely different remote server elsewhere on the web n ODBC still used; for ease of connection, OLE DB software recommended… n Provided that the www address or IP address is known, the OLE DB connections software should be able to point to the database wherever it is on the net

7 How Server Scripts can Interact with Databases n n Contain embedded SQL code that can extract data from or send data to a database

8 How Server Scripts can Interact with Databases   Whenever a database is updated… » »updated data picked up by server-script when it runs » »updated data displayed on client

9 How Server Scripts can Interact with Databases   Whenever a browser form captures data… » »data transferred directly to relevant server » »then stored in specified database field(s)

10 How Server Scripts Interact with Databases n n Whenever database information needs to be presented:   database fields and records taken into server memory   data sent to local machine to be displayed within a HTML format

11 Making Server-Scripting easier for semi-programmers! n Dreamweaver and other tools (e.g. Visual Web Developer) can help produce the server code to manage all of these actions  great for producing web pages with templates, style sheets, forms, tables, etc.  Flexible enough to generate code is several type of script (i.e. asp, asp.net, cold fusion or php pages)  deals with connectivity software, uploading to remote server, many server scripts available »more scripts via the web using “Extension Manager” »include complex applications/components such as shopping carts…

12 When NOT to use web tools during web development… n n Database Design!!!   Recommended that this part is done using the RDBMS itself   Ideally, developers should use CASE tools, or at least entity-relationship diagrams   Implementation of database should follow logical database design   Development of SQL queries and server scripts should FOLLOW database implementation

13 Variable Passing between Dynamic Web Pages n n As the widening scope of the www became apparent, Tim Berners-Lee added several features to basic HTML syntax n n This allowed data to be passed from web pages in one location to remote server processes, using http n n ONE method = GET:   Problem: can result in v. long URLs…   “GET” function (parameter/s tagged on to the URL) e.g. » »Get /thetest.jsp?firstname=richard&password=holidays&la stname=henson&action=transferbankfunds

14 Variable Passing between Dynamic Web Pages n n Alternative: “POST”   designed to be used within HTML forms… n n Example of syntax, added to HTML coding within …   post /thetest.jsp firstname=richard&password=holiday s&lastname=henson&action=transfer bankfunds

15 How do Server Scripts work with HTML forms? n Browser:  allows HTML code to make a request to run a particular script on a server (specified location)  on positive server response, passes appropriately formatted captured HTML forms data to that server process n Server running the script:  uses data from browser as input to its process »saves results somewhere (on a database?) »optionally sends HTML info back to the browser to format and display results of processing as it wishes »optionally passes results back to the browser, usually to appear in a HTML table

16 CGI Scripts (pre-asp) n CGI (Common Gateway Interface)  first use of http for a client-server application  so called because different types of clients and server communicate using a common protocol (i.e. TCP/IP)  code written in “C”, not embedded with HTML  ran on Unix servers  fairly primitive client browser

17 Disadvantages of CGIs n n Free-standing programs connected to the Web server only through a few invocation parameters and environment variables   each cgi process… » »takes quite a lot of server memory » »has to be loaded in and out of memory before/after use n n By contrast, e.g. asp,asp.net cf or php scripts:   embedded in HTML and very tightly integrated with web server   can be configured to share the same web server process space in memory

18 Features of Embedded Server Scripts n n Must be of an appropriate type for the web server that is to execute the code   first line of file: declaration of language used e.g..net C# n n Take advantage of web server’s built-in connectivity technologies e.g. MDAC:   allows access to large databases held on remote web servers anywhere on the world wide web, security restrictions permitting   allowing script processes to perform many queries per second on such databases

19 “off the shelf” server-side code n n Packages like Dreamweaver have a library of existing server-scripts ready for use   the term “server scripts” becomes “server behaviours” n n Menu driven   "Live Objects" menu option enabling quick creation of: n n Master-Detail Pages n n Insert Pages n n Update pages

20 Creating new “Server behaviours” n n Dreamweaver also includes a Server Behaviour Builder   very popular with experienced developers   significantly improves the ability for end users and third parties to create additional Server Behaviours   allows programmers to incorporate advanced coding and database interaction into graphically well-designed Web pages

21 Interacting with the Database n n Many existing databases pre-date the www   MOST are relational n n When planning a new web-based system, it may be that the a suitable existing database already exists n n The choices are:   EITHER to convert/port data into a new DBMS   OR, assuming that existing database is relational, make use of the existing DBMS data as it stands

22 Choice of DBMS – entry level n n Access or MySQL - small databases   both use SQL queries n n Both have their limitations:   Access can’t support more than 10 concurrent users/queries   MySQL falls short of full SQL capability in other ways: » »http://www.borland.com/resources/en/pdf/white_papers/i b_vs_MySQL.pdfhttp://www.borland.com/resources/en/pdf/white_papers/i b_vs_MySQL.pdf

23 Beware Earlier versions of Access! n n Even pre-2000 Access versions…   integrate integrate well with server-side scripting BUT… » »use a slightly different SQL syntax » »not automatically transferable to enterprise databases if an organisation subsequently needs to move up to a more powerful system n n Enterprise databases like SQL Server and Oracle provide full-blown programming and business logic within the database…

24 Choice of DBMS - Larger systems n n SQL Server or Oracle?   both standard SQL   both interface well with asp.net, php, etc.   no realistic alternatives n n However, it is possible (as a stopgap?) to create an Access Project file that can use the more powerful SQL Server database engine (e.g. Access XP, 2003)

25 Developing the Database n n The programming of field links etc. should reside within the database   rather than on a specific Web page n n Consequently, when something needs to be changed in the database:   just need to change the “Stored Procedure” or “View”   Pages will, perhaps with minor modifications, update automatically   Any previous investment in programming will still remain even if the developer changes platform/scripting language…

26 Linking the Database with the Web Server n n Using IIS:   Microsoft Data Access Components (MDAC – originally VB source code) » »freely available on the web » »enables any database system to link to IIS » »BUT more vulnerable to viruses, etc. n n Using Apache:   UNIX: no MDAC “vulnerabilities” (historically,.COM objects contained source code)   if on Windows platform, still allows use of ODBC components so flexible…

27 Which to Use? n n All have their adherents   all can easily go pear shaped… n n Most reliable:   all Microsoft?   no Microsoft! (but not for the faint-hearted)   Some Microsoft: » »Apache/php on Windows

28 Microsoft Scripting & Execution Environments n n “All Microsoft” options means using existing skills rather than learning new ones:   asp.net programming code – any language!   creating a relational database – Access is a popular platform (but limited scalability)

29 Mixed Environments n n e.g. Apache/php on Windows   very popular “compromise” option for non-Unix developers   Apache web server runs on Windows » »possible to run Access with ODBC drivers » »if on the same platform as IIS… n n each needs a separate TCP port (both go for 80)   Popularised in XAMPP » »free to download » »Command-line interface » »contains an implementation of php scripting language » »and an implementation of MySQL… » »doesn’t have Access-type database design components

30 Unix Scripting & Execution Environments n n For those who like a challenge…   Unix/Linux, Apache & PHP » »all open source software » »can therefore save a lot of money   but more difficult to get support…

31 More about SQL n n Developed by IBM in 1974 as Structured Query Language   took a lot of the tedium out of database programming   based on a small number of commands   one line of SQL could replace 100 lines of COBOL! n n Popularised by:   ORACLE on mid-range systems   DB2 on IBM mainframes n n Now the industry standard for databases…

32 Benefits of knowing SQL when creating server-scripts… n n When developing server-scripts:   generating programming code is obviously important » »e.g. input/output knowledge of syntax of that language   but the embedded database queries also have to be right... n n It figures that:   the more a developer is competent with SQL syntax…   the more elaborate interaction they will be able to achieve with database data

33 Basics of SQL n SELECT statement  allows field/s to be specified n FROM  Allows table/s to be specified n WHERE  conditionals based on particular field values n ORDER BY  allows results to be ordered by field/s

34 Datasets – Improving Download Time n Dreamweaver MX asp.net controls encourage the creation of data subsets  known as “datasets”  saves on amount of data downloaded »e.g. fields can all be held in a single table »faster processing and display  remote database access becomes a much more dynamic experience for the client/user n VERY important during on-line shopping

35 Creating ASP.net Datasets using SQL n The four basic SQL commands above can create a very wide range of datasets from any compatible relational database n For server behaviour compatible datasets to be created, the script has to first make a logical database connection n Dreamweaver even makes all this easy by:  using a Wizard to create a named connection  Using a further wizard to generate the SQL that will create the dataset, once the database connection has been made

36 Learning SQL? n n The more you know the better it is… n n Possible to practice modifying queries using Dreamweaver’s SQL query writing tool   gives you experience of server behaviours, databases, and SQL queries all at the same time   will also come in very handy in the design of the database that underpins any shopping cart system…


Download ppt "COMP3121 E-Commerce Technologies Richard Henson University of Worcester October 2010."

Similar presentations


Ads by Google