CMSC 100 E-Commerce and Databases Professor Marie desJardins Thursday, October 25, 2012

advertisement
CMSC 100
E-Commerce and Databases
Professor Marie desJardins
Thursday, October 25, 2012
Adapted from instructor slides for Schneider & Gerstung
E-Commerce and Databases
1
Thu 10/25/12
Overview


E-commerce:

Online business model

General transaction model/steps

Security issues

Website content and design
Databases:

Relational database model

Database operation

SQL (Structured Query Language)
E-Commerce and Databases
2
Thu 10/25/12
E-Commerce
E-Commerce and Databases
Thu 10/25/12
E-Commerce


The World Wide Web enables businesses to communicate with
customers

Advertising

Follow-up support

Sales to consumers

Sales to other businesses

Non-sales transactions (statements and bill pay)
E-commerce: Financial transactions (sales) entirely through the Web
and Internet
E-Commerce and Databases
4
4
Thu 10/25/12
Costs of E-Commerce


Risks of moving online

Same customers move from in-store to online

Face new competition online

Existing customers don’t need/want online store

Employee resistance
Costs of moving online

Computer equipment and infrastructure

Hire personnel to manage Web site

Legal expertise required: protect your intellectual property, regulations
online, customer privacy
E-Commerce and Databases
5
5
Thu 10/25/12
E-Commerce Model

Customer learns of your site and goes there

Identify return customers and personalize site

Provide secure environment for making purchase

Process payment:


Communicate with accounting and credit company
Fulfill order:

Update inventory

Contact shipping system and shipping company

Arrange pick up and delivery to customer
E-Commerce and Databases
6
6
Thu 10/25/12
E-Commerce and Databases
7
7
Thu 10/25/12
Cookies

Identify return customers and personalize site

Require user to register and log in


Connects to database with your past history on the site
What’s a cookie, really?

Small text file containing information about user

Leave it behind & look at it later

Allows continuity between one page of a site and another

(Relatively) harmless
E-Commerce and Databases
8
8
Thu 10/25/12
Security Issues
Provide secure environment for making purchase

Encryption: ensure sensitive information is encrypted for
transmission

Authentication: verify that your web site is legitimate

Spoofing: impersonating a legitimate business

Steal money

Steal identities
E-Commerce and Databases
9
9
Thu 10/25/12
Website Design Criteria

Design principles






Aesthetically pleasing
Highlights new products
Organized for natural shopping habits
Easy to navigate
 Provide site map or navigation bar
 No more than four clicks from one page to another
Encourages browsing and targeted searching
Supports multiple platforms (OSs) and browsers
E-Commerce and Databases
10
10
Thu 10/25/12
Website Contents

Easy way to find contact information

Clear privacy policy

FAQ page and link to customer service

Customer reviews or forums

Form to subscribe to newsletter

Suggestion box

News and press releases
E-Commerce and Databases
11
11
Thu 10/25/12
Databases
E-Commerce and Databases
Thu 10/25/12
Databases

Databases store large amounts of data

Businesses require databases for:


Inventory, personnel, customers, suppliers, financials
Data organization

Bits and bytes: computer data basic pieces

Field: one meaningful piece of information

Record: a set of related fields

Data file: a set of related records

Database: a set of related data files
E-Commerce and Databases
13
13
Thu 10/25/12
Database Organization
E-Commerce and Databases
14
14
Thu 10/25/12
Database Organization
(cont.)
Data files are often represented as tables

Records are rows, fields are columns
E-Commerce and Databases
15
15
Thu 10/25/12
Database Example
Rugs-For-You example, employee record

Record = one employee

Each field has

A field name, a category, with a specific type

A value for this record’s employee
E-Commerce and Databases
16
16
Thu 10/25/12
Relational Databases

Database management system (DBMS)


Manages files in a database
Relational database model: Files are 2D tables

Entity: Distinguishable component of system

Example: an employee, a customer, a rug for sale

Tuple: Row of a relational table

Attribute: Category of a field

Primary key: Attribute(s) that uniquely identify a tuple

Relation: Set of tuples (i.e., a table)
E-Commerce and Databases
17
17
Thu 10/25/12
Database Example
Exercise: Name an entity, a tuple, an attribute, a relation,
and a primary key
E-Commerce and Databases
18
18
Thu 10/25/12
Database Example (cont.)
Exercise: Is there a primary key? What do you think the
purpose of the EmployeeID (a foreign key) is?
E-Commerce and Databases
19
19
Thu 10/25/12
Foreign Keys

Multiple tables may contain related data


Example: Insurance policies for Rugs-For-You
Foreign key: An attribute in one table that is key in another

Connects data in one table with another

Example: EmployeeID
E-Commerce and Databases
20
20
Thu 10/25/12
Database Operations

Project: Select a subset of the attributes from a set of tuples

Restrict: Select only those tuples that meet specified criteria

Join: Combine tuples from different tables
E-Commerce and Databases
21
21
Thu 10/25/12
ID
LastName
FirstName
Birthdate
PayRate
HoursWorked
116
Kay
Janet
3/29/1976
$16.60
94
123
Perreira
Francine
8/15/1989
$8.50
185
149
Takasano
Frederick
5/23/1986
$12.35
250
171
Kay
John
11/17/1974
$17.80
245
165
Honou
Morris
6/9/1993
$6.70
53
E-Commerce and Databases
EmployeeID
PlanType
DateIssued
171
B2
10/18/1994
171
C1
6/21/2002
149
B2
8/16/2008
149
A1
5/23/2006
149
C2
12/18/2011
22
Thu 10/25/12
SQL
(Structured Query Language)

Project: Select a subset of the attributes from a set of tuples
SELECT ID, LastName, FirstName, PayRate
FROM Employees

