Application Architecture

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

Application Design and Development

9.1
Application Programs and User Interfaces

● Most database users do not use a query language like SQL


● An application program acts as the intermediary between users and
the database
● Applications split into
4 front-end
4 middle layer
4 backend
● Front-end: user interface
● Forms
● Graphical user interfaces
● Many interfaces are Web-based

9.2
Application Architecture Evolution
● Three distinct era’s of application architecture
● mainframe (1960’s and 70’s)
● personal computer era (1980’s)
● We era (1990’s onwards)

9.3
Web Interface
● Web browsers have become the de-facto standard user interface to
databases
● Enable large numbers of users to access databases from
anywhere
● Avoid the need for downloading/installing specialized code, while
providing a good graphical user interface
4 Javascript, Flash and other scripting languages run in
browser, but are downloaded transparently
● Examples: banks, airline and rental car reservations, university
course registration and grading, an so on.

9.4
The World Wide Web
● The Web is a distributed information system based on hypertext.
● Most Web documents are hypertext documents formatted via the
HyperText Markup Language (HTML)
● HTML documents contain
● text along with font specifications, and other formatting instructions
● hypertext links to other documents, which can be associated with
regions of the text.
● forms, enabling users to enter data which can then be sent back to
the Web server

9.5
Uniform Resources Locators

● In the Web, functionality of pointers is provided by Uniform Resource


Locators (URLs).
● URL example:
http://www.acm.org/sigmod
● The first part indicates how the document is to be accessed
4 “http” indicates that the document is to be accessed using the
Hyper Text Transfer Protocol.
● The second part gives the unique name of a machine on the
Internet.
● The rest of the URL identifies the document within the machine.
● The local identification can be:
4 The path name of a file on the machine, or
4 An identifier (path name) of a program, plus arguments to be
passed to the program
– E.g., http://www.google.com/search?q=silberschatz

9.6
HTML and HTTP
● HTML provides formatting, hypertext link, and image display features
● including tables, stylesheets (to alter default formatting), etc.
● HTML also provides input features
4 Select from a set of options
– Pop-up menus, radio buttons, check lists
4 Enter values
– Text boxes
● Filled in input sent back to the server, to be acted upon by an
executable at the server
● HyperText Transfer Protocol (HTTP) used for communication with the
Web server

9.7
Sample HTML Source Text

<html>
<body>
<table border>
<tr> <th>ID</th> <th>Name</th> <th>Department</th> </tr>
<tr> <td>00128</td> <td>Zhang</td> <td>Comp. Sci.</td> </tr>
….
</table>
<form action="PersonQuery" method=get>
Search for:
<select name="persontype">
<option value="student" selected>Student </option>
<option value="instructor"> Instructor </option>
</select> <br>
Name: <input type=text size=20 name="name">
<input type=submit value="submit">
</form>
</body> </html>

9.8
Display of Sample HTML Source

9.9
Web Servers

● A Web server can easily serve as a front end to a variety of


information services.
● The document name in a URL may identify an executable
program, that, when run, generates a HTML document.
● When an HTTP server receives a request for such a
document, it executes the program, and sends back the
HTML document that is generated.
● The Web client can pass extra arguments with the name of
the document.
● To install a new service on the Web, one simply needs to create
and install an executable that provides that service.
● The Web browser provides a graphical user interface to the
information service.

9.10
Slide 19- 11
Client-Server architecture

● Many clients connected with one server. The server is centerlined.it


provides services to all clients. All clients request to the server for different
Service. The server displays the results according to the client’s request.

Client/server architecture is also called as a networking computing model and client-server network because
all the requests and demands are sent over a network.

9.11
Structure of Client-server Database
Architecture in DBMS
● By using this architecture structure this software is divided into three
different tiers:
● Presentation tier
● Logic tier
● Data-tier

9.12
Slide 19- 13
Presentation -tier
● This is the first and topmost level of the application. The basic work of
this layer provides user interface .
● The interface is a graphical user interface. The graphical user
interface is an interface that consists of menus, buttons, and icons,
etc.
● The presentation tier presents information related to such work as
browsing, sales purchasing, and shopping cart contents.
● It attaches with other tiers by computing results to the browser/client
tier and all other tiers in the network.

