1 applications of computers 4 we talk about databases and their implementation 4 implementation of...

41
1 Applications of Computers We talk about databases and their implementation Implementation of databases involves trees therefore we introduce trees E-commerce (BTC) allows web-based access of inventory and orders Where are the inventory and orders stored? In the corporate database

Post on 20-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

1

Applications of Computers

We talk about databases and their implementation

Implementation of databases involves trees therefore we introduce trees

E-commerce (BTC) allows web-based access of inventory and orders

Where are the inventory and orders stored? In the corporate database

Page 2: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

2

Web-Based Forms+Server Side Scripts Allow E-Commerce Interaction

Page 3: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

3

Databases

Databases are implemented in many forms on all possible platforms

Think of flight reservation, credit card accounts, registration for a semester, payrolls, IRS records, SS records,……

We interact almost daily with at least one database in our day to day activities

A database contains records that contain information

Page 4: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

4

Database Concepts

A database is usually a large collection of information

A DBMS (Database Management System) is implemented to retrieve information from a database in an effective and efficient way

Database itself is implemented in files that contain records. Each record contains data fields having item-specific information

Page 5: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

5

Database Concepts: An example

Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999

Page 6: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

6

Use of Indices in Searching

If you store information in the way shown, you may want to select a specific person’s record

In order to select the appropriate record, you have to spell out the last name of a person