Restrict: Select only those tuples that meet specified criteria
WHERE LastName = ‘Takasano’
AND FirstName = ‘Frederick’

Join: Combine tuples from different tables
FROM Employees, InsurancePolicies
…
AND ID = EmployeeID;
E-Commerce and Databases
23
23
Thu 10/25/12
ID
LastName
FirstName
Birthdate
PayRate
HoursWorked
116
Kay
Janet
3/29/1976
$16.60
94
123
Perreira
Francine
8/15/1989
$8.50
185
149
Takasano
Frederick
5/23/1986
$12.35
250
171
Kay
John
11/17/1974
$17.80
245
165
Honou
Morris
6/9/1993
$6.70
53
SELECT ID, LastName, FirstName, PayRate
FROM Employees
E-Commerce and Databases
ID
LastName
FirstName
PayRate
116
Kay
Janet
$16.60
123
Perreira
Francine
$8.50
149
Takasano
Frederick
$12.35
171
Kay
John
$17.80
165
Honou
Morris
$6.70
24
Thu 10/25/12
ID
LastName
FirstName
Birthdate
PayRate
HoursWorked
116
Kay
Janet
3/29/1976
$16.60
94
123
Perreira
Francine
8/15/1989
$8.50
185
149
Takasano
Frederick
5/23/1986
$12.35
250
171
Kay
John
11/17/1974
$17.80
245
165
Honou
Morris
6/9/1993
$6.70
53
SELECT ID, LastName, FirstName, PayRate
FROM Employees
WHERE LastName = ‘Kay’
E-Commerce and Databases
ID
LastName
FirstName
PayRate
116
Kay
Janet
$16.60
171
Kay
John
$17.80
25
Thu 10/25/12
ID
LastName
FirstName
Birthdate
PayRate
116
Kay
Janet
123
Perreira
Francine
149
Takasano
Frederick
3/29/1976
94
EmployeeID $16.60 PlanType
8/15/1989
$8.50 B2 185
171
5/23/1986
$12.35 C1 250
171
171
Kay
John
165
Honou
Morris
11/17/1974
149
6/9/1993
149
HoursWorked
DateIssued
10/18/1994
6/21/2002
$17.80 B2 245
$6.70 A153
8/16/2008
5/23/2006
149 PayRate, PlanType,
C2
12/18/2011
SELECT ID, LastName, FirstName,
DateIssued
FROM Employees, InsurancePolicies
ID
Last
Name
First
Name
Birth
date
Pay
Rate
Hours
Worke
d
Employee
ID
Plan
Type
Date
Issued
116
Kay
Janet
3/29/1976
$16.60
94
171
B2
10/18/1994
123
Perreira
Francine
8/15/1989
$8.50
185
171
B2
10/18/1994
149
Takasano
Frederick
5/23/1986
$12.35
250
171
B2
10/18/1994
171
Kay
John
11/17/1974 $17.80
245
171
B2
10/18/1994
165
Honou
Morris
6/9/1993
53
171
B2
10/18/1994
E-Commerce and Databases
$6.70
26
Thu 10/25/12
ID
LastName
FirstName
Birthdate
PayRate
HoursWorked
116
Kay
Janet
3/29/1976
$16.60
94
123
Perreira
Francine
8/15/1989
$8.50
185
149
Takasano
Frederick
5/23/1986
$12.35
250
171
Kay
John
11/17/1974
$17.80
245
165
Honou
Morris
6/9/1993
$6.70
53
SELECT ID, LastName, FirstName, PayRate, PlanType, DateIssued
FROM Employees, InsurancePolicies
WHERE LastName = ‘Kay’ and ID = EmployeeID
ID
LastNa
me
FirstNa
me
PayRa
te
116
Kay
Janet
$16.60
171
Kay
John
$17.80
E-Commerce and Databases
EmployeeID
PlanType
DateIssued
171
B2
10/18/1994
171
C1
6/21/2002
149
B2
8/16/2008
149
A1
5/23/2006
149
C2
12/18/2011
27
Thu 10/25/12
More SQL Examples

What do these queries do?
SELECT ID, LastName, FirstName, Payrate, HoursWorked
FROM Employees
WHERE LastName = ‘Perreira’;
SELECT *
FROM Employees
ORDER BY ID;
SELECT *
FROM Employees
WHERE PayRate > 15.00
E-Commerce and Databases
28
28
Thu 10/25/12
SQL Examples (cont.)

What does this query do?
SELECT LastName, FirstName, PlanType
FROM Employees, InsurancePolicies
Where LastName = ‘Takasano’
AND FirstName = ‘Frederick’
AND ID = EmployeeID;
E-Commerce and Databases
29
29
Thu 10/25/12
E-Commerce and Databases
30
30
Thu 10/25/12
Design and Maintenance
Issues

Database integrity: As data is added/removed, must maintain:

Entity integrity: No primary key can be missing

Data integrity: Values must match category constraints (e.g., be a valid
pay rate)

Referential integrity: Foreign keys must match some primary key in
related table

Efficiency: Disk defragmentation and query optimization are needed
to retrieve data quickly

Distributed data: Data may be stored across computer network;
access may require network transmission
E-Commerce and Databases
31
31
Thu 10/25/12
Database Exercise


Design a relational database structure for course scheduling:

Course numbers, names, and descriptions

Time and location of a course in a given semester

What classes a student is taking/has taken, and their grades

What classes an instructor is teaching/has taught
Write SQL queries to find out:

A student’s schedule in a given semester

What classes a particular student has taken from a particular instrutor

The students who are taking a class this semester in a particular classroom
E-Commerce and Databases
32
Thu 10/25/12
Download