CS 338: Computer Applications in Business: Databases (Fall 2014)
welcome to
CS 338: Computer Applications
in Business: Databases
Fall 2014
Eyhab Al-Masri
1
Course Information
Term
Class No.
Section
Lectures Location
5712
LEC 001
DWE 1501
Fall 2014
Lectures Time
Wednesdays 10:00 am - 11:20 am
Fridays
10:00 am - 11:20 am
Instructor Name
Office
Email
Office Hours
Eyhab Al-Masri, PhD
DC 2555B
[email protected]
Wednesday 11:40 am 1:00 pm
TA Name
Office
Email
Office Hours
Mina Farid
TBA
[email protected]
TBA
Abhishek Singhi
TBA
[email protected]
TBA
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
CS 338: Computer Applications in Business: Databases (Fall 2014)
about this course
Course Website
UW LEARN Management System
http://learn.uwaterloo.ca
Textbook
Fundamentals of Database Systems
Authors: Ramez Elmasri & Shamkant Navathe
Publisher: Addison-Wesley (2010)
6th Edition (5th edition may also work)
ISBN: 0136086209
Course Evaluation
First midterm exam (Oct 10, in class)
25%
Second midterm exam (Nov 12, in class)
25%
Final Exam (TBA)
50%
Clicker Correctness [bonus factor of 4%]
4%
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
CS 338: Computer Applications in Business: Databases (Fall 2014)
Course Content
Introduction to database systems
Relational data model
SQL (ad hoc queries)
Relational algebra
Views and view management
Entity-Relationship (ER) model
Extended ER model
Mapping ER models to relational
DBMS architecture
Transactions
Database security and privacy
Distributed databases
Data warehouses
Data analytics
Relational database principles
Data modeling
DBMS functionality
Related topics
5
Assignments
Three/four assignments throughout the term
Sample solutions released on due date
Goal is to give you practice with material in order
to provide self-assessment and guidance
Assignment performance not part of evaluation
You need not polish a submission
You can work alone or with others
You can seek help from TAs
You will have more trouble learning the material (and
passing the course) if you do not attempt the assignments
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
CS 338: Computer Applications in Business: Databases (Fall 2014)
Clickers
Wireless student response system
Active learning lasts longer than passive listening
Clicker questions allow you to show me what you understand
without having to raise your hand and identify yourself
You will get some credit up to 4% bonus for correct answers
(based on best 80%)
Bookstore ~$42 (return for ~$20)
Used $30 when available
Be sure to register your clicker here:
http://www.student.cs.uwaterloo.ca/~pkates/uw-clicker.html
Image Source: http://www1.iclicker.com/purchase-response-devices
Using Your Clicker
Turn it on:
Press the ON/OFF button. A solid blue light should appear next to the top Power button. If your clicker
came wrapped in packaging, pull out the small plastic tab on the back to activate the batteries.
Change the frequency to AA:
The instructions on the back of your clicker say
Press and hold the ON/OFF button until the top blue Power light flashes. Enter the 2 letter frequency code (AA).
The code for each classroom (AA for DWE 1501) is posted near the podium at the front of the class.
When a clicker is turned off it forgets any changes in frequency and the clicker frequency is again AA
when the clicker is turned on.
How do I know if my vote has been received?
When the receiver acknowledges a vote, the Vote Status light on the clicker (the third light) will flash
green for a moment. If it flashes red instead, then either the voting period hasn't started, or the receiver
didn't respond to your vote. In the latter case, change the frequency of your clicker if necessary and
vote again. Raise your hand for assistance if you don't see a green response.
Can I change my vote/choice?
Yes. While the voting process is active, you can vote as often as you like. Only your last (most recent)
choice/vote is recorded.
8
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
CS 338: Computer Applications in Business: Databases (Fall 2014)
Summary
Be sure to check the course website regularly
http://learn.uwaterloo.ca
Material builds on itself
Like other courses in Math
Initial lectures focus on terminology and background knowledge
May be an overwhelming amount of details
Dont fall behind!
If you have questions or concerns, please send me an email or talk to any of the
TAs
I am always open to suggestions and recommendations
Do not cause a distraction
9
Why Take A Database Course?
Database systems are at the core of Computer Science,
Scientific Computing, Business, IT, Engineering, among
many other disciplines
They are important to our society
Topic is intellectually rich
Good to have it on your resume
Easy to construct and use?
This course is designed primarily to meet the needs of
students who are interested in the business or public
sector of the economy. The course presents methods used
for the storage, selection, and presentation of data.
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
10
CS 338: Computer Applications in Business: Databases (Fall 2014)
Why Take A Database Course?
at the core of many disciplines
Database systems have become in recent years an essential
component
Daily life activities involve some interaction with a database
Shift in corporate strategies (i.e. standalone applications to
Web applications)
Need for database technology has increased
significantly
Web: vast pool of information
Examples:
Search engines, Wikis, Web Services, Electronic Commerce, Social
Networks, etc
11
Why Take A Database Course?
they are important to our society
Knowledge is power Sir Francis Bacon
12
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
CS 338: Computer Applications in Business: Databases (Fall 2014)
Why Take A Database Course?
topic is intellectually rich
Information Representation
Database modeling/design
Languages and Data Queries
Complex queries
Concurrency Control
Controlling concurrent access to information
Data Mining
Discovering patterns in data
Data Storage
Software & hardware that can fit large amounts of data
13
Why Take A Database Course?
good to have it on your resume
Database systems are applied across many areas
Electrical Engineering
Software Development
Mechanical Engineering
Computer Science
Science
Business
among many others
Valuable in situations such as
Use database (DB) terminology knowledgeably
Understand DB concepts that arise in the workplace
Interact with (direct, understand) IT personnel
Understand technical articles involving DB technology
Discuss DB concepts in a job interview
14
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
CS 338: Computer Applications in Business: Databases (Fall 2014)
Why Take A Database Course?
easy to construct and use?
Developing a database may involve a great amount of
work
Good News:
This is an introductory course
Course workload is balanced throughout the semester
15
Databases and
Database Users
Chapter 1
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some material
adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
Rice University Data Center
CS 338: Computer Applications in Business: Databases (Fall 2014)
what is a database?
17
Introduction
Database
Collection of related data
Data
known facts that can be recorded and that have implicit meaning
A database has the following implicit properties
Miniworld or universe of discourse (UoD)
Represents some aspect of the real world
Changes in the miniworld are reflected in the database
Logically coherent collection of data with inherent meaning
Random assortment of data cannot be referred to as database
Designed, built and populated with data for a specific purpose
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
CS 338: Computer Applications in Business: Databases (Fall 2014)
Introduction
Example of a large commercial database
Amazon.com, eBay, Facebook, Twitter
Database Management System (DBMS)
Collection of interrelated data and programs that enable users to
create and maintain a database
DBMS is a general-purpose software system that facilitates the
processes of defining, constructing, manipulating, and sharing
databases among various users and applications
Allows multiple users/programs to access and manipulate DB
concurrently
Protects DB against unauthorized access and manipulation
Provides means to evolve DB and program behaviour as requirements
change over time
Introduction
Basic Functions of DBMS
Defining a database
Specify the data types, structures, and constraints of the data to be
stored
Uses a Data Definition Language (DDL)
Meta-data
Database definition or descriptive information
Stored by the DBMS in the form of a database catalog or dictionary
Constructing a database
Process of storing data on some storage medium controlled by the
DBMS
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
10
CS 338: Computer Applications in Business: Databases (Fall 2014)
Introduction
Basic Functions of DBMS
Manipulating a database
Query and update the database miniworld
Generate reports
Uses Data Manipulation Language (DML)
Sharing a database
Allow multiple users and programs to access the database
simultaneously
Introduction
Basic Functions of DBMS
Populating a database
Inserting data to reflect the miniworld
Application program
Accesses database by sending queries to DBMS
Query
Causes some data to be retrieved
e.g. retrieve bank account balance
Transaction
May cause some data to be read and some data to be written into the
database
e.g., buying a product, transferring funds
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
11
CS 338: Computer Applications in Business: Databases (Fall 2014)
Introduction
Basic Functions of DBMS
Protecting a database
System protection
against hardware or software malfunction (i.e. crashes)
Security protection
against unauthorized or malicious access
Maintaining a database
Allow the system to evolve as requirements change over time
An Example
UNIVERSITY database
Information concerning students, courses, and grades in a university
environment
Data records
STUDENT
COURSE
SECTION
GRADE_REPORT
PREREQUISITE
Define structure of each type of data record by
specifying data elements to include and data
type for each element
String (sequence of alphabetic characters)
Numeric (integer or real)
Date (year or year-month-day)
Monetary amount
etc.
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
12
CS 338: Computer Applications in Business: Databases (Fall 2014)
An Example
An Example
Simplified Database System Environment
Structured Query
Language (SQL)
Data Manipulation
Language (DML)
Data Definition
Language (DDL)
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
13
CS 338: Computer Applications in Business: Databases (Fall 2014)
An Example
To construct the UNIVERSITY database
Store data to represent each student, course, section, grade report,
and prerequisite as a record in appropriate file
Define relationships among the records
Example: record for Smith in the STUDENT file is related to two
records in the GRADE_REPORT file
Specifies Smiths grades in two sections or courses
Database manipulation involves querying and updating
An Example
Examples of queries:
Retrieve the transcript
a list of all courses and grades of Smith
List the names of students who took the section of the Database
course offered in fall 2008 and their grades in that section
List the prerequisites of the Database course
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
14
CS 338: Computer Applications in Business: Databases (Fall 2014)
An Example
Examples of updates:
Change the class of Smith to sophomore
Create a new section for the Database course for this semester
Enter a grade of A for Smith in the Database section of last
semester
Queries and updates must be specified precisely in the query
language of the DBMS before they can be processed
An Example
Phases for Designing a Database
Phases for designing a database:
Requirements specification and analysis
Documented in details
Conceptual design
Represented and manipulated using some computerized tools
Logical design
Expressed in a data model (i.e. Relational Data Model)
Physical design
Further specifications are provided for storing and accessing the database
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
15
CS 338: Computer Applications in Business: Databases (Fall 2014)
Before Database Approach
Traditional File Approach
Traditional file processing
Each user defines and implements the files needed for a specific
software application
System stores permanent records in various files
it needs different programs to extract records from, and add records to,
the appropriate files
Before Database Approach
Traditional File Approach
Example
Registrar
Office Files
Accounting
Office Files
Registrar Office
Application
.
.
.
Accounting
Office
Application
.
.
.
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
Registrar
Office Users
Accounting
Office Users
16
CS 338: Computer Applications in Business: Databases (Fall 2014)
Before Database Approach
Traditional File Approach
Disadvantages
1. Uncontrolled Redundancy & data inconsistency
No form of supervision that can coordinate data operations
Poor Enforcement of Standards
2.
Data names, formats, constraints, etc..
are not standardized across an organization
Before Database Approach
Traditional File Approach
Disadvantages
3. Limited data sharing
Each application has access only to its files (i.e. other
applications do not have access to these files)
Program-Data Dependency
4.
Any change to structure causes change
in all programs accessing that file
Description of files and data are
embedded within an application
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
17
CS 338: Computer Applications in Business: Databases (Fall 2014)
Database Approach
Database approach
Overcomes the limitations of the traditional file approach
Single repository maintains data that is defined once and then
accessed by various users
Main characteristics of database approach
1.
Self-describing nature of a database system
2.
Insulation between programs and data, and data abstraction
3.
Support of multiple views of the data
4.
Sharing of data and multiuser transaction processing
Database Approach
Example
Registrar Office
Application
.
.
.
Accounting
Office
Application
.
.
.
Registrar
Office
Users
Common
Shared
Database
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
Accountin
g Office
Users
18
CS 338: Computer Applications in Business: Databases (Fall 2014)
A DBMS in the Database Approach allows
1.
2.
3.
4.
5.
6.
7.
8.
9.
Persistence of data
Transaction control
Concurrency control
Recovery control
Querying
Integrity control
Data security
Version control
Performance tuning
Characteristics of database approach
Self-Describing Nature of a Database System
Database system contains complete definition of structure
and constraints
This information (called meta-data) is stored in the DBMS catalog
i.e. structure of each file, type and storage format of each data item,
various constraints on data
Database catalog used by:
DBMS software
Database users who need information
about database structure
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
DBMS software is
not written for a
specific database
application
19
CS 338: Computer Applications in Business: Databases (Fall 2014)
Characteristics of database approach
Self-Describing Nature of a Database System
Characteristics of database approach
Insulation Between Programs and Data
Database systems have Program-data independence
Structure of data files is stored in DBMS catalog separately
from access programs
Changes made to the structure of the database does not necessarily
require changes to the programs (i.e. add new columns)
Program-operation independence
Some types of database systems enable definitions of operations on
data as part of database definitions
Operations are specified in two parts:
Interface (or signature) includes operation name and data types of its
arguments
Implementation (or method) can be changed without affecting the interface
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
20
CS 338: Computer Applications in Business: Databases (Fall 2014)
Characteristics of database approach
Insulation Between Programs and Data
The characteristic that allows program-data independence
and program-operation independence is called data
abstraction
DBMS provides users with conceptual representation of
data
Does not include many of the details of how data is stored or how
operations are implemented
Data model
Type of data abstraction used to provide conceptual representation
It uses logical concepts such as objects, their properties, and their
interrelationships
Hides implementation and storage details
Characteristics of database approach
Support of Multiple Views of the Data
View
Subset of the database, or
Contain virtual data derived from the database files but is not
explicitly stored
Multiuser DBMS
Users have a variety of distinct applications
Must provide facilities for defining multiple views
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
21
CS 338: Computer Applications in Business: Databases (Fall 2014)
Characteristics of database approach
Support of Multiple Views of the Data
Characteristics of database approach
Sharing of Data & Multiuser Transaction Processing
Allow multiple users to access the database at the same
time
Example assigning seats for airline reservation systems
Concurrency control software
Ensure that several users trying to update the same data do so in a
controlled manner
Result of the updates is correct
Online transaction processing (OLTP) application
Ensure that concurrent transactions operate correctly and efficiently
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
22
CS 338: Computer Applications in Business: Databases (Fall 2014)
Characteristics of database approach
Sharing of Data & Multiuser Transaction Processing
Transaction
Definition: executing program or process that includes one or more
database accesses (i.e. reading or updating records)
DBMS must enforce some properties
Isolation property
Each transaction appears to execute in isolation from other transactions
Atomicity property
Either all the database operations in a transaction are executed or none
are
Data Centers
Picture from Rice University: Data Center
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
46
23
CS 338: Computer Applications in Business: Databases (Fall 2014)
Data Centers
Picture from Microsoft: Data Center (Ireland)
47
Data Centers
Picture from Google : Council Bluffs (Iowa)
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
48
24
CS 338: Computer Applications in Business: Databases (Fall 2014)
Data Centers
Interested in getting more information about current
Google Data Centers?
Check http://www.google.com/about/datacenters/
49
1992-2014 by Addison Wesley & Pearson Education, Inc., McGraw-Hill. Some
material adapted and modified from Fundamentals of Database Systems (Elmasri et al.)
25