9.13
Logic Tier
● The logical tier is also known as data access tier and middle tier.
● It lies between the presentation tier and the data tier.
● It basically controls the application’s functions by performing
processing.
● The components that build this layer exist on the server, assist the
resources sharing these components also define the business rules
like different government legal rules, data rules, and different business
algorithm which are designed to keep data structure consistent.

9.14
Data- Tier
● This is basically the DBMS (database management system) layer. This
layer consist of database.it can be used through the business
services layer.
● In this layer, data is stored and retrieved .The responsibility of this
layer to keep data consistent and independent.
● Providing data in its own tier also improves scalability and
performance. This layer consists of data access components.

9.15
Advantages of Client-server Database Architecture in DBMS

● All the data and resources are controlled by server .In this way all
data and resources are very consistent.
● You can easily increase the number of client in this architecture at any
time. This all increases the scalability of the network.
● This is very easy to maintain you can easily repair, replace or add
clients in this network. The independence of the changes also known
as encapsulation.
● This network is very easy to use and it is not complicated.

9.16
Disadvantages of Client-server Database Architecture in
DBMS

● Traffic is a big problem in this network.


● When you add large numbers of the client with server this network will
be more complicated.
● When the server goes down all the clients are not able to send their
request. The whole work will be stopped
● The hardware and software are very expensive.
● The client does not have resources for each resource they need to
request the server. Because of all resources exit on server

9.17
Two- Tier Architecture

9.18
Two-Layer Web Architecture
● Multiple levels of indirection have overheads
Alternative: two-layer architecture

9.19
Three-Tier Database Architecture

9.20
Three-Layer Web Architecture

9.21
9.22
HTTP and Sessions
● The HTTP protocol is connectionless
● That is, once the server replies to a request, the server
closes the connection with the client, and forgets all
about the request
● In contrast, Unix logins, and JDBC/ODBC connections
stay connected until the client disconnects
4 retaining user authentication and other information
● Motivation: reduces load on server
4 operating systems have tight limits on number of open
connections on a machine

9.23
Server-Side Scripting
● Server-side scripting simplifies the task of connecting a database to
the Web
● Define an HTML document with embedded executable code/SQL
queries.
● Input values from HTML forms can be used directly in the
embedded code/SQL queries.
● When the document is requested, the Web server executes the
embedded code/SQL queries to generate the actual HTML
document.
● Numerous server-side scripting languages
● JSP, PHP
● General purpose scripting languages: VBScript, Perl, Python

9.24
PHP
● PHP is widely used for Web server scripting
● Extensive libaries including for database access using ODBC
<html>
<head> <title> Hello </title> </head>
<body>
<?php if (!isset($_REQUEST[‘name’]))
{ echo “Hello World”; }
else { echo “Hello, ” + $_REQUEST[‘name’]; }
?>
</body>
</html>

9.25
Client Side Scripting

● Browsers can fetch certain scripts (client-side scripts) or


programs along with documents, and execute them in “safe
mode” at the client site
● Javascript
● Macromedia Flash and Shockwave for animation/games
● VRML
● Applets
● Client-side scripts/programs allow documents to be active
● E.g., animation by executing programs at the local site
● E.g., ensure that values entered by users satisfy some
correctness checks
● Permit flexible interaction with the user.
4 Executing programs at the client site speeds up
interaction by avoiding many round trips to server

9.26
Javascript
● Example of Javascript used to validate form input
<html> <head>
<script type="text/javascript">
function validate() {
var credits=document.getElementById("credits").value;
if (isNaN(credits)|| credits<=0 || credits>=16) {
alert("Credits must be a number greater than 0 and less than 16");
return false
}
}
</script>
</head> <body>
<form action="createCourse" onsubmit="return validate()">
Title: <input type="text" id="title" size="20"><br />
Credits: <input type="text" id="credits" size="2"><br />
<Input type="submit" value="Submit">
</form>
</body> </html>

