Transcript Lab Session-II CS121 Summer
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 1
Web-Based Forms+Server Side Scripts Allow E-Commerce Interaction
2
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
3
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 4
Database Concepts: An example
Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999 5
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) 6
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 7
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 8
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 9
10
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 11
12
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 13
A Plain Binary Tree
14
A Binary Search Tree
15
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?
16
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 17
BST and Actual File
Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999 18
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 19
Network Database Model
Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999 20
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 21
Relational Database Model
Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999 22
Relational Database Model
Adapted for academic use from “Exploring The Digital Domain” by Abernethy Allen, ITP 1999 23
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 24
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 25
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 26
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 27
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 28
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 29
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.
30
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 31
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 32
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 33
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 34 design
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 35
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 36
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 37
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 38
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 39
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 40
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 41