+ All Categories
Home > Documents > M1G505190 Introduction to Database Development 6. Building Applications.

M1G505190 Introduction to Database Development 6. Building Applications.

Date post: 30-Dec-2015
Category:
Upload: dustin-rice
View: 219 times
Download: 0 times
Share this document with a friend
Popular Tags:
22
M1G505190 Introduction to Database Development 6. Building Applications
Transcript
Page 1: M1G505190 Introduction to Database Development 6. Building Applications.

M1G505190

Introduction to Database Development

6. Building Applications

Page 2: M1G505190 Introduction to Database Development 6. Building Applications.

Databases and applications

Up to now you have been working directly with the tables and queries in a database

However, it’s unlikely that you would want the end-users of your database to work with those tables and queries

The users of the GCUTours system, for example, just want an easy way to book holidays

Introduction to Database Development 6. Building applications 2

Page 3: M1G505190 Introduction to Database Development 6. Building Applications.

Databases and applications

To be useful, a database usually needs to be part of an application. There are two main reasons for creating an application: to provide a user-friendly interface for getting

information into and out of the database to provide processing of information, or business

logic, over and above the capability of SQL queries

Introduction to Database Development 6. Building applications 3

Page 4: M1G505190 Introduction to Database Development 6. Building Applications.

Business logic

An example of a piece of business logic in the GCUTours system might be:

when a new booking is created, the system should update the value of the sales value for the appropriate package

Introduction to Database Development 6. Building applications 4

Page 5: M1G505190 Introduction to Database Development 6. Building Applications.

Different viewpoints on databases and applications

Introduction to Database Development 6. Building applications 5

Page 6: M1G505190 Introduction to Database Development 6. Building Applications.

RDBMS application

Uses tools provided by the RDBMS Form and report designers create the

interface forms and reports can be created as web

pages or as desktop applications A programming language built into the

RDBMS can be used to write business logic, e.g. Oracle PL/SQL

Introduction to Database Development 6. Building applications 6

Page 7: M1G505190 Introduction to Database Development 6. Building Applications.

Client-server application

Desktop client application written in a programming language such as C# or Java

Connects to a database server to store and retrieve data

Database server is usually on a separate computer which can be accessed over a network by many clients

Introduction to Database Development 6. Building applications 7

Page 8: M1G505190 Introduction to Database Development 6. Building Applications.

Web application

HTML web pages with code included which queries the database and allows results to be embedded in page

Needs a web application server Code written in a programming language

such as C# or Java Code to query database runs on a server and

HTML page with data is sent to web browser Suitable for very simple applications

Introduction to Database Development 6. Building applications 8

Page 9: M1G505190 Introduction to Database Development 6. Building Applications.

Enterprise application

Uses same technology as web application but designed for larger, more complex applications

Application is organised in layers/tiers, each with their own role, e.g. database access

Information is represented as classes and objects within the application, and passed to a database for long-term storage

Introduction to Database Development 6. Building applications 9

Page 10: M1G505190 Introduction to Database Development 6. Building Applications.

What they have in common

Forms allow users to enter information Reports or summaries of information are

presented to users User actions result in business logic being

carried out

Introduction to Database Development 6. Building applications 10

Page 11: M1G505190 Introduction to Database Development 6. Building Applications.

Application Design

Regardless of the tools used, applications must be carefully designed to allow the user to carry out the tasks associated with the use cases of the system

Users focus on tasks Should not be required to understand the

structure of the underlying database

Introduction to Database Development 6. Building applications 11

Page 12: M1G505190 Introduction to Database Development 6. Building Applications.

Application Design

The interface should: present the user with information in a way which

matches the task rather than the database gather information from the user which needs to

be stored An application is not just an interface to the

database Needs to have interface and business logic

implemented by writing code in a programming language

Introduction to Database Development 6. Building applications 12

Page 13: M1G505190 Introduction to Database Development 6. Building Applications.

Database servers

In many applications the database needs to be shared by many clients at the same time.

Databases which need to be accessed concurrently are located on database servers Software running on the same computer as the

client, or on a separate computer which clients access over a network

Sometimes the computer which hosts the database is known as a database server

Introduction to Database Development 6. Building applications 13

Page 14: M1G505190 Introduction to Database Development 6. Building Applications.

Database servers

Many popular RDBMSs are designed to work in this client-server mode e.g. Oracle, MySQL and Microsoft SQL Server

SQL Server Compact and Microsoft Access are designed mainly to be embedded within a single application

Not suitable for large-scale applications However, the principles of database design

and the SQL language are the same

Introduction to Database Development 6. Building applications 14

Page 15: M1G505190 Introduction to Database Development 6. Building Applications.

Web applications with WebMatrix

Demo

Introduction to Database Development 6. Building applications 15

Page 16: M1G505190 Introduction to Database Development 6. Building Applications.

Reports

A report should give an easily readable summary of data in a database

Often present information to company managers

For example, monthly sales reports Some RDBMSs and development tools have

report generators Other specialised reporting tools available,

e.g. Crystal Reports

Introduction to Database Development 6. Building applications 16

Page 17: M1G505190 Introduction to Database Development 6. Building Applications.

Report example

Introduction to Database Development 6. Building applications 17

Page 18: M1G505190 Introduction to Database Development 6. Building Applications.

Connecting to a database

In the WebMatrix examples we have seen here, the database is a SQL Server Compact database which is included in the application

Code simply opens the database file. var db = Database.Open("gcutourswm");

In many cases, however, applications which use databases are separate from the application

Need to connect to database server

Introduction to Database Development 6. Building applications 18

Page 19: M1G505190 Introduction to Database Development 6. Building Applications.

Information needed to make a connection

The database driver – a piece of software which provides an interface between the application language (e.g. Java, Visual Basic) and a specific type of database (e.g. Access, Oracle, JavaDB)

The network address or name of the computer where the database is located

The name of the specific database on that computer (e.g. the gcutours database)

Introduction to Database Development 6. Building applications 19

Page 20: M1G505190 Introduction to Database Development 6. Building Applications.

Database connections

Connection details often combined into a string of characters called the database URL

It’s possible to connect to just about any type of database from just about any programming language, as long as you have a suitable database driver

Once the connection has been made the application usually communicates with the database by sending SQL queries

Introduction to Database Development 6. Building applications 20

Page 21: M1G505190 Introduction to Database Development 6. Building Applications.

Connecting to a JavaDB database

The GCUTours case study application connects to a JavaDB database

The following lines of Java code sets up the connection information In this case, the database is on the same

computer as the application, so the network name is localhost

Introduction to Database Development 6. Building applications 21

Page 22: M1G505190 Introduction to Database Development 6. Building Applications.

That’s all for now, but...

Some database topics to be covered in other modules include: Entity-relationship modelling More SQL Other database systems (e.g. Oracle) Database programming Database administration and security Transactions Handling large numbers of users Databases and object-oriented languages...

Introduction to Database Development 6. Building applications 22


Recommended