9.27
Slide 19- 28
Types of API in Java for Data Base
Connectivity(JDBC)

9.28
Steps for JDBC

9.29
S
Sample Java Program to show JDBC

9.30
PHYSICAL STORAGE

9.31
Classification of Physical Storage Media

● Speed with which data can be accessed


● Cost per unit of data
● Reliability
● data loss on power failure or system crash
● physical failure of the storage device
● Can differentiate storage into:
● volatile storage: loses contents when power is switched off
● non-volatile storage:
4 Contents persist even when power is switched off.
4 Includes secondary and tertiary storage, as well as batter-
backed up main-memory.

9.32
Physical Storage Media

● Cache – fastest and most costly form of storage; volatile;


managed by the computer system hardware.
● Main memory:
● fast access (10s to 100s of nanoseconds; 1 nanosecond =
10–9 seconds)
● generally too small (or too expensive) to store the entire
database
4 capacities of up to a few Gigabytes widely used currently
4 Capacities have gone up and per-byte costs have
decreased steadily and rapidly (roughly factor of 2 every 2
to 3 years)
● Volatile — contents of main memory are usually lost if a power
failure or system crash occurs.

9.33
Physical Storage Media (Cont.)
● Flash memory
● Data survives power failure
● Data can be written at a location only once, but location can be
erased and written to again
4 Can support only a limited number (10K – 1M) of write/erase
cycles.
4 Erasing of memory has to be done to an entire bank of
memory
● Reads are roughly as fast as main memory
● But writes are slow (few microseconds), erase is slower
● Widely used in embedded devices such as digital cameras,
phones, and USB keys

9.34
Physical Storage Media (Cont.)

● Magnetic-disk
● Data is stored on spinning disk, and read/written magnetically
● Primary medium for the long-term storage of data; typically stores entire
database.
● Data must be moved from disk to main memory for access, and written
back for storage
4 Much slower access than main memory (more on this later)
● direct-access – possible to read data on disk in any order, unlike
magnetic tape
● Capacities range up to roughly 1.5 TB as of 2009
4 Much larger capacity and cost/byte than main memory/flash memory
4 Growing constantly and rapidly with technology improvements (factor
of 2 to 3 every 2 years)
● Survives power failures and system crashes
4 disk failure can destroy data, but is rare

9.35
Physical Storage Media (Cont.)
● Optical storage
● non-volatile, data is read optically from a spinning disk using
a laser
● CD-ROM (640 MB) and DVD (4.7 to 17 GB) most popular
forms
● Blu-ray disks: 27 GB to 54 GB
● Write-one, read-many (WORM) optical disks used for archival
storage (CD-R, DVD-R, DVD+R)
● Multiple write versions also available (CD-RW, DVD-RW,
DVD+RW, and DVD-RAM)
● Reads and writes are slower than with magnetic disk
● Juke-box systems, with large numbers of removable disks, a
few drives, and a mechanism for automatic
loading/unloading of disks available for storing large volumes
of data

9.36
Physical Storage Media (Cont.)
● Tape storage
● non-volatile, used primarily for backup (to recover from disk
failure), and for archival data
● sequential-access – much slower than disk
● very high capacity (40 to 300 GB tapes available)
● tape can be removed from drive ⇒ storage costs much
cheaper than disk, but drives are expensive
● Tape jukeboxes available for storing massive amounts of
data
4 hundreds of terabytes (1 terabyte = 109 bytes) to even
multiple petabytes (1 petabyte = 1012 bytes)

9.37
Storage Hierarchy

9.38
Storage Hierarchy (Cont.)

● primary storage: Fastest media but volatile (cache, main


memory).
● secondary storage: next level in hierarchy, non-volatile,
moderately fast access time
● also called on-line storage
● E.g. flash memory, magnetic disks
● tertiary storage: lowest level in hierarchy, non-volatile, slow
access time
● also called off-line storage
● E.g. magnetic tape, optical storage

9.39

You might also like