Download Chapter 5

Document related concepts

Database wikipedia , lookup

Relational model wikipedia , lookup

Clusterpoint wikipedia , lookup

Database model wikipedia , lookup

Transcript
Chapter 5
Database Processing
“We Don’t Have a Way to Track the Data About
the Videos.”
• Falcon Security stores sequentially numbered digital video
files in separated directories for each client.
• Tracking down exact footage of when equipment stolen
means searching hundreds of video files.
• Need database to track video files.
• MongoDB for tracking video files?
Copyright © 2017 Pearson Education, Inc.
5-2
Study Questions
Q1: What is the purpose of a database?
Q2: What is a database?
Q3: What is a database management system (DBMS)?
Q4: How do database applications make databases more useful?
Q5: How are data models used for database development?
Q6: How is a data model transformed into a database design?
Q7: How can Falcon Security benefit from a database system?
Q8: 2026?
Copyright © 2017 Pearson Education, Inc.
5-3
Q1: What Is the Purpose of a Database?
• Organize and keep track of things.
• Keep track of multiple themes.
• General rule:
– Single theme - store in a spreadsheet.
– Multiple themes - use a database.
• What's a theme?
– Ex: student grades, student emails, student office visits.
Copyright © 2017 Pearson Education, Inc.
5-4
A List of Student Grades Presented in a
Spreadsheet – Single Theme
Copyright © 2017 Pearson Education, Inc.
5-5
Student Data Form for a Database Application
Copyright © 2017 Pearson Education, Inc.
5-6
Q2: What Is a Database?
Copyright © 2017 Pearson Education, Inc.
5-7
Hierarchy of Data Elements
Copyright © 2017 Pearson Education, Inc.
5-8
Components of a Database
Copyright © 2017 Pearson Education, Inc.
5-9
Example of
Relationships
Among Rows
Copyright © 2017 Pearson Education, Inc.
5-10
Sample of Access Metadata
Copyright © 2017 Pearson Education, Inc.
5-11
Ethics Guide: Querying Inequality?
• MaryAnn has a data mart.
• Business professional majored in HR, now "expert" in SQL.
• Uses SQL to do job faster and better.
• Examined data, saw possible discriminatory pattern.
• What would you do from categorical imperative and utilitarian
perspectives?
Copyright © 2017 Pearson Education, Inc.
5-12
Ethics Guide: Querying Inequality? (cont’d)
• Queries could reveal all sorts of patterns and trends.
– Be sure what answers you want before starting query.
• How strongly do you feel about social and personal
responsibility, considering your needs and those of your family?
• How important is social responsibility posture of an employer to
you?
–Is that something to add to your criteria for a job search?
Copyright © 2017 Pearson Education, Inc.
5-13
So What? Not What the Data Says . . .
• Subjective:
– Small, nonrandom sample.
– Called four different sales reps who can’t get any prospects
to bite.
• Objective:
– Same month historical data, seasonal data comparisons.
• How to recognize and minimize bias?
– Use non-routine cognitive skills.
Copyright © 2017 Pearson Education, Inc.
5-14
Q3: What Is a Database Management System
(DBMS)?
• Program to create, process, administer a database.
• Licensed from vendors
–IBM, Microsoft, Oracle, and others.
 DB2, Access, SQL Server, Oracle Database.