The last name serves as a search index as all the records matching this last name can be retrieved (http://www.switchboard.com)

Page 7: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

7

Use of Indices in Searching

The database files searched this way are called Indexed files

Indexed files can be implemented with Binary Search Tree (BST)

The BST nodes contain the data values of the indexed fields e.g. last names

Additionally, a link is provided to the actual file

Page 8: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

8

Trees

A Binary Search Tree is a data structure that is very useful in search applications

A natural tree has a root from which everything starts

It has branches and leaves Think about your family tree Look at an organization chart for a company

Page 9: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

9

Trees

Think about the way directories are organized in your computer

There is a root directory C:\ Then there are sub-directories Sub-directories can also have further sub-

directories This is the directory tree

Page 10: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

10

Page 11: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

11

Binary Tree

A binary tree is a tree in which each node can have just two children

Binary tree is easy to sketch Start with a root node (root is at the top as opposed

to natural trees) One child is shown on left and the other one is

shown on right The children can also have maximum two children

each

Page 12: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

12

Page 13: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

13

Binary Search Tree

A binary search tree is a specialized type of tree

In BST, a node can have only two children (right and left)

The value of the left child is LESS than the value of the parent node

The value of the right child is MORE than the value of the parent node

Page 14: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

14

A Plain Binary Tree

Page 15: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

15

A Binary Search Tree

Page 16: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

16

Class Exercise

Make a BST from the list shown. Assume that the numbers are to be entered into the BST from left to right. The first number will be taken as the root.

[4,2,1,3,6,5,7] Assume that we are searching for two specific

numbers in this tree. The numbers are 6 and 9 How many comparisons are needed to finish the

search?

Page 17: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

17

Use of Indices in Searching

Let us consider the implementation of indices into database files

Indexing can be implemented with our friendly BST

The BST nodes contain the data values of the indexed fields e.g. last names

Additionally, a link is provided to the actual file

Page 18: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

18

BST and Actual File

Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999

Page 19: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

19

Network Database Model

The need for a convenient query language and interaction developed for applications beyond payrolls and inventory databases

The programmers worked to link records in separate files together

This model is called “network database model” because it uses a network of links between files

Programmers must be aware of physical organization of files and links

Page 20: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

20

Network Database Model

Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999

Page 21: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

21

Relational Database Model

Relational database model was introduced in late 70’s

This model gives a more conceptual view of the database

It establishes a logical relationship between records using one field as a logical link

The information needed to employ relational database is intuitive and does not include physical disk addresses

Page 22: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

22

Relational Database Model

Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999

Page 23: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

23

Relational Database Model

Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999

Page 24: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

24

Comparing Both Models

Network model is much faster than the relational model because the links are physical disk addresses

Relational model is more flexible so it can handle different types of queries

RDBMS performs search after search to retrieve information from different files

The tradeoff is flexibility vs speed

Page 25: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

25

Airline Reservation System

When we reserve a seat in a flight, the agent interacts with the database

The types of queries are limited to a few options (class, fare, availability, restrictions)

There are thousands of queries in progress at any given time

We want the database to be fast and efficient

Page 26: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

26

Player Performance Statistics

During televised games, comments are made on certain players

For example, Mark has a batting average of 0.407 against the Braves, etc.

This information is obtained on the fly from a database of player performance

We want this database to be flexible as many different types of queries are allowed

Page 27: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

27

Example of a Central Database

AFIS is FBI’s Automated Fingerprint Identification System

It provides a national database of digitized fingerprints

California requires thumb prints on driver licenses

International travelers may be provided with smart cards and checked with hand identification

Page 28: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

28

Creating Your Own Database

Large databases cannot be implemented on personal computers

For PC’s, the relational database model is more appropriate as the number of data items is small and speed is not a primary concern

MS-Access is used to implement databases on PC platform

Page 29: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

29

Defining the Database Structure

Initial work involves deciding about the contents of individual fields and overall organization

Each field can contain only one type of data Related data files are called tables A table is an object that stores data in records

(rows) and fields (columns). The data is, for example, about a customer or an employee

Page 30: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

30

A Table in MS-Access

In table Design view, you can create an entire table from scratch, or add, delete, or customize an existing table's fields.

In table Datasheet view, you can add, edit, or view the data in a table. You can also check the spelling and print your table's data, filter or sort records, change the datasheet's appearance, or change the table's structure by adding or deleting columns.

Page 31: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

31

Databases in MS-Access

In order to facilitate entry of data, MS-Access provides forms. Forms can be designed through the Forms tab

Queries and Reports can be created to interact with the database and extract data that meets certain search requirements or it has been sorted. Reports generate nice formatted display of the output data

Page 32: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

32

Forming Queries

Queries are requests for specific information that meet a certain criteria

Queries are written in a query language Normally, queries act as the only user

interface in a database Store cashier, bank teller clerk, payroll data

entry operators….all use query language to interact with the databases

Page 33: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

33

Forming Queries

SQL (“sequel”) stands for structured query language and it is a de-facto standard

SQL queries are simple and you do not need to know programming to form these queries

For example, to show all items whose value exceeds $200 in the inventory database:

SELECT Item-Name FROM Inventory WHERE Value>$200

Page 34: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

34

Natural Language Queries

Work is in progress to have a natural language query system

For example, the above question could be re-phrased as “Find the item names from inventory whose value exceeds $200”

One of the search engines on the web, AltaVista, supports natural language queries

QBE(Query-by-example) is also popular and MS-Access uses it by having criteria field in query design

Page 35: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

35

The Web Interface

Web and database technologies are merging providing exciting opportunities

(Think about the e-commerce, it has become possible for you to book a flight, browse through items and buy things online)

“Web database front-ends” provide forms using which users can make selections as per their criteria and interact with the database

Page 36: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

36

Web Interface

Web interface supports http (hyper text transfer protocol) that runs over TCP/IP

This protocol supports transfer of text, graphics and applets, thus opening a lot of possibilities

Industry is interested in small gadgets running http protocol that can exchange information in a secure way

Page 37: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

37

E-Commerce

Almost all major companies have their homes on the web, mainly for advertising

Companies were reluctant towards e-commerce but now it is picking up

The most revolutionary e-commerce is between business and customer

Business-business e-commerce is already developed

Page 38: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

38

E-Commerce Requirements

E-commerce between customer and business requires several functions

For example, auction sites should have the capability to track bids by various people

Also, multi-vendor selling sites should support tracking of multiple companies

Transactions between customers and the e-commerce site should be safe and secure

Page 39: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

39

The Credit Card Concerns

Almost all e-commerce sites offer credit card support

A customer who wants to buy something pays with credit card

The credit card information is transmitted through the public network and it can be tapped by someone in the middle

Page 40: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

40

Encryption and Data Security

For successful e-commerce, we must ensure that the sensitive data has been encrypted and secured

Encryption transforms the data using a “key” into a value that is meaningless in its normal form

This encrypted value can only be decrypted by authorized agency or person

Page 41: 1 Applications of Computers 4 We talk about databases and their implementation 4 Implementation of databases involves trees therefore we introduce trees

41

Securing the Connection

For protecting the credit card info, it is transmitted under SSL (secure sockets layer)

It means the card info is encrypted and it is very difficult to break the code by an intruder

Surprisingly, the misuse of the card info by employees is a more serious concern