lecture160505
Download
Report
Transcript lecture160505
DATABASE PROGRAMMING
Lecture on 16 – 05 – 2005
PREVIOUS LECTURE
QUIZ:
- Some students were very creative in transforming 2NF to 3NF.
Excellent!
- Some of the answers were not effective and seemed forcing to
decompose a table unnecessarily.
- Some students just copied their friends' answers. It's OK for Quiz but
not for exam! Remember this, in exam you will get 0.
NEWS
1. All lecture materials and Normalixation quiz marks are available on
http://192.168.1.1/teachers/adinugro/dp
DATABASE APPLICATION
A database application is a program that is used to manipulate data
contained in a database.
Application isolates users from the data in the database. Thus, users
should not know or care:
• which data elements are stored in what tables or columns,
• what data types are used, or
• how much storage is available.
Users should only care about:
• entering data correctly, or
• extracting data that is needed.
EVOLUTION OF DATABASE
APPLICATION
1. Networks
The advent of networks. Exchanging data in a network, lead to
'client-server architecture'.
2. The Internet
Exchanging data through some set of networking protocols, such
as email (SMTP/POP2/IMAP) and FTP.
3. The Web
Ability to break database application into modules, so users only
know or care about entering data and extracting data that is
needed.
4. Intranets
Simulates 'mini Internet' in an enterprise. Applying Internet
protocols in the intranet.
THREE-TIER MODEL
This model divides a database application into three sections or tiers.
Each tier receives data and performs a well-defined task upon it. If all
goes well, the tier then forwards the data; if an error occurs, it returns an
error to the data source.
Three-tier model can be described as follows:
1. Bottom Tier: Access to the database (MySQL, Oracle)
2. Middle Tier: Business Logic (JavaBean)
3. Top Tier: User Interface (JSP)
BOTTOM TIER
• This tier is the 'data-source'.
• It consist of the database engine, plus drivers and networking software
with which your application accesses the engine. For example, MySQL Connector J - TCP/IP.
• This tier receives instructions from the tier above it, executes them,
generates results (reply to those instructions or error), and return to the
tier above it
MIDDLE TIER
• Sometimes is also called as middleware.
• This tier is where the application business logic implemented.
• This tier receives instructions from the tier above it, compares with the
rules programmed into it, sends instructions to the bottom tier, waits for
reply from the bottom tier, forwards the reply from bottom tier to top tier.
• Example of rules in this tier: check whether the book is not borrowed,
then someone can borrow it.
TOP TIER
• The top tier holds the user interface, so sometimes also called
Presentation Logic as it is responsible for presentation of data.
• This tier displays instructions and data, waits for user interaction, then
forward the instruction to the middle tier.
BENEFITS OF THE THREETIER
• Easier Design
It will be easier for human being to think clearly about a complex
task by dealing with it one piece at a time.
• Easier Implementation
Each piece can be written and debugged separately.
• Reusability
As it is decomposed into modules, modules that perform the
same task should be able to be used repeatedly.
• Distributability
Each module can be distributed over a network.
EXAMPLE OF THE THREETIER
• Bottom Tier:
MySQL as database engine.
• Middle Tier:
PHP or JAVABEAN
• Top Tier:
HTML with CSS or Javascript
DRIVERS
In our previous discussion, we talk about accessing database directly.
However, it is becoming common that we have a driver between our
database engine and the application.
The most commonly used drivers are built around:
• Microsoft's Open Database Connectivity (ODBC), and
• Sun's Java Database Connectivity( JDBC).
ODBC
ODBC definition according to
Webpodia(http://www.webopedia.com/TERM/O/ODBC.html)
Stand for Open DataBase Connectivity, a standard database access method developed by the
SQL Access group in 1992.
The goal of ODBC is to make it possible to access any data from any application, regardless
of which database management system (DBMS) is handling the data.
ODBC manages this by inserting a middle layer, called a database driver, between an
application and the DBMS. The purpose of this layer is to translate the application's data
queries into commands that the DBMS understands.
For this to work, both the application and the DBMS must be ODBC-compliant -- that is,
the application must be capable of issuing ODBC commands and the DBMS must be
capable of responding to them.
ODBC(2)
Microsoft Definition
(http://msdn.microsoft.com/library/default.asp?url=/library/enus/odbc/htm/dasdkodbcoverview.asp) :
The Microsoft® Open Database Connectivity (ODBC) interface is a C
programming language interface that makes it possible for applications to access
data from a variety of database management systems (DBMSs).
The ODBC interface permits maximum interoperability — an application can
access data in diverse DBMSs through a single interface. Furthermore, that
application will be independent of any DBMS from which it accesses data. Users
of the application can add software components called drivers, which interface
between an application and a specific DBMS.
Why ODBC
• Portable Data Access Code
Available in many platforms.
Microsoft has made some enhancements to its ODBC.
Unix/Linux platform can take the same advantage using
UnixODBC
•Dynamic Data Binding
Easy to configure an application to use any ODBC compliant data
source.
No need to recompile application to change the data source
REFERENCES
• Michele Petrovsky, Linux Database Bible Chapter 12, Hungry
Minds.
• http://www.unixodbc.org