• Open source
– MySQL: License-free for most applications.
Copyright © 2017 Pearson Education, Inc.
5-15
Processing the Database
DBMS Process Operations
1. Read
2. Insert
3. Modify
4. Delete data
Copyright © 2017 Pearson Education, Inc.
5-16
Processing the Database
• Structured Query Language - SQL (see-quell)
– International standard
– Used by nearly all DBMS
SQL Example
INSERT INTO Student
([Student Number], [Student Name], HW1, HW2, MidTerm)
VALUES (1000, ‘Franklin, Benjamin’, 90, 95, 100);
Copyright © 2017 Pearson Education, Inc.
5-17
Adding a New Column to a Table (in Access 2013)
Copyright © 2017 Pearson Education, Inc.
5-18
Administering the Database
• Set up security system, user accounts, passwords, permissions,
limits for processing.
• Limit user permissions.
• Back up database, improve performance of database
applications, remove unwanted data.
Copyright © 2017 Pearson Education, Inc.
5-19
Summary of Database Administration Tasks
Copyright © 2017 Pearson Education, Inc.
5-20
Summary of Database Administration Tasks
(cont'd)
Copyright © 2017 Pearson Education, Inc.
5-21
Q4: How Do Database Applications Make
Databases More Useful?
Forms
Queries
View data; insert new, update existing, delete
existing data.
Search using values provided by user.
Reports
Structured presentation of data using sorting,
grouping, filtering, other operations.
Application programs
Provide security, data consistency, special
purpose processing, e.g., handle
out-of-stock situations.
Copyright © 2017 Pearson Education, Inc.
5-22
Q4: How Do Database Applications Make
Databases More Useful? (cont'd)
Copyright © 2017 Pearson Education, Inc.
5-23
Example of a Student Report
Copyright © 2017 Pearson Education, Inc.
5-24
Query Example
Copyright © 2017 Pearson Education, Inc.
5-25
Browser Forms, Reports, Queries, and
Applications
Copyright © 2017 Pearson Education, Inc.
5-26
Account Creation Browser Form
Copyright © 2017 Pearson Education, Inc.
5-27
Browser
Report
Copyright © 2017 Pearson Education, Inc.
5-28
Graphical Query: User Clicks on Video Icon to Find
All Videos from that Location
Copyright © 2017 Pearson Education, Inc.
5-29
Multiuser Processing Problem
1.Andrea puts both
in shopping
baskets, but
delays checking
out.
1.Andrea reads
pedal record
showing balance
of 2 pedals.
1
2
3
2. Jeffrey reads
same record
showing balance
of 2 pedals.
1.Andrea proceeds
to checkout.
Someone will be
disappointed.
4
5
4.Jeffrey puts both
in shopping
basket and
checks out
before Andrea.
Copyright © 2017 Pearson Education, Inc.
5-30
Q5: How Are Data Models Used for Database
Development?
Copyright © 2017 Pearson Education, Inc.
5-31
What Is the Entity-Relationship Data Model?
Entities
• Something to track.
– Order, customer, salesperson,
item, volunteer, donation
Attributes
• Describe characteristics of entity.
– OrderNumber, CustomerNumber,
VolunteerName, PhoneNumber
Identifier
• Uniquely identifies one entity
instance from other instances
– Student_ID_Number
Copyright © 2017 Pearson Education, Inc.
5-32
Student Data Model Entities
Copyright © 2017 Pearson Education, Inc.
5-33
Example of Department, Adviser, and Student
Entities and Relationships (cont'd)
Copyright © 2017 Pearson Education, Inc.
5-34
Sample of Relationships―Version 1
Crow’s
Feet
1:N
One department may
have many advisers,
but an adviser may be
in only one department
N:M
An Adviser may have
many students, and
one student may have
many advisers
Copyright © 2017 Pearson Education, Inc.
5-35
Sample of Relationships─Version 2
“Crow’s
Foot”
N:M
A department has many
advisors, and an
advisor may advise for
more than one depart
1:N
A student has only
one advisor, but an
adviser may advise
many students
Copyright © 2017 Pearson Education, Inc.
5-36
Crow’s-Foot Diagram Version
Maximum cardinality─maximum number of entities in a
relationship. Vertical bar on a line means at least one entity
required.
Minimum cardinality—minimum number of entities in a
relationship. Small oval means entity is optional; relationship
need not have entity of that type.
Copyright © 2017 Pearson Education, Inc.
5-37
Q6: How Is a Data Model Transformed into a
Database Design?
• Normalization
– Converting poorly structured tables into two or more wellstructured tables.
• Goal
– Construct tables with single theme or entity.
• Purpose
– Minimize data integrity problems.
Copyright © 2017 Pearson Education, Inc.
5-38
Data Integrity Problems
• Data integrity problems.
– Incorrect or inconsistent information.
– Users lose confidence in information.
– System gets a poor reputation.
• Can only occur if data are duplicated.
Copyright © 2017 Pearson Education, Inc.
5-39
Poorly Designed Employee Table Causes Data
Integrity Problem
Copyright © 2017 Pearson Education, Inc.
5-40
Two Normalized Tables
Single
Themes
Copyright © 2017 Pearson Education, Inc.
5-41
Summary of Normalization
Copyright © 2017 Pearson Education, Inc.
5-42
Representing 1:N Relationships
Copyright © 2017 Pearson Education, Inc.
5-43
Representing an N:M Relationship: Strategy for
Foreign Keys
Copyright © 2017 Pearson Education, Inc.
5-44
Users’ Role in the Development of Databases
• Final judges.
• Thorough review of data model.
– Entities must contain all the data users need to do their jobs.
– Must accurately reflect their view of the business.
• Take it seriously.
• Devote time.
Copyright © 2017 Pearson Education, Inc.
5-45
Q7: How Can Falcon Security Benefit from a
Database System?
• Find videos by querying their characteristics.
– “Which videos do we have of the Beresford Building in
October 2014, shot from 3,000 feet or less?”
• Choices
1. Store videos on a file server and keep metadata about each
video in a relational database to query with SQL.
2. Use NoSQL MongoDB.
Copyright © 2017 Pearson Education, Inc.
5-46
Falcon Security Chooses Option 1
• Use Access to store
metadata.
• Less risky: uses
known technology.
• Creates E-R diagram.
• Decide to keep design
simple at first.
Copyright © 2017 Pearson Education, Inc.
5-47
Q8: 2026?
• Volume of database continues to grow.
• Cheap, unlimited storage, greater processing speeds do in
relational databases.
• Security becomes more important.
• Many NoSQL, NewSQL, and in-memory databases exist in
commerce.
Copyright © 2017 Pearson Education, Inc.
5-48
ACID Transactions
• Atomic, Consistent, Isolated, Durable transactions.
• Critical to traditional commercial applications.
• New Internet applications (Twitter) don’t need ACID.
Copyright © 2017 Pearson Education, Inc.
5-49
New Categories of DBMS
1. NoSQL DBMS (NotRelational DBMS)
• Supports very high transaction rates, processing relatively
simple data structures,
• Replicated on many servers in the cloud, without ACID
transaction support.
• MongoDB, Cassandra, Bigtable, and Dynamo.
Copyright © 2017 Pearson Education, Inc.
5-50
New Categories of DBMS (cont’d)
2. NewSQL DBMS
• Process very high levels of transactions, like NoSQL DBMS, but
provide ACID support.
• May or may not support relational model.
• Current hotbed of development.
3. In-memory DBMS using SQL extension
• SAP HANA, Tableau.
• High volume ACID transaction support with complex relational query
processing.
Copyright © 2017 Pearson Education, Inc.
5-51
Q8: 2026? (cont'd)
• Keep abreast of developments.
• Watch from investor’s perspective.
• New opportunities and career paths will develop around these
new DBMS products.
• Separate yourself from the competition when it comes to job
interviews.
Copyright © 2017 Pearson Education, Inc.
5-52
Security Guide: Theft by SQL Injection
• Common way of stealing data from corporations.
• Done by people outside of host nation to avoid prosecution.
• Highly organized and well-funded.
– Criminal syndicates, nation states, or political hacktivists.
– Mandiant report “APT1: Exposing One of China’s Cyber
Espionage Units”
• Attempting SQL injection could result in your arrest.
Copyright © 2017 Pearson Education, Inc.
5-53
Security Guide:
Theft by SQL
Injection (cont'd)
Copyright © 2017 Pearson Education, Inc.
5-54
Security Guide: Theft by SQL Injection (cont'd)
1. Retailers suffer two times as many SQL injection attacks as
other industries.
2. Most Web applications receive four or more Web attack
campaigns per month, and others are constantly under attack
(176 out of 180 days).
3. One Web site received 94,057 SQL injection attack requests in
one day.
Copyright © 2017 Pearson Education, Inc.
5-55
Guide: Immanuel Kant, Data Modeler
• Perception of reality based on our perceptive apparatus.
• Brain processes perceptions into something meaningful.
• Human’s model what appears to be.
• Users determine if a data model fits their perception of reality.
Copyright © 2017 Pearson Education, Inc.
5-56
Active Review
Q1: What is the purpose of a database?
Q2: What is a database?
Q3: What is a database management system (DBMS)?
Q4: How do database applications make databases more useful?
Q5: How are data models used for database development?
Q6: How is a data model transformed into a database design?
Q7: How can Falcon Security benefit from a database system?
Q8: 2026?
Copyright © 2017 Pearson Education, Inc.
5-57
Case Study 5: Dean's Piano Database
• Certified piano tuner and
technician repairing and restoring
pianos for many years.
• Clown entertainer at children’s
parties.
Copyright © 2017 Pearson Education, Inc.
5-58
Pianos in Storage
Copyright © 2017 Pearson Education, Inc.
5-59
Columns in
the Piano
Table
Copyright © 2017 Pearson Education, Inc.
5-60
Query Design and Result
Copyright © 2017 Pearson Education, Inc.
5-61
Piano Sound
Quality by Building
Copyright © 2017 Pearson Education, Inc.
5-62
Copyright © 2017 Pearson Education, Inc.