Download Databases - gozips.uakron.edu

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

SQL wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Open Database Connectivity wikipedia , lookup

Relational model wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Object-relational impedance mismatch wikipedia , lookup

Transcript
2440: 141
Web Site Administration
Web Server-Side Programming
Instructor: Joseph Nattey
The Need for Programming Languages
 Web pages with just HTML statements are static pages
 Pages that contain programming statements allow
changes and they are called dynamic pages
 Programming languages can also be used to update
databases and communicate with other systems
Programming Languages
 a programming language processes information from the
user and from data stored in a database.
 the result of the processing can consist of a report sent to
the user or data returned to the database.
Web Server-Side Programming
3
Programming Languages
 The data can come from a variety of sources including a
user who typed information on a web page.
 Programming languages perform three basic steps
 Input data, Processes data, Store data, Output data
Web Server-Side Programming
4
Programming
 Programming languages process data in three ways,
sequence, decision/logic, repetition/iteration
 Sequence – one instruction after another is processed
Web Server-Side Programming
5
Programming
 Programming languages process data in three ways.
 Decision/logic – based on data more than one option is
possible.
 Pseudo code for .10 percent book
discount with purchase of more
than 3 books:
 if (books > 3 then
totSales = sales * .10
else
totSales = sales
Web Server-Side Programming
6
Programming
 Programming languages process data in three ways.
 Repetition – also known as looping or iteration structures,
provides our program logic with ability to repeat a block of
statements based on the evaluation
of a Boolean expression.
 Pseudo code to repeat a sequence
statement 10 times:
 while cnt < 10
total = cnt * qty
 Flow Chart to repeat a sequence
statement 10 times:
Web Server-Side Programming
7
Programs
 Programs are written to perform specific tasks
 Programming is accomplished using major elements such as:
 Syntax and Expressions
 Comments
 Literal Values
 Data Types and Variables
 Input/Output Data
 Arithmetic Operations
 Logical Operations


Selections/Decisions
Repetitions/Looping
 Arrays
Web Server-Side Programming
8
Web Programming Languages
 Web pages that contain only HTML/XHTML statements
are called static pages
 Web pages that contain programming statements are
known as dynamic pages (allow the content to change)
Web Server-Side Programming
9
Web Programming Languages…
 Programming languages can be used to create:
 Dynamic webpages on client Web browsers

Using client-side scripting languages such as JavaScript and
VBScript
 Dynamic webpages that run on Web servers and update
databases


Using server-side scripting languages such as Java Server Pages
(JSP), Active Server Pages (ASP), ASP,NET, PHP, Coldfusion, etc
Using SQL on DBMSs such as Oracle, MySQL, SQL Server, DB2, etc
Web Server-Side Programming
10
Server-Side Programming
 Server-side programs provide dynamic content and
allows interaction with Web users using:
 DHTML
 Active Server Pages (ASP)
 Servlets and Java Server Pages (JSP)
 PHP: Hypertext Preprocessor (PHP)
 Practical Extraction and Reporting Language (Perl)
 Databases
Web Server-Side Programming
11
Dynamic Documents
 Dynamic HTML (DHTML) is a term for a combination
of client-side technologies that produce dynamic
documents
 DHTML can be used to create simple animations,
images, and text with resources such as:
 HTML/XHTML
 Style sheets (CSS)
 Client-side scripting (JavaScript or VBScript)
Web Server-Side Programming
12
Web Applications
 Web applications use a combination of the following
 HTML/XHTML
 Style sheets (CSS)
 Client-side scripting languages
 such as JavaScript or VBScript
 Server-side scripting languages
 Such as ASP, ASP.NET, PHP, JSP, etc
 Database Management Systems (DBMS) to create and
manipulate databases

Usually using the embedded Structured Query Language (SQL)
especially in Relational Databases.
Web Server-Side Programming
13
HTML Form Page
<html>
<head>
<title>HTML Form Page</title>
</head>
<body>
<form action=“http://localhost/cgi-bin/perl/hello.cgi”
method=“post”>
7.
<input name=“firstname” type=“text” />
8.
<input value=“Send” type=“submit” />
9.
</form>
10. </body>
11. </html>
1.
2.
3.
4.
5.
6.
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Web Server-Side Programming
Opening <html> tag
Opening <head> tag
Specifying the title of the page (HTML Form
Page) with the two-sided <title> tag
Closing </head> tag
Opening <body> tag
Opening <form> tag specifying the recipient
CGI file using the action attribute and the
method of sending data (using the HTTP’s
post) with the method attribute
Using the <input> tag’s type attribute to
specify the form component (text for textbox)
being used to accept data, and the name
attribute to uniquely identify the component
Using the <input> tag’s type attribute to
specify a submit button (submit) being used
to send data, and the value attribute for the
button’s caption
Closing </form> tag
Closing </body> tag
Closing </html> tag
14
DHTML Sample Code
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
<html>
<head>
<script type = "text/javascript">
document.writeln("Hello World");
</script>
<style type=“text/css”>
p {color: blue}
</style>
<title>DHTML Page</title>
</head>
<body>
<p> Embedded style </p>
<p style="color: red"> Inline style </p>
</body>
</html>
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
Web Server-Side Programming
Opening <html> tag
Opening <head> tag
Opening <script> tag specifying the script
language of choice (JavaScript)
Displays text (“Hello World”) on a browser
Closing </script> tag
Opening <style> tag specifying the style sheet
type (css – cascading style sheet)
Specifying a value of blue as the text color for
all paragraphs on the page – Embedded style
Closing </script> tag
Specifying the title of the page (DHTML Page)
with the two-sided <title> tag
Closing </head> tag
Opening <body> tag
Displays a paragraph on the page
Displays a paragraph with an Inline style
Closing </body> tag
Closing </html> tag
15
Active Server Pages (ASP)
 Microsoft’s server-side technology for creating
dynamic Web pages
 Based on Microsoft’s Component Object Model
(COM) and ActiveX Controls
 COM is a Microsoft standard that defines how software
components from different vendors can work together
 ActiveX controls are components built using the COM
specifications
 VBScript and JavaScript are the most popular ASP
languages but any language (such as C++, Perl, Java)
that supports COM can also be used
Web Server-Side Programming
16
ASP Page
1.
2.
3.
4.
<%@ language=“Javascript”>
<html>
<%= “Hello World” %>
</html>
<%@ Language=VBScript %>
<html>
<head>
<title>Example 1</title>
</head>
<body>
<%
FirstVar = "Hello world!"
%>
<%=FirstVar%>
</body>
</html>
1.
2.
3.
4.
Specifies the ASP script language using the @
directive
Opening <html> tag
Displays text on a page using the = directive
Closing </html> tag
1. Assigns the text "Hello World" to the variable FirstVar.
2. Uses HTML to make an HTML page.
3. Uses <%FirstVar%> to print out the value of the
variable FirstVar.
4. Ends the HTML page.
Web Server-Side Programming
17
Servlets and Java Server Pages (JSP)
 Sun Microsystem’s alternative to Microsoft’s ASP
 Rely on Sun’s Java programming language
 Java – a portable object-oriented language
 Servlets – are server-side programs like CGI programs but
run as part of the Web server instead of executing as
separate processes (as CGI scripts do)
 JSP – provides the same benefits of servlets

lets you mix regular, static HTML with dynamically-generated
HTML.
 JavaBeans – a component model written in Java to allow
developers write reusable components

JSP’s solution to separate content from presentation
Web Server-Side Programming
18
JSP Page
1.
2.
3.
<html>
<%= “Hello World” %>
</html>
1.
2.
3.
Web Server-Side Programming
Opening <html> tag
Displays text on a page using the =
directive
Closing </html> tag
19
PERL
(gyina)
 Perl is the Swiss Army chainsaw of scripting
languages: powerful and adaptable.
 It was first developed by Larry Wall, a linguist working
as a systems administrator for NASA in the late 1980s,
as a way to make report processing easier.
 Since then, it has moved into a large number of roles:
automating system administration, acting as glue
between different computer systems; and, of course,
being one of the most popular languages for CGI
programming on the Web.
Web Server-Side Programming
20
Perl CGI Script
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
#!/cgi-bin/perl
#hello.cgi – Sample perl script
print “Content-type: text/html\n\n”;
use CGI qw(:standard);
use strict;
my ($fname);
$fname = param(‘firstname’);
print “<HTML\n”;
print “<head><title>Perl CGI
Script</title></head>\n”;
print “<body>Hello $fname</body>\n”;
print “</html>\n”;
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Web Server-Side Programming
Location of the Perl interpreter (required in
UNIX; optional in Windows)
Comment (non-executable statement)
Sends an HTML document type (text/html) to
the browser using the HTTP header line
(Content-type) and creates a new line
Allows the script to parse data from the form
when received
Prevents Perl from using undeclared variables
Declares a scalar variable (preceded by a $
sign) named fname
Assigns a form data to a variable
Sends the opening <html> tag to the browser
Sends the two-sided <head> and <title> tags
to the browser
Sends the two-sided <body> and contents of
the page to the browser
Sends the closing </html> tag to the browser
21
PHP: Hypertext Preprocessor (PHP)
 A simple open-source server-side programming language
used for developing interactive Web documents
 Includes object-oriented programming (OOP) capabilities
Web Server-Side Programming
22
PHP Page
1.
2.
3.
<html>
<?php echo “Hello World” ?>
</html>
1.
2.
3.
Web Server-Side Programming
Opening <html> tag
Displays text on a browser
Closing </html> tag
23
Databases
 Databases are a collection of data and metadata
(data about other data) about entities using a
database management system (DBMS)
 DBMS – software used to create, construct and manipulate
databases

E.g. DB2, Oracle, Microsoft SQL Server, MySQL, etc
 Entities – any thing, place, event, etc that data is collected
about

Data is collected in the form of attributes to help make up records


Attributes – description of an entity
Records – collection of attributes
Web Server-Side Programming
24
Database Management Systems
(DBMSs)
 The purpose of a DBMS is to store data in an organized
manner for further processing
 Structured Query Language (SQL) is the language used to
define and manipulate the data
 Most databases are relational and organize data into
tables
DBMS
 Most DBMSs use a data definition language (DDL) and
data manipulation language (DML) to help create and
manipulate databases
 The most widely used DDL/DML for databases is the
structured query language (SQL) – pronounced “sequel”
 Used by virtually all DBMSs
Web Server-Side Programming
26
SQL
 SQL is a language embedded in virtually all DBMSs to
perform several tasks including:
 Creating the structure of database objects

Using the create command
 Removing database objects

Using the drop command
 Changing the structure of database objects

Using the alter command
Web Server-Side Programming
27
SQL…
(kyere)
 Other SQL functionalities include:
 Adding records into database tables

Using the insert command
 Removing records from database tables

Using the delete command
 Changing records in database tables

Using the update command
 Retrieve records from database tables

Using the select command
Web Server-Side Programming
28
Web Servers and Server-Side
Programming Language
 Choosing a programming language for server-side
programming depends on the type of Web server to use
and vice versa
 The two most popular Web servers allows you to choose
their most friendliest programming language
 IIS is most friendly with ASP, ASP.NET
 Apache is most friendly with PHP, JSP, etc
Web Server-Side Programming
29